Guest User

Untitled

a guest
Jun 9th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. Image overlay with matrix
  2. %# some image
  3. I = im2double( imread('peppers.png') );
  4.  
  5. %# I create here a random mask (gaussian centered in middle of image)
  6. [r,c,~] = size(I);
  7. [X Y] = meshgrid(1:r,1:c);
  8. Z = mvnpdf([X(:) Y(:)], [r c]./2, diag(15.*[r c]));
  9. Z = (Z-min(Z(:)))./range(Z(:));
  10. Z = reshape(Z',[c r])';
  11.  
  12. %# show image and mask separately
  13. subplot(121), imshow(I)
  14. subplot(122), imshow(Z)
  15.  
  16. %# show overlayed images
  17. figure, imshow(I), hold on
  18. hImg = imshow(Z); set(hImg, 'AlphaData', 0.6);
  19.  
  20. %# also we can specify a colormap
  21. colormap hsv
Advertisement
Add Comment
Please, Sign In to add comment