Ah so I figured out the more urgent problem about the lower resolution. If I add truesize(gcf) in between imshow and getframe all pixels are also present in saved image. Still have the large white frame though.
Saving image with Colorbar in high quality
23 次查看(过去 30 天)
显示 更早的评论
Hi,
I want to save images with a colormap and a colorbar and use the following code below. The code saves a file, but the saved file has a large white frame and contains less pixels than if I display the images via imshow. Below is a comparison of the result of imshow vs. the saved image from the code. How can I save the image(s) in the same quality as seen via imshow?
imshow image:
saved image:
for n=1:length(out(1,1,:))
imshow(out(:,:,n)) %out is a stack containing all images, which are supposed to be saved
colormap parula
colorbar
caxis([0 color_scale]) %color_scale is some integer value, which was calculated previously
temp=getframe(gcf)
img=filename(5*n-4); %this line and the next 2 are for proper naming of the file
img2=split(img,'result of ');
img3=replace(img2,'.tif','.png');
fullfilename=fullfile(folder2,img3{2});
imwrite(temp.cdata,fullfilename)
clear temp
end
3 个评论
Adam Danz
2022-9-16
Have you tried expanding your axes to the size of your figure by setting the position property of your axes?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Import, Export, and Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!