Distinguishing ROI within an image with a different color

12 views (last 30 days)
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)

Accepted Answer

Image Analyst
Image Analyst on 3 May 2021
  1 Comment
Warid Islam
Warid Islam on 3 May 2021
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?

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!