I have an image that is result of labeling and applying boundaries. Each object is labeled with a number, then its boundary is defined.
The code I used is the following:
% bwboundaries() returns a cell array, where each cell contains the
% row/column coordinates for an object in the image.
% Plot the borders of all the coins on the original grayscale image
% using the coordinates returned by bwboundaries.
figure(2);
imshow(bwImage);
[r, c, p] = size(bwImage);
hold on
title('Outlines, from bwboundaries()', 'FontSize', fontSize);
axis image;
% Make sure image is not artificially stretched because of
% screen's aspect ratio.
hold on;
boundaries = bwboundaries(bw5);
numberOfBoundaries = size(boundaries, 1);
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
hold off;
Now, I want to save the grayscale image AND the boundaries+labels applied above them in a variable, so that I can then do the following:
imwrite(A,'contours.jpg');
and save the image to do image post processing with GUI. It seemed really easy but every time I try it saves only the labels or only the boundaries on the grayscale image. I need both of them, as in the image I uploaded above. Thanks.
EDIT: As an alternative I could directly upload the image in a GUI interface but still, the problem of saving the correct image in a variable still remains.
You can use export_fig or saveas.
You can find many examples on the links, but the simplest command you can try is:
saveas(gcf,'filename.png')