Identify Scratches in a Material

Hello everybody,
This is not a biology problem but I am hoping I can find some help identify scratches in a material. I have an acceptable routine in ImageJ. What this does is …

  1. Run a median filter on the original image
  2. Subtract the original image from the new ‘medianimage’
  3. Applies a threshold
  4. Runs ImageJ’s analyze particles function

This works fairly well however I seem to have to change the thresholding to account for different types of images(Brightness, Focus, weird defects, etc). I would also like to be able to distinguish shape types so I only find long and skinny objects(maybe worms?). Lastly, I would like to incorporate this more into Cell Profiler rather than doing almost everything in ImageJ.

Does anyone have any ideas of how to accomplish these goals in Cell Profiler?
Thanks for any help,

-I have uploaded a short pipeling and an image for anyone to play around with

ScratchesPipe.cp (3.69 KB)


I would suggest replacing the RunImageJ module with the following modules:

  • ImageMath with “Invert” as the operation to invert the pixel intensities (i.e, light becomes dark and vice versa).
  • EnhanceOrsupressFeatures with “Speckles” as the feature type and the feature size as the approximate width of the scratches you want to detect.

The step in EnhanceOrSupress performs top-hat filtering which effectively removes the background based on the feature you want to retain. In effect it performs much the same function as your median filtering.

An optional step is to include another EnhanceOrSupress module with “Neurites” as the features on the inverted image. Neurites are long, skinny processes and this modules attempts to enhance them.

Alternately, if you want to retain the workflow from ImageJ, the Smooth module performs median smoothing, use ImageMath to subtract the result, and ApplyThreshold does what the name implies.


Thank you very much for the reply!
Enhancing the speckles seems to do the opposite function that I want as it enhances the porosity of the materials. A lot of my images are much more porous and I am looking for the scratches. This Neurite function however, this can definitely help and then I can use the IdentifyPrimaryObjects module to then count the scratches. I need to somehow quantify the scratches and this outputs areas and counts that I can work with.

Thanks again and let me know if you have any more tips,