# Ridge finding in noisy 2D image

I'm using MATLAB, and have experience with it but not with this kind of problem. I'm trying to identify white lines in noisy 2D images such as the one below. I can separate the brighter ones just by thresholding, but the dimmer ones (like in the bottom left) are tricky. Any suggestions? I guess I need some kind of ridge detection. It's worth noting that the background isn't entirely uniform... the brightness of the dim filaments might even be lower than the background noise in other parts of the image. So maybe some kind of local filtering instead of uniform background subtraction. As you can see I don't know where to begin.

Ideally I would will want to produce a skeleton describing all the lines for further analysis (measuring lengths). Of course this involves dealing with cross-overs and stuff too, but for now if I can just detect all the lines that would be a good start.

• can you please let me know how to calculate the length of fibers also of this image – garima verma Apr 22 at 7:41

My proposal would be:

1. Filter noise
2. Create image without the lines
3. Subtract the image without the lines from the image with the lines
4. Apply threshold
5. Postprocess the image

Code:

close all;
% acquire input image
img = rgb2gray(img);
% remove some noise
img_gauss = imfilter(img,fspecial('gaussian',10,2));
figure();
imshow(img_gauss);
% remove all the lines from the image
img_filtered = medfilt2(img_gauss,[31,31],'symmetric');
figure();
imshow(img_filtered);
% subtract image without lines from image with lines
img_subtracted = uint8(double(img_gauss)-double(img_filtered)+127);
figure();
imshow(img_subtracted);
% threshold
img_thresh = img_subtracted>130;
figure();
imshow(img_thresh);
% use open to remove some noise
figure();
img_opened = imopen(img_thresh,ones(3));
imshow(img_opened);