How to save imshowpair figure using imwrite?

조회 수: 7 (최근 30일)
Kirsty Bennett
Kirsty Bennett 2020년 1월 31일
댓글: Md Shamim Hossain 2021년 7월 10일
How would I save the following as a binary image? I want to use imwrite, or be able to save it as a variable in the workspace so that I can use bwskel.
registered = imregister(Moving,Fixed,'Similarity',optimizer,metric);
figure
A = imshowpair(registered,Fixed);

답변 (2개)

Guillaume
Guillaume 2020년 2월 6일
No, no, no, don't use print or saveas, this is possibly going to rescale your image, change the the colour depth, etc.
A simpler and reliable way is to use imfuse instead of imshowpair. imshowpair is for displaying a pair, imfuse is for creating an image of the pair. In any other way, they work exactly the same and have the same options
registered = imregister(Moving,Fixed,'Similarity',optimizer,metric);
fusedpair = imfused(registered, Fixed);
imwrite(fusedpair, 'somefile.png');
  댓글 수: 3
Kirsty Bennett
Kirsty Bennett 2020년 2월 20일
Thank you so much!! Literally saved me today :D
Md Shamim Hossain
Md Shamim Hossain 2021년 7월 10일
Is it possible to save three images using the same process?

댓글을 달려면 로그인하십시오.


Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020년 2월 4일
Hey Kirsty,
Since imshowpair returns class matlab.graphics.primitive.Image, imwrite cannot be used directly. Instead, you can use the functions -
saveas(gcf, 'savedImage.jpeg', 'jpeg');
print(gcf, '-djpeg', 'savedImage.jpeg', '-r0'); % Print allows you to specify the resolution
% at which you want to save the image
Hope this helps!
  댓글 수: 1
Kirsty Bennett
Kirsty Bennett 2020년 2월 6일
Thank you Vinai. I'll use the saveas function :)

댓글을 달려면 로그인하십시오.

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by