How to save the image obtained from 'imagesc' plot for further processing?

조회 수: 24 (최근 30일)
Iam using 'dlmread' to read the data and for plotting the data iam using 'imagesc'. first of all is it correct way to save the image in .png or .jpg formats... while Iam saving the image size is changed. (ex: in my data from 2048*130 to 560*420*3). while saving the data xlabel, ylabel and title also visible. actually I want to apply wavelet denoiosing and feature extraction on my data please help me in this regard.
here I have attached my code. I cannot able to attach data files it is not supported.. In this program my bscan image is saved in 'Y_T1', without writing all the code I have copied Y_T1 data in excel sheet and saved in text(Tab delimited), it is saved in notepad file. I recall the file using 'dlmread' and plotted using imagesc... Is it correct way or not?
img=dlmread('Y_T1.txt', '\t', 0, 0);
X_scan=linspace(0,129,44);
df=20e6;
NFFT=2048;
Fs=(NFFT-1)*df;
dt=1/Fs;
T_record=1/df;
T_array=0:dt:T_record;
imagesc(X_scan,T_array,img)
ylim([0 10e-9])

채택된 답변

Walter Roberson
Walter Roberson 2021년 5월 24일
Note that image() and imagesc() and imshow() do not accept individual coordinates for each row or column. They ignore everything except the first and last coordinates in a vector of coordinates. So where you imagesc(X_scan,T_array,img) that would be treated like
imagesc([0 129], [0 T_record], img)
You are asking about the size changing when you save the image, but if the size does not change then you need to explain how you want the change in coordinates to be handled. With some file formats it would be possible to set the image resolution headers in the file, so that at some level something knows that your 2048 rows corresponds to 5e-8 units... but that is quite unlikely to be of any practical use.
If you are using a fairly recent version of MATLAB, use
rimg = rescale(img);
and then imwrite() rimg if you really need it saved to a file.
If you are not using quite as modern a version then
rimg = mat2gray(img); %badly named function
You say
I want to apply wavelet denoiosing and feature extraction on my data please help me in this regard.
Doing that does not require writing the data to an image file: you could work directly with the rimg matrix.
  댓글 수: 9
Walter Roberson
Walter Roberson 2021년 5월 28일
Reminder: when you imwrite() double precision to a png file, the effect is as-if you had first done im2uint8 -- so floor(TheImage * 255) is what gets written to the file. That could lose details. Whereas if you just load the data from the workspace directly, it will not lose the details.
santhosh kumar buddepu
santhosh kumar buddepu 2021년 5월 31일
No sir, it is not expected to be tall and thin, while plotting using imagesc my image is like as i have uploaded.I have loaded XT2 data directly from workspace still it is like as i uploaded previously.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by