2

Possible Duplicate:
imagesc plot to matrix in matlab
Scale Matrix to a new range

I have:

I = imread('image.tif');

At this point I can easly print the pixel with cord 100,100 by doing I(100,100)
Now I scale to image to fit the range 0.5...0.9

imagesc(I,[0.5 0.9]);
colormap('gray');

Is there any way to get the new matrix I ? (with pixel values from 0.5 to 0.9)

If i do

I  = imagesc(I,[0.5 0.9]);

I only get the handler to image object

Community
  • 1
  • 1
dynamic
  • 46,985
  • 55
  • 154
  • 231

2 Answers2

3

You can get the image data from an image plot with:

A = rand(100,100);
I = imagesc(A, [.5 .9]);
B = get(I, 'CData');

Predicting from your previous question: Scale Matrix to a new range I expect that B won't be you want. In fact B will be identical to A. This can be verified with:

all(all(A==B))

The second argument to imagesc doesn't scale the values in the provided matrix rather it scales the colormap.

Community
  • 1
  • 1
slayton
  • 20,123
  • 10
  • 60
  • 89
2

Try the getimage command:

A = rand(100,100);
I = imagesc(A, [.5 .9]);
B = getimage(gca);
Andrey Rubshtein
  • 20,795
  • 11
  • 69
  • 104