필터 지우기
필터 지우기

How to find the dark pixels in an image?

조회 수: 10 (최근 30일)
Al Falamanki
Al Falamanki 2017년 11월 28일
댓글: Al Falamanki 2017년 11월 28일
Hello. I have a lot of images like this one:
From the whole shrimp, I would like to determine the area of dark pixels as a percentage of the visible surface. Does anybody have an idea how to do that? My idea is to first define/find the desired color and then filter the image for that defined color.
Thanks Falamanki

채택된 답변

Bshara Murr
Bshara Murr 2017년 11월 28일
I = imread('shrimp.bmp');
N = I(:,:,3)>100;
I(:,:,2) = I(:,:,2)>100;
Where the second line treats each color channel separately, 3 represents the blue color, you can use 1 and 2 for red and green the 100 is the threshold that you can change as you with, you can use < as well, this gives you a bw image of the desired channel. the third line returns an rgb image but with a certain color channel thresholded but it will alter your white background as well.
  댓글 수: 4
Bshara Murr
Bshara Murr 2017년 11월 28일
Aha okay. Did you find what you were looking for?
Al Falamanki
Al Falamanki 2017년 11월 28일
I am working on it, but so far, i think will get a satisfactory solution. Thanks !!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 11월 28일
You could try rgb2gray, then imbinarize using some brightness level you consider to be "dark", and count the number of 0 in the result.

Community Treasure Hunt

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

Start Hunting!

Translated by