How to get image of figure with exact same size after saving on computer
古いコメントを表示
I would like to save image from a figure with exact same size. I have used export setup for specific size (e.g. points) of image. However, it becomes a different dimension after saving on computer memory. Is there any way to get the image of that figure with exact same size after saving it.
回答 (1 件)
Image Analyst
2019 年 9 月 22 日
0 投票
Using saveas() or export_fig() will give you an image the same size in pixels as the displayed figure.
If you have an axes on that figure and want just the stuff in the axes, you can use getimage() or getframe() to get an image.
If you have an image, you can use imwrite() and that will save it with the same size.
8 件のコメント
Rafi Ahmed
2019 年 9 月 22 日
編集済み: Rafi Ahmed
2019 年 9 月 22 日
Image Analyst
2019 年 9 月 22 日
Where did the image come from? Is it a graph/plot? Or an image?
saveas() saves the whole window including the surrounding padding/white space.
How did you create the picture in the axes on the figure that you saved with saveas()? Did you use plot() or imshow() or image() or imagesc() or pcolor() or something else?
Did you try my other suggestions of getframe(), getimage(), or imwrite()?
Rafi Ahmed
2019 年 9 月 22 日
編集済み: Rafi Ahmed
2019 年 9 月 22 日
Rafi Ahmed
2019 年 9 月 25 日
Walter Roberson
2019 年 9 月 25 日
編集済み: Walter Roberson
2019 年 9 月 25 日
If you want to save only what is pcolor'd, then do not use pcolor() and saveas()
Use arcsin(linspace(0,1,WidthOfOutputImage)) to get x coordinates to use in your matrix of power values. That is, your meshgrid() with sin() makes for a non-linear pcolor output, and you need to linearize it by finding the x values that map into each output pixel wide.
mat2gray() to map 10*log10(pxx) to the range 0 to 1, and then multiply by the number of entries in the colormap you are using, floor(), uint8() and ind2rgb() with that colormap. The result should be an RGB image.
Rafi Ahmed
2019 年 9 月 25 日
Walter Roberson
2019 年 9 月 25 日
You have
[Az Doppler] = meshgrid(sin(phi*pi/180),fdop);
so Az will be "sin spaced" apart -- closer together near -180, 0, and +180 than near +-90 degrees. When you then use Az as the x coordinate for pcolor, it has to put the elements closer together or further apart because of that.The distance between adjacent values is not constant with what you are doing now. But when you create an image, the distance between adjacent values (pixels) is constant. So you have to substitute in original non-linearly spaced phi coordinates such that sin() of them translates after the sin() to be linearly spaced.
However, I just realized that you have a problem: for each x value in the range (-1,1) exclusive, there are two phi values that map to that same x value. Your surface folds back on itself, and you need to decide which of the folds is the one that you want to appear in the output.
Rafi Ahmed
2019 年 9 月 25 日
編集済み: Rafi Ahmed
2019 年 9 月 25 日
カテゴリ
ヘルプ センター および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!