Why does IMWRITE produce an empty image when I try to save a figure to the disk folder?
古いコメントを表示
I currently have a MATLAB figure that has a button to allow the user to save that image to the folder. I would like when the user clicks on the button, the save dialog window to appear so that the user can specify the name, type and location.
From the search that I did in here, I think I need to use uiputfile and imwrite to accomplish this. I tried the code below which is called when the user click on the save button but it saves an empty image. fh3 is the handle for the figure.
function pbsave_callback(source, eventdata, fh3)
[files, path, index] = uiputfile({'*.jpg';'*.gif';'*.*'},'Save As');
imwrite(fh3, files, 'jpg');
end
採用された回答
その他の回答 (2 件)
Walter Roberson
2011 年 2 月 7 日
1 投票
imwrite() writes a matrix of data as an image. It is taking your fh3 as a single 1 x 1 pixel of image data.
Use saveas() to copy figures to image files.
S
2011 年 2 月 7 日
0 投票
2 件のコメント
Walter Roberson
2011 年 2 月 7 日
What Units are you using for the controls?
When you saveas() or print() the figure PaperPosition and PaperPositionMode take effect, with an effective resize operation.
I recommend you use the matlab file exchange contribution "export_fig"
S
2011 年 2 月 7 日
カテゴリ
ヘルプ センター および File Exchange で Images についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!