Calibrating mask for for accuracy
2 次查看(过去 30 天)
显示 更早的评论
I have the following images.
![](/matlabcentral/answers/uploaded_files/6040/1.jpg)
![](/matlabcentral/answers/uploaded_files/6041/LCC1.jpg)
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)
![](/matlabcentral/answers/uploaded_files/6038/untitled1.jpg)
![](/matlabcentral/answers/uploaded_files/6039/untitled2.jpg)
Or is there a way to remove the noise (white spots) in the background and make the background "pure black"? Thanks
0 个评论
采纳的回答
Image Analyst
2013-12-21
You need to adjust the thresholds. Look at this custom demo I wrote for you (attached).
23 个评论
Image Analyst
2013-12-30
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.
更多回答(1 个)
Walter Roberson
2013-12-21
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 个评论
Walter Roberson
2013-12-22
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().
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!