recognize black dot
古いコメントを表示
Hi, i' m a college student, and i need your help. I have some images of white dices (with black points) on red background and i need to recognize the value on visible face of dices. I tried to convert image on black-white but the result is really wrong...can someone recommend some links about those problems?
thanks!
採用された回答
その他の回答 (1 件)
Walter Roberson
2011 年 6 月 19 日
1 投票
You are not clear about what "the result is really wrong" means ?
Threshold your image based upon either the blue or green channels. bwlabel() the image. regionprops() and look at the hole count of each region: it will be the number of dots (unless the shadows are fairly deep.)
9 件のコメント
Ignazioc calo
2011 年 6 月 19 日
Image Analyst
2011 年 6 月 19 日
If the image is good (contiguous blobs and no spurious isolated noise pixels), you don't even need regionprops() - bwlabel() returns the number of blobs as the second (optional) output argument. You can threshold on the red channel - that way you won't have to worry about calling imclearborder.
redChannel = rgbImage(:,:,1);
spotsImage = redChannel < someThreshold;
[labeledImage numberOfSpots] = bwlabel(spotsImage);
He should post the actual image somewhere if he wants any more precise advice.
Image Analyst
2011 年 6 月 19 日
You won't get the best contrast if you convert to grayscale. You should pick one of the color channels. Post your image on your favorite free file hosting website such as tinypic.com.
Ignazioc calo
2011 年 6 月 19 日
Image Analyst
2011 年 6 月 19 日
When you threshold like this:
dadobw = im2bw(dadogray,level);
you're getting the bright things, not the dark spots like you want. You'd have to invert your image and then possibly call imclearborder depending on if you got any of the red background with that threshold. Like I said, thresholding on the red channel would probably be best and easiest. Of course even that can have problems if you have a varying light intensity over the background.
Walter Roberson
2011 年 6 月 19 日
If you threshold on green or blue, then you would be masking out the red background and you would detect the blue or green component that goes to make up the white. The resulting binary image would be set (logical 1) where there were die faces, so bwlabel() would label the individual faces (imagine there being more than one die in a picture.) Then the "holes" in the faces would correspond to the black dots on the faces, and counting the holes within the individual objects (which regionprops will do for you) tells you the number of pips on the face. No border clearing needed, and no confusing the red of the background with the red component of the white faces.
Ignazioc calo
2011 年 6 月 19 日
Walter Roberson
2011 年 6 月 19 日
Indeed, the sample pictures do turn out to have two dice -- and a number of black spots on the red background. The algorithm I suggest would not have any difficulty with the black spots on the background.
Walter Roberson
2011 年 6 月 19 日
EulerNumber is the regionprops() value you want. It will be 0 or negative, being one (1) object minus the number of holes (dots).
Depending on how distinct the dots are and whether there is any significant noise, it is possible that you might need to use imdilate() to fill in speckles or trim irregular shadows.
カテゴリ
ヘルプ センター および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!