Overlaying one image on another gives blue boxes instead of image - MATLAB

房东的猫 提交于 2019-12-25 07:59:18

问题


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.


回答1:


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;


来源:https://stackoverflow.com/questions/24046434/overlaying-one-image-on-another-gives-blue-boxes-instead-of-image-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!