filtering single pixel defects
6 views (last 30 days)
Show older comments
Hello
I am trying to sort different bins of defect after thresholding. What I want to is to get rid of single pixel defects and count the others. What I have is:
%% image= after thresholding
CC = bwconncomp(ima2, 8);
numPixels = cellfun(@numel,CC.PixelIdxList);
which here by ploting "numPixels", I can tell I have different bins and mostly single pixels. By a simple loop I can change single pixel in "numPixels" to zero. However, I want to map the defect on the image by this:
Stats_1 = regionprops(CC,'Centroid');
centroids = cat(1,Stats_1.Centroid);
imshow(image);
hold on;
plot(centroids(:,1),centroids(:,2),'bo');
hold off
Here, I used "CC" to extract the location of the defects which has a single defects included.
I was trying to use "strel(nhood)" to define single pixel with others after thresholding. But, I was not able to do it correctly. Any help would be apprecited or any other approches to do this sorting.
Thanks in advance.
0 Comments
Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!