Reputation: 1298
I am trying to overlay one image on top of another in MATLAB.
I checked out Superimpose two images in MATLAB for an answer. But the issue is that the overlayed images are being shown as blue boxes on the original image, instead of the actual image.
The incorrect output is shown here https://i.sstatic.net/7tH3Q.jpg.
The code I am using is
a = 0.2;
tform = affine2d([1 0 0; a 1 0; 0 0 1]);
B = imwarp(z,tform, 'FillValues',255);
B = ~B;
figure; imshow(B);
h = imagesc([X1 X2], [Y1 Y2], B);
set(h, 'AlphaData', 1);
The normal imshow(B)
shows me the correct image but the overlaying part is giving me the problem.
I have tried changing the value of AlphaData
but that doesn't seem to be working.
Upvotes: 0
Views: 277
Reputation: 2359
Have a look to function imshowpair with properties Blend
You can try this too :
figure;
h = imshow(FirstImage);
set(h,'AlphaData',0.2);
hold on;
imshow(SecondImage);
hold off;
Upvotes: 1