简体   繁体   English

用Matlab进行图像处理

[英]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 今天,我正在学习Matlab中的大多数规则,并且需要帮助以使此函数获得每种颜色的最大值和最小值。

 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] ![我看到这张照片] [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. 原因是因为您尚未指定colormapimagesc默认为jet颜色图。 To get a grayscale image, use colormap(gray) after the imagesc line 要获得灰度图像,请在imagesc行之后使用colormap(gray)

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(:)) . 其次,作为一般性提示,如果要在整个矩阵中找到minmax ,而不是两次调用,请使用min(ima(:))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. 这将为您提供相同的答案,并且在矩阵大小较大和/或在循环中重复使用它时会更快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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