Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %Nioi Pier Giuliano
- %Creating negative of a grayscale image [in the right way]
- %Clean up all variables and close all existing windows
- clear all
- close all
- % step 1
- %load a grayscale image
- I=imread('cameraman.tif');
- %show images
- subplot(4,2,1); imshow(I); title('original image');
- subplot(4,2,2); imhist(I); title('hist of original image');
- % step 2
- %calling my function to create negative of I
- N=negative(I);
- %show images
- subplot(4,2,3); imshow(N); title('negative image');
- subplot(4,2,4); imhist(N); title('hist of negative image');
- % step 3
- %negative of negative, must be equeal to I
- NN=negative(N);
- if(NN==I)
- disp('NN IS equal to I');
- else
- disp('NN IS NOT equal to I');
- end
- % step 4
- %wrong negative function
- WN=wrong_negative(I);
- %show images
- subplot(4,2,5); imshow(WN); title('wrong negative image');
- subplot(4,2,6); imhist(WN); title('hist of wrong negative image');
- % step 5
- %wrong negative of wrong negative, should be equeal to I, but..
- NWN=wrong_negative(WN);
- if(NWN==I)
- disp('NWN IS equal to I');
- else
- disp('NWN IS NOT equal to I');
- end
- % step 6
- %using matlab IPT function for comparisons
- N2=imcomplement(I);
- if(N==N2)
- disp('N2 IS equal to N');
- else
- disp('N2 IS NOT equal to N');
- end
- %show images
- subplot(4,2,7); imshow(N2); title('matlab negative image');
- subplot(4,2,8); imhist(N2); title('hist of matlab negative image');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement