how to remove object that contain more than X% black pixels
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
i have some roi and i want to remove roi that has more then 90% black pixels how can i do that???
0 Commenti
Risposte (1)
Image Analyst
il 26 Dic 2014
Modificato: Image Analyst
il 26 Dic 2014
Is your ROI in the form of a binary image? Are there multiple regions in that binary image? Just call regionprops and find blobs where the (FilledArea - Area) / FilledArea > 0.1.
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'FilledArea', 'Area');
allAreas = [measurements.Area];
allFilledAreas = [measurements.FilledArea];
darkRatios = (allFilledAreas - allAreas) / allFilledAreas;
darkIndexes = find(darkRatios > 0.1);
newLabeledImage = ismember(labeledImage, darkIndexes);
% Relabel
labeledImage = bwlabel(newLabeledImage > 0);
% Measure again with new blobs.
measurements = regionprops(labeledImage, 'FilledArea', 'Area');
3 Commenti
Image Analyst
il 27 Dic 2014
It's only 9 lines of code, that do what you asked for.
If you really wanted OCR instead, then you should have said so initially and posted your image.
Vedere anche
Categorie
Scopri di più su Convert Image Type in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!