Saving image changes size.
4 ビュー (過去 30 日間)
古いコメントを表示
saveas saves the wrong dimensions, truesize doesn't adjust the image to its true size? In c++ the image just diplays the whole size, but I can't do something similar here.
imwrite does not save the image with the drawn rectangles, but saves the correct dimensions.
How do I fix my code to save the correct dimensions and also the drawn rectangles?
tar_loc = '...\images\';
im = imread([tar_loc '001.jpg']);
fig = figure(420);
imshow(im);
axis on;
window_pos = [ 1131 367 575 534];
template_pos = [1279 508 258 273];
hold on;
r1_window = images.roi.Rectangle(fig.CurrentAxes,'Position', window_pos, 'Label','Window','FaceAlpha', 0, 'Color',[1 0 0]);
r2_template = images.roi.Rectangle(fig.CurrentAxes,'Position',template_pos, 'Label','Template','FaceAlpha', 0, 'Color' , 'y');
I = getimage(fig);
imwrite(I, [filepath 'target.png']) %Saves correct size
truesize(fig)
saveas(fig.CurrentAxes, [filepath 'target_roi.png']); %Saves wrong size
imdon2 = imread([filepath 'target.png']);
size(imdon2)
0 件のコメント
回答 (1 件)
awezmm
2019 年 10 月 23 日
Try using the export_fig package: https://www.mathworks.com/matlabcentral/fileexchange/23629-export_fig
You have lots options with this package on how to save a figure, like choosing to save at native resolution.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Read, Write, and Modify Image についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!