carlsbad
carlsbad

Reputation: 17

Inversion of an image

How do you invert an image (reversing grayscale) in MATLAB?

Upvotes: 0

Views: 10360

Answers (3)

user3859472
user3859472

Reputation: 29

use img=~img.

it may work I guess.

Upvotes: -2

gnovice
gnovice

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

Justin Peel
Justin Peel

Reputation: 47082

I think that you're looking for the imcomplement function if you have the imaging processing toolbox.

Upvotes: 4

Related Questions