Manipulating overlap colors from imfuse

조회 수: 21 (최근 30일)
Aaron Devanathan
Aaron Devanathan 2021년 8월 17일
편집: Image Analyst 2021년 8월 18일
Hello,
I am wondering if there is a way to manipulate the overlap colors when fusing two images via imfuse?
When I run the below code, the fused_image output shows the overlap in a lighter magenta color, which is hard to see adjacent to the magenta of image_2. I'd like to manipulate the overlap color if possible. Any thoughts? Happy to provide clarification as needed.
fused_image=imfuse(image_1, image_2, 'ColorChannels', [2 1 2]);
  댓글 수: 1
DGM
DGM 2021년 8월 17일
편집: DGM 2021년 8월 18일
It's kind of hard to tell what you're after without knowing what images you're using and what features you're trying to make clear. The overlap "color" is simply a linear combination of [1 0 1] and [0 1 0]. In this scheme, you could change the colors to any complementary pair, but the combinations will always be neutral grays at best.

댓글을 달려면 로그인하십시오.

답변 (2개)

DGM
DGM 2021년 8월 17일
편집: DGM 2021년 8월 18일
First approach:
This basically replicates what you're already doing, but it's flexible.
% two test images
A = im2double(imread('cameraman.tif'));
B = fliplr(A);
% pick any two complementary colors
% i.e. the sum of the two vectors should be [1 1 1]
ct = [1 0 1; 0 1 0];
ct = permute(ct,[1 3 2]);
C = A.*ct(1,1,:) + B.*ct(2,1,:);
imshow(C)
As it says, you can pick whatever colors:
ct = [1 0.5 0; 0 0.5 1];
ct = permute(ct,[1 3 2]);
C = A.*ct(1,1,:) + B.*ct(2,1,:);
imshow(C)
Second approach:
Maybe this is more along the lines of what you're after:
% combine two images using a 3-color representation of luma
A = im2double(imread('cameraman.tif'));
B = fliplr(A);
% pick any triad
ct = [1 0 0; 0 0 1; 0 1 0];
Ao = max(A-B,0); % A only
Bo = max(B-A,0); % B only
mix = min(A,B); % A and B
% compose image (simple average if ct is a triad)
ct = permute(ct,[1 3 2]);
C = Ao.*ct(1,1,:) + Bo.*ct(2,1,:) + mix.*ct(3,1,:);
imshow(C)
For what it's worth, this is the map describing the behavior of this routine.
ct = [1 0 0; 0 0 1; 0 1 0];
% use two orthogonal gradients
x = linspace(0,1,256);
[B A] = meshgrid(x);
Ao = max(A-B,0);
Bo = max(B-A,0);
mix = min(A,B);
ct = permute(ct,[1 3 2]);
C = Ao.*ct(1,1,:) + Bo.*ct(2,1,:) + mix.*ct(3,1,:);
subplot(2,2,1)
imshow(flipud(A))
title('A')
subplot(2,2,2)
imshow(B)
title('B')
subplot(2,2,3)
image(x,x,C)
axis('equal')
set(gca,'ydir','normal','xlim',[0 1],'ylim',[0 1])
xlabel('B luma')
ylabel('A luma')
title('C')

Image Analyst
Image Analyst 2021년 8월 18일
편집: Image Analyst 2021년 8월 18일
If you want to "fuse" two gray scale images "manually" you can use cat().
[rows, columns, numColors] = size(image1);
black = zeros(rows, columns, class(image1));
rgbImage = cat(3, image1, image2, black);
You can experiment with putting image1, image2, and black into the various positions until you see something you like. You could even combine them into an average image and put that into one of the color channels if you want:
aveImage = uint8((double(image1) + double(image2))/2);
rgbImage = cat(3, image1, aveImage, black);
or you could weight one of the images, or both of them, to amplify or suppress it
darkerImage2 = uint8(double(image2) * 0.3);
rgbImage = cat(3, image1, black, darkerImage2);

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by