How to invert intensity values of a scalar frame?
5 views (last 30 days)
Show older comments
WKT ,each pixel has a value from 0 (black) to 255 (white)...But i need 255(white) and 0(black)..So any suggestions to change pixel values like this...
0 Comments
Accepted Answer
Geoff Hayes
on 4 Apr 2015
Vignesh - if the data type of each pixel in your image is an 8-bit unsigned integer, then just subtract these pixels from 255. For example,
myImg = uint8([zeros(400,200,3) 255*ones(400,200,3)]);
image(myImg);
will create a square image that is black on the left half and white on the right. If we then do,
image(uint8(255)-myImg);
then the left-half of the image is now white and the right-half is white, and so we have changed the pixels from 0 to 255 and 255 to 0.
Try the above and see what happens!
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!