Please anybody tell me how to remove only the protrusion from this image using just the morphological operations. Also I want to reduce the circle (white color) radius by 5 pixels. I know we can do that by using erosion but what should be the structuring element's(disk type) radius should be and how many iterations should we perform for the selected radius.
I mean can we have structuring element se =strel('disk',5) and perform one iteration or se = strel('disk',1) and perform 5 iterations.

Matlab has a simple function for you to do this. You can use a morphological open operation and morphological erode operation to achieve this. The code can be found below.
I = imread( 'O3Z7j.jpg' );
figure; imshow( I )
D = imopen(I,strel( 'disk', 50 ) );
figure; imshow( D )
E = imerode(D,strel( 'disk', 5 ) );
figure; imshow( E )
Essentially as Wiki describes it, morphological open is the "dilation of the erosion of a set A", where erosion is defined here. To create the structuring element kernel, you can use strel( 'disk', n ) to define a disc of radius n.
The result is shown here.

Here is the image before the erosion.

The before image is shown here.

EDIT: Performance
>> sum( sum( I>128 ) )
ans =
227675
>> sum( sum( D>128 ) )
ans =
227173
>> 227675 - 227173
ans =
502
EDIT 2: Added imerode for new requirement.
Assume your image is in a BW array, you can find the center of the main disk with bwdist and then find the pixels that are anormally distributed with respect to the distance to the center.
In practice, this gives:
tol = 25;
% --- Get the center
D = bwdist(1-BW);
[~,I] = max(D(:));
[y, x] = ind2sub(size(BW), I);
% --- Find distances
[Y, X] = find(BW);
J = find(BW);
[d2, K] = sort((X-x).^2 + (Y-y).^2);
z = 1:numel(d2);
f = fit(z', d2, 'poly1');
I = (d2 > z'*f.p1 + f.p2 + tol);
BW(J(K(I))) = 0;
and the result:

You can tune the parameter tol to erode more or less the protrusion, but it should not be below 20 otherwise you with remove pixels of the main disk.
Best,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With