Imfuse two images together from different sizes

3 views (last 30 days)
Marina Ghobrial
Marina Ghobrial on 17 May 2021
Answered: DGM on 17 May 2021
I want to imfuse two images with one another that are two different matrixes.
A and moving are the images on top of one another. The first image (moving) is much smaller so I tried resizing it by utilizing the resize command. Can you please help
hold on;
C = imfuse(A, originalfalsecolor','Scaling','joint','ColorChannels',[1 2 0]);
C = imresize(C, 0.75);
J = imresize(moving, [616 220]);
imshow (J)
%M = imresize( A,[size(moving,1) size(moving,2)]);
[D,RD] =imfuse(A, moving,'ColorChannels',[1 2 0]);
D = imresize(D, 0.75);

Answers (1)

DGM on 17 May 2021
If the images are different sizes, you need to at least know where to put one image with relation to the other -- i.e. an offset. imfuse uses registration objects, but you don't seem to be using any of the functionality of imfuse anyway. Why not just do it the simple way?
A = imread('peppers.png'); % bigger picture
B = imread('lsbwm.bmp'); % smaller picture
sb = size(B);
offset = [100 100]; % specify where the picture goes
chantoswap = [1 2 3]; % specify which channels to swap
% just directly put the image content there
% if you want to extend beyond the edges of the parent image, then you'll
% need to deal with that. (e.g. pad A, place B, crop result)
outpict = A;
outpict(offset(1)+(1:sb(1)),offset(2)+(1:sb(2)),chantoswap) = B(:,:,chantoswap);
I'm sure someone else can come up with a solution using imfuse, but I never use it.

Community Treasure Hunt

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

Start Hunting!