REEM
REEM

Reputation: 13

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 :'(

Upvotes: 0

Views: 323

Answers (1)

abcd
abcd

Reputation: 42245

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

"Why am I getting this picture enter image description here

instead of this"

enter image description here

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.

Upvotes: 1

Related Questions