Displaying how many pixels in the third plane of image

조회 수: 1 (최근 30일)
SAMIA ALGHAMDI
SAMIA ALGHAMDI 2017년 5월 30일
답변: KSSV 2017년 5월 30일
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)))

채택된 답변

KSSV
KSSV 2017년 5월 30일
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')

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by