Question

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 http://imgur.com/R1QZh32.

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.

Was it helpful?

Solution

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top