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
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