【问题标题】:using imwrite on a labeled image on matlab在 matlab 上的标记图像上使用 imwrite
【发布时间】: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


    【解决方案1】:

    您可以使用export_fig 或saveas。

    您可以在链接上找到许多示例,但您可以尝试的最简单的命令是:

    saveas(gcf,'filename.png')
    

    【讨论】:

    • 干杯伙伴我搞砸了 WHERE 添加特定命令。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-16
    • 2014-11-21
    • 1970-01-01
    • 1970-01-01
    • 2013-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多