I'm using imshow
to create this binary image. When it shows the figure I see a grey background and no edges in the figure. If I save the plot in as .png
, I see the background as white and I can't see any edges on the figure. How can I add edges to this plot?
Image as shown by imshow
:
Image as saved to PNG:
By default, saved figures have a white background. Ensure that the colors of the saved figure match the colors on the display by setting the InvertHardcopy
property of the figure to 'off'
.
Example:
A = rand(300, 300) > 0.1;
f = figure();
f.InvertHardcopy = 'off';
imshow(A);
title('Binary Image threshold 0.9');
saveas(f, 'test.png');
gives:
Alternatively, it is possible to set the visibility of the axes in the imshow
and make the ticks empty:
A = rand(300, 300) > 0.1;
f = figure();
iptsetpref('ImshowAxesVisible', 'on');
imshow(A);
xticks({});
yticks({});
title('Binary Image threshold 0.9');
saveas(f, 'test.png');
that gives:
Source: Matlab Documentation