Count all green pixels above a threshold and colour them
5 次查看(过去 30 天)
显示 更早的评论
I would like to evaluate an image with the Imageprocessing toolbox. More precisely, I would like to count all green pixels that are above a threshold. Afterwards all used pixels should be coloured, so that it is visually traceable which pixels were used.
How is this possible?
0 个评论
回答(1 个)
Ameer Hamza
2020-9-15
编辑:Ameer Hamza
2020-9-15
See this example, this take the green channel of input image, find all pixels above a threshold, and give them red color.
img = im2double(imread('pears.png'));
r = img(:,:,1);
g = img(:,:,2);
b = img(:,:,3);
mask = g > 0.7;
r(mask) = 1;
g(mask) = 0;
b(mask) = 0;
img_new = cat(3, r, g, b);
img:
img_new:
5 个评论
Ameer Hamza
2020-9-16
I don't think it is easy to separate this part based on pixels color alone. You may need to try the image segmentation app
imageSegmenter
and use some other segmentation methods such as flood fill algorithm to separate this region.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!