Customizing the color channels for fusing two images in
1 次查看(过去 30 天)
显示 更早的评论
Hi
I have these two 2DFFT images (DSC_3675.pngFFT and DSC_4062.pngFFT). I have to superimpose them for comparison purpose, but when I amd doing it using imfuse or cat I am getting something like 'superimposed'. I want the two plos to be displayed on white background with two distinct colour (such as blue and red etc.)
Thank You
0 个评论
采纳的回答
DGM
2021-10-28
编辑:DGM
2021-10-28
This is a basic image blending operation. As such, I am going to elect to do this with MIMT tools instead of native MATLAB/IPT. MIMT is available on the File Exchange:
This will give you an image where the dark areas of the two images are represented as the specified colors against a white background:
A = imread('DSC_3675.pngFFT.png');
B = imread('DSC_4062.pngFFT.png');
colorA = [255 0 0];
colorB = [0 0 255];
s = imsize(A);
if any(s ~= imsize(B))
warning('image sizes don''t match; padding')
% adjust gravity to control colocation of images
S = imstacker({A,B},'gravity','center','padding',[1 1 1]);
A = S(:,:,:,1);
B = S(:,:,:,2);
s = imsize(A);
clear S
end
% generate colored underlays
cpA = colorpict(s,colorA,'uint8');
cpB = colorpict(s,colorB,'uint8');
% colorize images
A = imblend(A,cpA,1,'screen');
B = imblend(B,cpB,1,'screen');
% combine colorized images
C = imblend(A,B,1,'multiply');
imshow(C)
If you want specified colors on a black background:
A = imread('DSC_3675.pngFFT.png');
B = imread('DSC_4062.pngFFT.png');
colorA = [255 128 0];
colorB = [0 128 255];
s = imsize(A);
if any(s ~= imsize(B))
warning('image sizes don''t match; padding')
% adjust gravity to control colocation of images
S = imstacker({A,B},'gravity','center','padding',[1 1 1]);
A = S(:,:,:,1);
B = S(:,:,:,2);
s = imsize(A);
end
% generate colored underlays
cpA = colorpict(s,colorA,'uint8');
cpB = colorpict(s,colorB,'uint8');
% colorize images
A = imblend(imcomplement(A),cpA,1,'multiply');
B = imblend(imcomplement(B),cpB,1,'multiply');
% combine colorized images
C = imblend(A,B,1,'screen');
imshow(C)
As you can tell by this awful white website background, the readability of any image depends on its surroundings.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!