Advertisement
iampiergiu

main.m

Oct 1st, 2011
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.41 KB | None | 0 0
  1. %Nioi Pier Giuliano
  2. %Creating negative of a grayscale image [in the right way]
  3. %Clean up all variables and close all existing windows
  4. clear all
  5. close all
  6.  
  7. % step 1
  8. %load a grayscale image
  9. I=imread('cameraman.tif');
  10. %show images
  11. subplot(4,2,1); imshow(I); title('original image');
  12. subplot(4,2,2); imhist(I); title('hist of original image');
  13.  
  14. % step 2
  15. %calling my function to create negative of I
  16. N=negative(I);
  17. %show images
  18. subplot(4,2,3); imshow(N); title('negative image');
  19. subplot(4,2,4); imhist(N); title('hist of negative image');
  20.  
  21. % step 3
  22. %negative of negative, must be equeal to I
  23. NN=negative(N);
  24. if(NN==I)
  25.     disp('NN IS equal to I');
  26. else
  27.     disp('NN IS NOT equal to I');    
  28. end
  29.    
  30.  
  31. % step 4
  32. %wrong negative function
  33. WN=wrong_negative(I);
  34. %show images
  35. subplot(4,2,5); imshow(WN); title('wrong negative image');
  36. subplot(4,2,6); imhist(WN); title('hist of wrong negative image');
  37.  
  38. % step 5
  39. %wrong negative of wrong negative, should be equeal to I, but..
  40. NWN=wrong_negative(WN);
  41. if(NWN==I)
  42.     disp('NWN IS equal to I');
  43. else
  44.     disp('NWN IS NOT equal to I');    
  45. end
  46.  
  47. % step 6
  48. %using matlab IPT function for comparisons
  49. N2=imcomplement(I);
  50. if(N==N2)
  51.     disp('N2 IS equal to N');
  52. else
  53.     disp('N2 IS NOT equal to N');    
  54. end
  55. %show images
  56. subplot(4,2,7); imshow(N2); title('matlab negative image');
  57. subplot(4,2,8); imhist(N2); title('hist of matlab negative image');
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement