开发者

Image Processing with Matlab

Today I'm learning most of the rules in matlab and need help to make thi开发者_高级运维s function get the maximum and minimum of each color

 function [mini,maxi] = min_max(imageName)
ima = imread(imageName);
imshow(ima);
ima = rgb2gray(ima);
imagesc(ima);
axis image;
mini = min(min(ima));
maxi = max(max(ima));

when I using this picture

[mini,maxi]=min_max('peppers.png');

![I see this pic][1]

please help me :'(


I don't see any pictures in your post, but I think your question is:

"Why am I getting this picture

Image Processing with Matlab

instead of this"

Image Processing with Matlab

The reason is because you haven't specified a colormap and imagesc defaults to the jet colormap. To get a grayscale image, use colormap(gray) after the imagesc line

Secondly, as a general tip, if you want to find the min or max value in the entire matrix, instead of calling it twice, use min(ima(:)) and max(ima(:)). This will give you the same answer and is much faster when your matrix size is large and/or when you use it repeatedly in loops.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜