简体   繁体   中英

Image Processing with Matlab

Today I'm learning most of the rules in matlab and need help to make this 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 在此处输入图片说明

instead of this"

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM