Calibrating mask for for accuracy

2 views (last 30 days)
Elvin
Elvin on 21 Dec 2013
Commented: Elvin on 2 Jan 2014

I have the following images.

I'm trying to mask the green part only using the code:

LCC = imread('1.jpg');
test_mask = LCC(:,:,2) > 175;  %same setting for both images

Though the calibration is already at 175, I'm still getting white spots when using imshow(test_mask)

Or is there a way to remove the noise (white spots) in the background and make the background "pure black"? Thanks

Accepted Answer

Image Analyst
Image Analyst on 21 Dec 2013
You need to adjust the thresholds. Look at this custom demo I wrote for you (attached).
  23 Comments
Image Analyst
Image Analyst on 30 Dec 2013
No, it's not. You're not realizing certain things. For one, the blades are a lot brighter than you think they are. In fact when we look at the RGB values of both the standards and test images:
standardMeans =
160.214758458431 197.181622129674 58.9798316015043
151.791390004578 172.326893656249 103.610183415117
140.489793180539 156.166890704425 117.035337936326
153.707747416186 161.159521297862 136.795286601503
testMeans =
169.575414791022 212.304643393041 133.444469974054
183.017321075119 228.922035175274 136.424941826779
152.051015834026 199.078477650428 110.05266640506
160.274121743674 207.052936770004 129.50083587363
161.01396762605 207.530082395828 126.591355056847
we see that the test means are bright. For example they are all at least 199 in the green. Now, which standard is that bright? The first one, not the second one. True, the second one may be a better match than the first one if you looked at just the hue and saturation, but if you include the lightness(value) the first one is a better match. There is also a problem with your standards in that they have bright and dark ridges so they have a bimodal histogram. Perhaps you're just paying attention to the brighter color and that's why your eyes are deceiving you. I think it's because you don't have good control over your intensity. Or maybe you just need to, or want to ignore the differences in lightness and just look at the differences in a and b. You can calculate the differences in ab instead of E (which is l, a, and b) if you want to ignore intensity.
I've attached my new program which uses actual filenames, and has different folders for standard and test images, and also calculates RGB means for you to examine.
Elvin
Elvin on 2 Jan 2014
Thank you for the explanation. The staffs at the IRRI are the one who said that the following images belong to this/that panel. That's why it is already classified according to their panels. To tell you, they just look at the leaf and compare it with the LCC using only their eyes. We are basing the accuracy of our program based on the results that IRRI has given to us. So that's why I'm worried that I'm not reading the same results with the IRRI.
Anyway, I guess our problem is with the taking of the pictures. I guess we need to adjust the lighting properly. I guess we have to build a nice setup when taking pictures for both the LCC and the leafs.
By the way, thank you very much for the help. I'll take a look at the new program once I get home

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 21 Dec 2013
White is high in all of R, G, B, whereas the Green part that you want will be low in R or B (or both.) So you can test something like,
test_mask = LCC(:,:,2) > 175 & LCC(:,:,1) < 128; %128 chosen arbitrarily
  2 Comments
Elvin
Elvin on 21 Dec 2013
I've tried it but I've got almost a pure black output
Walter Roberson
Walter Roberson on 22 Dec 2013
test_mask = LCC(:,:,2) > 100;
then bwopen() on test_mask.
You have a spot inside your leaf where the green channel goes as low as 110.
Your red channels turn out to be fairly high all over inside the leaf, including values as high as 224. The blue channel is generally notably lower than the red channel, but peaks as high as 247 (one bright spot right at the edge of the leaf, but over 240 in some other spots as well.)
Your leaf is not all "green": the white along the ribs and the white speckles elsewhere, are important to the overall appearance. You need to keep those white spots when they are inside the leaf, but an isolated white spot of the same intensity in the background needs to be removed. This suggests that although you should threshold based on color, that you should also be throwing away small points. Such as by using bwopen().

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!