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

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!

 Réponse acceptée

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))

Plus de réponses (1)

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));

Catégories

En savoir plus sur Color and Styling dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by