Matlab Edge Image Deletion

I am trying to remove a border from my image in Matlab. enter image description here I tried this

clc,clear,clf

Im=im2double(imread('Im.png'));
imshow(Im);title('Original Image')
pause(.5)
imshow(edge(Im));title('after Sobel')
pause(.5)
imshow(Im-edge(Im));title('Im-edge(Im)')

and result

enter image description here

but there are two obvious problems:

  • The edgedefault output Sobelcontains some inside of the form.
  • Subtract the binaryimage from gray scaleone! (output edgeis binary)

    Any help would be appreciated.

Download the original image.

+4
source share
1 answer

, , , , . . , , . , , . , , .

Stack Imgur, - :

enter image description here

"" , . 5 , , , . , imerode imdilate, 5 × 5 .

% Read from Stack Imgur directly
im = imread('/img/0f4664860a3f6ef58f2ffe83464b5be9.png');

% Perform Sobel Edge detection
sim = edge(im, 'sobel');

% Find the mask of the object
mask = im > 5;

% Shrink the object
se = strel('square', 5);
mask_s = imerode(mask, se);

% Remove the inner boundary of the object
mask(mask_s) = false;

% Slightly enlarge now to ensure outer boundary is removed
mask = imdilate(mask, se);

% Create new image by removing the boundaries of the 
% edge image
sim(mask) = false;

% Show the result
figure; imshow(sim);

:

enter image description here

Sobel, , . , , .

+1

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


All Articles