Matlab: individual connected components

I worked on the problem of image processing with coin detection.

I have some images like this:

http://dennlinger.bplaced.net/t06-4.jpg

and wanted to separate the falsely bound coins.

We have already tried the watershed method, as indicated on the MATLAB homepage:

especially since the first example is our problem.

But instead, we get somehow a very messy separation, as you can see here:

http://dennlinger.bplaced.net/myAwesomeTry.PNG

We have already extracted the coin area using the regionprops Extrema parameter and selected the watershed only for the desired area.

I would appreciate any help in resolving the problem, or even another way to separate it.

+4
2

Image Processing Toolbox, Circular Hough Transform imfindcircles. R2012a, , , .

, , . , . , Hough Transform, . Hough - , .

, . , , , . imfindcircles :

[centers,radii] = imfindcircles(A, radiusRange);

A , radiusRange - , , . :

  • centers: N x 2, (x,y) , , - x, , y .
  • radii: , . N x 1.

imfindcircles, , Sensitivity. , , , , , . , . 0,85. 0,9, . , , , 50 150 . :

im = im2bw(imread('http://dennlinger.bplaced.net/t06-4.jpg'));
[centers,radii] = imfindcircles(im, [50 150], 'Sensitivity', 0.9);

StackOverflow. logical true black white, uint8. im. imfindcircles .

, , imshow, , viscircles .

imshow(im);
viscircles(centers, radii, 'DrawBackgroundCircle', false);

viscircles . , , . , :

enter image description here

, centers radii. centers , radii , .


, , regionprops, , . , - :

[X,Y] = meshgrid(1:size(im,2), 1:size(im,1));
IDs = zeros(size(im));
for idx = 1 : numel(radii)
    r = radii(idx);
    cen = centers(idx,:);

    loc = (X - cen(1)).^2 + (Y - cen(2)).^2 <= r^2;
    IDs(loc) = idx;
end

, meshgrid ID , . , , , , . ID . IDs , bwlabel. , , idx, :

cir = IDs == idx;

, , [0-255] :

imshow(IDs, []);

enter image description here

, imfindcircles.

, , , , . , , - ID. cool, + 1 . - :

cmap = cool(numel(radii) + 1);
RGB = ind2rgb(IDs, cmap);
imshow(RGB);

, cool. , ind2rgb, .

, :

enter image description here

+3

: , , , .

, Image Processing, imerode - . . , - Matlab , /, .

( ), , ima.jpg :

ima=imread('ima.jpg');
se = strel('disk',50);
eroded = imerode(ima,se);
imshow(eroded)

, . bwlabel , , .

enter image description here

0

Source: https://habr.com/ru/post/1570237/


All Articles