开发者

draw a rectangle on top of overlaid images

I would like to overlay two images in MATLAB (I and imagesc(data)) and then draw a rectangle on top of those. I2 specifies the transparency pattern in the following code. The rectangle becomes a line on top of the image. Can anyone tell me why the rectangle is not drawn correctly?

imshow(I);           
hold on;
h = imagesc(data,[0,1]);    
hold off;
I2开发者_如何学Go = ones(height,width) * 80;
set(h, 'AlphaData', I2);
rectangle('Position',[100,100,20,20]);    


Since we can't reproduce your code exactly without all the data, here is a complete example with sample images:

%# some sample images
I = imread('coins.png');
I_transp = imread('peppers.png');

%# create a gaussian mask for transparency
[r,c,~] = size(I_transp);
M = fspecial('gaussian', [r c], mean([r c]./5));
M = (M-min(M(:)))./range(M(:));

%# show overlayed images
figure, imshow(I, 'XData',[1 c], 'YData',[1 r]), hold on
hImg = imshow(I_transp);
set(hImg, 'AlphaData',M);

%# draw a rectangle
rectangle('Position',[355 220 100 100], 'LineWidth',2, 'EdgeColor','b');

draw a rectangle on top of overlaid images

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜