Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 9th, 2012  |  syntax: None  |  size: 0.53 KB  |  hits: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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