MATLAB: Combine /fuse two images into one

2d image3d imagecombine imagesdigital image processingfuse imageimage processingimfuseMATLABmerge

Hi all
I have two images . I want to combine them into one image .1st images has a size of 512×271
and the second image has a size of 512x271x512
I want to combine them into one image with size of 512x271x512 like last image
but I don't know how I can do this . I have used imfuse but its not working for me . any one help me in tis matter

Best Answer

im1 = imread('one.JPG');
other_images = .... whatever is needed to read your 512x271x512 into an array
blend = 0.2;
mask1 = imbinarize(im1);
fused = other_images;
for slice = 1 : size(fused, 3)
this_slice = fused(:,:,slice);
this_slice(mask1) = this_slice(mask1) * (1-blend) * im1(mask1);
fused(:,:,slice) = this_slice;
end
Here, blend is the portion of the image that should be used at those locations, rather than just overwriting the pixels with the white line.