【发布时间】:2018-04-27 12:22:14
【问题描述】:
我有一个图像是标记和应用边界的结果。每个对象都标有一个数字,然后定义其边界。
我使用的代码如下:
% 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;
现在,我想将灰度图像和应用在它们上方的边界+标签保存在一个变量中,这样我就可以执行以下操作:
imwrite(A,'contours.jpg');
并保存图像以使用 GUI 进行图像后期处理。这看起来很简单,但每次我尝试时它只保存标签或灰度图像上的边界。我需要他们两个,就像我上面上传的图片一样。谢谢。
编辑:作为替代方案,我可以直接在 GUI 界面中上传图像,但仍然存在将正确图像保存在变量中的问题。
【问题讨论】:
标签: matlab image-processing image-segmentation boundary