Reputation: 1613
I have read a image like that
a = imread('test.jpg');
image(a)
what the test.jpg is:
but after the image function
the result is:
and I don't know why it show that?
Because I want to crop some part, so I have to see the image shown.
How to fix it by showing the human face by image?
Upvotes: 0
Views: 49
Reputation: 973
You image data might be in a color map instead. try [a,cmap] = imread(...)
. If cmap is not empty, a
is indices into cmap
, and cmap
contains the actual colors.
Use img = cat(3,cmap(a,1),cmap(a,2),cmap(a,3))
to get your image, and show it with image(img)
.
Note that using imagesc
might be misleading in this case as it will still show something that looks like your image when simply doing imagesc(a)
. This as different pixels colors are associated with different index-values in a
.
Upvotes: 0
Reputation: 9075
You are using image
command to display an image. From here: "image creates an image graphics object by interpreting each element in a matrix as an index into the figure's colormap or directly as RGB values". Since you are providing a 2-D matrix, each element is interpreted as the index to the figures colormap. You can see the figure's colormap by using
c_map=colormap;
Also, the axis is set to square, therefore you see a circle instead of an ellipse. Use imshow(a,[])
to display the grayscale image as desired.
Upvotes: 1