Reputation: 17
How do you invert an image (reversing grayscale) in MATLAB?
Upvotes: 0
Views: 10360
Reputation: 125854
If it's a grayscale intensity image of class uint8
, you can do this:
reversedImg = 255-img;
If it's a grayscale intensity image of class double
, the pixel values should be between 0 and 1, so you can do this:
reversedImg = 1-img;
Upvotes: 9
Reputation: 47082
I think that you're looking for the imcomplement function if you have the imaging processing toolbox.
Upvotes: 4