How can I make a gray-scale image with a continuously changing intensity pattern?

2 views (last 30 days)
Hi. I am trying to figure out how to make a gray-scale image with a continuously changing intensity pattern. For example, if I run the code below, I get a staircase-like discrete pattern along the horizontal direction because of the limited number of colormap values (?). I wonder if I can make it displayed more smoothly.
x = [1:10000]; figure(1), imagesc(x), colormap gray
Thank you!

Accepted Answer

Shashank Prasanna
Shashank Prasanna on 1 Feb 2013
I used your suggestion, is this better?
x = [1:10000]; figure(1), imagesc(x), colormap gray
set(gcf,'colormap',repmat(linspace(0,1,250)',1,3))

More Answers (1)

Image Analyst
Image Analyst on 1 Feb 2013
If you don't specify the number of steps in the colormap, it defaults to 64 which give rise to the step-like appearance. You can specify how many steps to give the colormap, up to a max of 256. So do this, to give a smoother appearance:
colormap(gray(256));

Categories

Find more on Colormaps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!