Manipulating overlap colors from imfuse

21 次查看(过去 30 天)
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