How to save the image obtained from 'imagesc' plot for further processing?
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
santhosh kumar buddepu
el 24 de Mayo de 2021
Comentada: santhosh kumar buddepu
el 31 de Mayo de 2021
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])
0 comentarios
Respuesta aceptada
Walter Roberson
el 24 de Mayo de 2021
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 comentarios
Walter Roberson
el 28 de Mayo de 2021
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Large Files and Big Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!