i need negative image

341 views (last 30 days)
Miss SHOOSH
Miss SHOOSH on 28 Oct 2015
Edited: DGM on 25 Apr 2022
Hello .. I need help with transformation in grey level to transform cameraman.tiff image to negative version .. using Matlab code .. thanks
  4 Comments
Miss SHOOSH
Miss SHOOSH on 28 Oct 2015
Ok Thanks .. anyone else can help? I have to apply negative transformation to the image cameraman.tif

Sign in to comment.

Answers (3)

VIBHOR AGARWAL
VIBHOR AGARWAL on 8 Feb 2018
Edited: VIBHOR AGARWAL on 8 Feb 2018
You can also use MATLAB's in built function- `imcomplement(Image)` for this purpose.

Image Analyst
Image Analyst on 28 Oct 2015
Try this with a uint8 image:
positiveImage = imread('CameraMan.tif');
negativeImage = 255 - positiveImage;

DGM
DGM on 25 Apr 2022
Edited: DGM on 25 Apr 2022
It's best to avoid writing your code around unchecked assumptions of array class.
If you have Image Processing Toolbox, imcomplement() should work fine.
A = imread('peppers.png');
B = imcomplement(A);
imshow(B)
If you don't have IPT, MIMT iminv() (attached) does the same thing. It will work fine for images of any standard numeric/logical class. If you want to know how it works, just open it up and see.
A = imread('peppers.png');
B = iminv(A);
imshow(B)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!