Advertisement
iampiergiu

wrong_negative.m

Oct 1st, 2011
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.61 KB | None | 0 0
  1. %Nioi Pier Giuliano
  2. %creates negative of grayscale image
  3. %
  4. %function usage
  5. %    imshow(negative(imread('cameraman.tif')));
  6. %
  7. %
  8.  
  9. function immNeg=wrong_negative(image)
  10. %create output image of the same size as the input image
  11. [rows,cols]=size(image);
  12. immNeg=zeros(rows,cols);
  13.  
  14. %conversion for working double
  15. %values range in [0,1] , instead of [0,255]
  16. image=im2double(image);
  17.  
  18. %finding max and min gray level value
  19. max_gray=max(max(image));
  20.  
  21. %Wrong trasformation
  22. for i=1:rows
  23.     for j=1:cols
  24.         immNeg(i,j)=max_gray - image(i,j);
  25.     end
  26. end
  27.  
  28. %conversion back to uint8
  29. immNeg=im2uint8(immNeg);
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement