Is it possible to count the bolts in this image?

4 vues (au cours des 30 derniers jours)
Nathan Hughes
Nathan Hughes le 29 Mar 2017
Commenté : androidguy le 29 Mar 2017
Hello,
I've been practicing my segmentation on a number of different challenges, this one I've been having a lot of problems with and was hoping I could get a pointer in the right direction. I'm confident it's fairly simple, my methods are just the wrong ones.
Any help is greatly appreciated!
  2 commentaires
Matt J
Matt J le 29 Mar 2017
What's the method that hasn't worked?
androidguy
androidguy le 29 Mar 2017
Try this?
clear variables
clc
close all
warning off
I1 = imread('screws.png');
figure, imshow(I1), title('original image');
I = rgb2gray(I1);
figure, imshow(I), title('original image');
[~, threshold] = edge(I, 'sobel');
fudgeFactor = .8;
BWs = edge(I,'sobel', threshold * fudgeFactor);
figure, imshow(BWs), title('binary gradient mask');
se90 = strel('line', 3, 90);
se0 = strel('line', 3, 0);
BWsdil = imdilate(BWs, [se90 se0]);
figure, imshow(BWsdil), title('dilated gradient mask');
BWdfill = imfill(BWsdil, 'holes');
figure, imshow(BWdfill);
title('binary image with filled holes');
BWnobord = imclearborder(BWdfill, 4);
figure, imshow(BWnobord), title('cleared border image');
seD = strel('diamond',1);
BWfinal = imerode(BWnobord,seD);
BWfinal = imerode(BWfinal,seD);
figure, imshow(BWfinal), title('segmented image');
BWoutline = bwperim(BWfinal);
Segout = I;
Segout(BWoutline) = 255;
figure, imshow(Segout), title('outlined original image');

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Image Filtering and Enhancement dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by