Saving a plot as png 224*224*3 image

Hi,
I have generated a plot in Matlab as shown in figure.When i save it using 'saveas(gcf,'im1.png')' , it is saved as a 656*875*3 png image.I want to save it as 224*224*3 png image without the axis titles,labelling and colorbar.i.e.only the actual plot.Can anyone kindly guide on it?
guide about
Thanks

2 comentarios

KALYAN ACHARJYA
KALYAN ACHARJYA el 17 de Feb. de 2021
Editada: KALYAN ACHARJYA el 17 de Feb. de 2021
Can you share plot details?
ali
ali el 18 de Feb. de 2021
Its a spectrogram with frequency on y axis and time on x axis

Iniciar sesión para comentar.

Respuestas (1)

Rik
Rik el 17 de Feb. de 2021

0 votos

You can do three things:
  1. Don't create your image as a plot, but as an image.
  2. Crop the image down to the location of your axes object.
  3. Use export_fig.

14 comentarios

ali
ali el 18 de Feb. de 2021
Can you kindly guide further about option 1?
Rik
Rik el 18 de Feb. de 2021
That depends on how you created this plot. You can probably round your data to integer and use ind2rgb to convert to an RGB image. If you attach example data and your code, we might be able to give an explicit example.
ali
ali el 20 de Feb. de 2021
load('data.mat');
x = sum(AA/max(max(abs(AA)))); %normalizing bw 0 and 1 and summing across rows
a=size(x);
for k=4960:4960:a(2)
x1=x(k-4959:k);
figure();
c=jet(256);colormap(c);
spectrogram(x1,hanning(512),487,1024,12.4e3,'centered','yaxis','MinThreshold',-60);
end
Rik
Rik el 20 de Feb. de 2021
Your data is not attached and if hanning is a function, it no longer exists (although there is a hann function).
I don't have the signal processing toolbox, so I will need to expirement with the Run feature in this forum.
ali
ali el 23 de Feb. de 2021
I am unable to attach data as max limit is 5MB for attachments.
Rik
Rik el 23 de Feb. de 2021
Can you reduce the size of the variables? Is all data really necessary? The image will look differently, but I should still be able to reproduce a similar image.
ali
ali el 8 de Mzo. de 2021
Hi,
Attached is the data..loop will not be necessary as data is less now.
Rik
Rik el 8 de Mzo. de 2021
What code should I be using?
ali
ali el 22 de Mzo. de 2021
load('data.mat');
x = sum(AA/max(max(abs(AA)))); %normalizing bw 0 and 1 and summing across rows
a=size(x);
for k=4960:4960:a(2)
x1=x(k-4959:k);
figure();
c=jet(256);colormap(c);
spectrogram(x1,hanning(512),487,1024,12.4e3,'centered','yaxis','MinThreshold',-60);
end
Rik
Rik el 24 de Mzo. de 2021
Your mat file contains the variable data, which is not even used by the code. How am I supposed to help you like this?
Check that your code doesn't use any variables appart from those in the mat file.
Put your mat file in a separate folder, call clearvars and then run your code. If it doesn't run for you, it will not run for me either.
And please use the S=load('data.mat') syntax. That will show you immediately where variables are coming from. If it isn't followed by AA=S.AA; I don't even have to download your mat file before telling you that you fix your example.
Also, use the formatting tools when posting.
ali
ali el 16 de Jun. de 2021
Hi Rik,
Sorry for replying late. Actually, i uploaded the data file after modification(due to attachment size limitation) but forgot to change code accordingly. I have corrected the code as follow. Now it will work with the mat file. Make sure to put the mat file in the Matlab path.
load('data.mat');
x = sum(data/max(max(abs(data)))); %normalizing bw 0 and 1 and summing across rows
figure();
c=jet(256);colormap(c);
spectrogram(x,hanning(512),487,1024,12.4e3,'centered','yaxis','MinThreshold',-60);
Rik
Rik el 16 de Jun. de 2021
Please use the S=load('data.mat') syntax.
ali
ali el 17 de Jun. de 2021
S=load('data.mat');
x = sum(S.data/max(max(abs(S.data)))); %normalizing bw 0 and 1 and summing across rows
figure();
c=jet(256);colormap(c);
spectrogram(x,hanning(512),487,1024,12.4e3,'centered','yaxis','MinThreshold',-50);
ali
ali el 24 de Jun. de 2021
Hi @Rik,
Waiting for your response.
thanks

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Productos

Versión

R2018a

Preguntada:

ali
el 17 de Feb. de 2021

Comentada:

ali
el 24 de Jun. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by