intersection the red edges of the mask to a grayscale image

2 次查看(过去 30 天)
Hi; I have two images of lungs first in grayscale and the second with a mask, I want to make the edges of the mask intersect with the grayscale image, so that the resulting image remains in grayscale and the edges are red, I have a problem where I can not keep the image in grayscale because the code does not work without "label2rgb"
I = imread('001.png');
[B,L] = bwboundaries(I,'noholes');
I = imread('002.png');
img2(:,:,1)=I;
img2(:,:,2)=I;
img2(:,:,3)=I;
imshow(label2rgb(I, @jet, [.0 .0 .0]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 1)
end

采纳的回答

Matt J
Matt J 2021-10-1
Is this what you want?
I = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/755699/001.png');
[B,L] = bwboundaries(I,'noholes');
I = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/755704/002.png');
img2(:,:,1)=I;
img2(:,:,2)=I;
img2(:,:,3)=I;
imshow(I)
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 1)
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by