How to colorize a range of pixel values in a grayscale image?

5 views (last 30 days)
Hello everyone. I have a grayscale image of 112*112. I want to specify every pixel value in this image from 0 to 256, with zero being black and 256 being white, and the middle pixel values either lesser dark or lesser white. I am using imacesc funciton for this purpose but it is graying out the whole image.
Can someone tell me how can I assign certain pixel values to certain colors in this image so that I can explain what's happening inside it more clearly in my project. Thanks.

Answers (1)

Rik
Rik on 19 Nov 2020
You can either adjust the colormap, or use imshow. If your image is not uint8, you will have to scale it down to [0,1] to make sure imshow will correctly scale your image.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!