Customizing the color channels for fusing two images in

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

Accepted Answer

DGM
DGM on 28 Oct 2021
Edited: DGM on 28 Oct 2021
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.

More Answers (0)

Categories

Find more on Display Image in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!