Distinguishing ROI within an image with a different color

3 次查看(过去 30 天)
I have a image named as TM10.jpg. After segmentation, the result is displayed as i2.jpg. I am trying to fuse those images together where I would like to highlight the result in the fused image with a separate color. The fused image is displayed in i1.jpg. I want to display the brightest region in the center by a green color. I came up with a solution shown in i3.jpg. Here, the background is completely black. I want the center to be green and the background color as similar as in i1.jpg Any suggestion would be very much appreciated.
I=imread('TM10.jpg');
J=imread('i2.jpg');
figure,imshow(J)
I=RemoveWhiteSpace(I);
figure,imshow(I)
J=RemoveWhiteSpace(J);
figure,imshow(J)
[rowsI colsI numberOfColorChannelsI]=size(I);
[rowsJ colsJ numberOfColorChannelsJ]=size(J);
if rowsJ ~= rowsI || colsI ~= colsJ
J = imresize(J, [rowsI colsI]);
end
% If it's grayscale, convert to color
if numberOfColorChannelsI < 3
I = cat(3, I, I, I);
else
% It's really an RGB image already.
I = I;
end
% If it's grayscale, convert to color
if numberOfColorChannelsJ < 3
J = cat(3, J, J, J);
else
% It's really an RGB image already.
J = J;
end
J = uint8(J * 256);
% Specify the color we want to make this area.
redChannel = J(:, :, 1);
greenChannel = J(:, :, 2);
blueChannel = J(:, :, 3);
allBlack = zeros(size(J, 1), size(J, 2), 'uint8');
just_red = cat(3, redChannel, allBlack, allBlack);
figure,imshow(just_red)
C = imfuse(I,just_red,'falsecolor','Scaling','joint','ColorChannels',[1 2 0]);
imshow(C)

采纳的回答

Image Analyst
Image Analyst 2021-5-3
  1 个评论
Warid Islam
Warid Islam 2021-5-3
It worked. I have another issue. The result is shown in s.jpg. It can be seen that there is a blue border on the right and left side of the image. Is there any way to remove those?

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by