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.


  • $\begingroup$ can you please let me know how to calculate the length of fibers also of this image $\endgroup$ Apr 22, 2019 at 7:41

1 Answer 1


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


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

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.