remove double boundary at image border (bwareaopen, bwperim)
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am using a Matlab example to find the contours in an image and outline them. This technique works very well for all structures on the inside of the image. If one of the structures (finger-like electrodes under the microscope) is cut at the image's border the routine tries to close it, resulting in a "double contour" of the finger.
I need to make the program realize that the structure is in fact at the border and the outer contour should be the only one detected.
Using imclearborder I can remove the contours of objects affected, but this would affect to many of the shapes I am trying to trace!
I tried uploading an snapshot of the problem, but my university seems to be blocking every site I know and tried, so I can only attach the code (pretty straight forward from the ML examples) and abused my profile photo for the image. Sorry for that.
function [ output_args ] = process_sem( I_sem, diamondsize, bwareaopensize, bwperimconnectors )
%Finds outlines in a grayscale image and displays them in overlay
J = adapthisteq(I_sem,'NumTiles', [8 8], 'clipLimit', 0.002,'Distribution', 'exponential');
h1 = fspecial('gaussian',5,5); % set up a Gaussain filter
Im1 = imfilter(J,h1,'replicate'); % filter the signal by Gaussian filter
Im2 = im2bw(Im1,graythresh(Im1)+0.1);
se=strel('diamond',diamondsize);
Im2=imdilate(Im2,se);
Im2=imerode(Im2,se);
%If border-connection should be removed uncomment the following line
%clearbordersconn=4;
%Im2=imclearborder(Im2,clearbordersconn);
se90 = strel('line', 3, 45);
se0 = strel('line', 3, 0);
Im2= imdilate(Im2, [se90 se0]);
Im3 = bwareaopen( Im2, bwareaopensize);
Im3=imfill(Im3, 'holes');
%final smoothing
seD = strel('diamond',1);
Im2 = imerode(Im2,seD);
Im2 = imerode(Im2,seD);
%final smoothing end
Im3outline = bwperim(Im3,bwperimconnectors);
Segout = I_sem;
Segout(Im3outline) = 255;
figure;imshow(Segout), title('outlined original image');
[imx,imy] = gradient(double(Im3outline),1.0);
output_args = [imx, imy, Im3 ];
Any help is very much appreciated!
Kind regards, Chris
0 comentarios
Respuesta aceptada
Image Analyst
el 14 de En. de 2013
Why would imclearborder() change the contours of the remaining objects? Any object touching the border you want to remove because you don't have the entire object in the field of view. Unless you're talking about the insides of those rod-shaped things and you want to keep the inside even if the bright perimeter slightly touches the edge. It would be good for you to somehow find a way to upload an image. How about a site on your university's own server? It should not complain about that.
5 comentarios
Image Analyst
el 15 de En. de 2013
Sure - you have all the coordinates. Use norm(), hypot() or the Pythagorean theorem.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!