簡體   English   中英

在matlab上的標簽圖像上使用imwrite

[英]using imwrite on a labeled image on matlab

我有一幅圖像是標注和應用邊界的結果。 每個對象都標有數字,然后定義其邊界。

圖片要保存

我使用的代碼如下:

% 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界面中上傳圖像,但是仍然存在將正確的圖像保存在變量中的問題。

您可以使用export_figsaveas

您可以在鏈接上找到許多示例,但是您可以嘗試的最簡單的命令是:

saveas(gcf,'filename.png')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM