MATLAB: Displaying how many pixels in the third plane of image

image processing

Hi, I'm new to Matlab can you help me figuring out how to solve these two questions?. how can I display how many pixels in the third plane of the image is greater than 150. Do I need to use nested for loop to count them? or there is an easier way to do that. another question if I want to display the minimum value in the second plane of the image on the screen.is this right?
% x= imread('image.jpg');
min(min(x(:,:,2)))

Best Answer

I = imread('peppers.png') ;
R = I(:,:,1) ;
G = I(:,:,2) ;
B = I(:,:,3) ;
%%pixels in B greater then 150
[y,x] = find(B>150);
figure(1)
imshow(B) ;
hold on
plot(x,y,'.r')
%%minimum value in G
[val,idx] = min(G(:)) ;
[i,j] = ind2sub(size(G),idx) ;
figure(2)
imshow(G) ;
hold on
plot(i,j,'*r')