Creating mask that take only area with specific number of pixel using convolution
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to make binary mask that take only areas with specific number of pixel,using convolution I know how to calculate number of pixels,but I cant figure out how to convolve the mask over the image and make it return only the areas within range of pixels and ignore the rest.. I tried many times, but nothing works.. I would greatly appreciate any help
0 commentaires
Réponses (1)
Image Analyst
le 3 Déc 2014
Let's say you have a binary image called "binaryImage", and let's say you want to make another binary image called "mask" that is "true" only when the scanning window has 8 to 15 "true" pixels in binaryImage. So, first you'd count the number of pixels in the window, let's say the window is 5 by 5.
countImage = conv2(double(binaryImage), ones(5), 'same');
Now find pixels where the count is in the range 8 to 15, inclusive
mask = countImage >= 8 & countImage <= 15;
That's it. You're done. mask is the final resulting binary image.
2 commentaires
Image Analyst
le 3 Déc 2014
Would have been nice to know that from the beginning. Advice on image processing is always better if you have an image to look at rather than guessing "blind".
You're going to have to separate them first. Either call watershed() or do repeated imerode() until they split apart.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!