I am trying to save the image at an specific size.

33 ビュー (過去 30 日間)
Atik Faysal
Atik Faysal 2021 年 1 月 7 日
コメント済み: Image Analyst 2021 年 1 月 8 日
Here is the code I am doing:
[wt,f] = cwt(y,'amor',12000);
h = figure();
t = 0:numel(y)-1;
hp = pcolor(t,f,abs(wt));
hp.EdgeColor = 'none';
set(gca,'xtick',[],'ytick',[],'xticklabel',[],'yticklabel',[]);
exportgraphics(gca,'myplot.png','Resolution',300)
I want to save the image at height and width of 224. How do I modify the resulotion value?

採用された回答

Rik
Rik 2021 年 1 月 7 日
The better way is to calculate the appropriate value.
However, you can also do this quick-n-dirty:
[wt,f] = cwt(y,'amor',12000);
h = figure();
t = 0:numel(y)-1;
hp = pcolor(t,f,abs(wt));
hp.EdgeColor = 'none';
set(gca,'xtick',[],'ytick',[],'xticklabel',[],'yticklabel',[]);
fn='myplot.png';R=300;
px_sz=[224 224];
exportgraphics(gca,fn,'Resolution',R);
im=imread(fn);
im=imresize(im,px_sz);
imwrite(im,fn);
Alternatively, you could also determine with what value you need to scale R to get your intended size in pixels. Note that this does not check if your image is square, so it may stretch your image.
  5 件のコメント
Atik Faysal
Atik Faysal 2021 年 1 月 8 日
I did not know that. Thank you for the info. However, I can not use imshow properly in my code. Would you care to show me how to do it?
[wt,f] = cwt(y,'amor',12000);
h = figure();
t = 0:numel(y)-1;
hp = pcolor(t,f,abs(wt));
hp.EdgeColor = 'none';
set(gca,'xtick',[],'ytick',[],'xticklabel',[],'yticklabel',[]);
fn='myplot.png';R=300;
px_sz=[224 224];
exportgraphics(gca,fn,'Resolution',R);
im=imread(fn);
im=imresize(im,px_sz);
imwrite(im,fn);
Image Analyst
Image Analyst 2021 年 1 月 8 日
imshow() takes an image so not sure what your image is - maybe f or wt. I don't have the Wavelet Toolbox so I can't run your code.

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by