I'm trying to detect dirty floor areas in a series of images, using MATLAB and its Image Processing Toolbox, like the one that follows:

Clean/Dirty Floor Sample

In the image above, there are two distinct areas, the whiter floor, which is considered clean, and the dirty floor, which is the area beyond the yellow warning sign. I'm looking for ways to detect these differences.

A relevant problem is that lighting intensity and colour may not be constant along the paths.

I've already tried 2D cross-correlation between a smaller sample image (taken from the image below), but it was not very effective.

Clean Floor Sample

My method was something like:

  1. Mask out irrelevant features in input image (corridors other than the white ones, for example);

  2. RGB to Grayscale conversion of input image (analysis target) and full sample image;

  3. Extract a portion of the sample image and extract its histogram;

  4. Use histogram equalization on input image, using the sample's histogram (histeq);

  5. Run normxcorr2 between input and sample images;

  6. Plot all points below an arbitrary constant (xCorr < 0.8, for example) over input image to detect "dirty" areas.

Maybe deep learning for image segmentation would be the most effective method, but I currently don't have the time to implement it.

Any other suggestions that would be any more effective on this situation?

  • $\begingroup$ I can post the results on the cross-correlation test, other attempts I've made or the code itself, if they're any relevant for the question. Thanks! $\endgroup$
    – R_Est
    Apr 23, 2018 at 16:35
  • 3
    $\begingroup$ If you want to apply some modern tech to this problem, you could consider trying to use a convolution neural network with a training set of clean and dirty floor (sub)images to identify where portions of an image may be dirty. If you want something simpler, you could consider making a separate image by say coloring portions that are dirty in the original image with red pixels and portions that are clean with blue pixels. You could then feed the original image and marked image into some classification algo, like using Gaussian discriminants, and see how it does. $\endgroup$
    – spektr
    Apr 24, 2018 at 0:39
  • $\begingroup$ How many labeled example pictures do you have? Are they in a public place we can contemplate them? $\endgroup$
    – Richard
    Nov 1, 2021 at 19:42

1 Answer 1


Here are some suggestions:

  1. Whatever method you try, look at a large number of dirty floor samples to get an idea of the range of things - is it a darker area, is it streaks, etc.

  2. For a simple idea, you might want to try an 2-dim FFT or DCT of a patch of the floor. The 0,0 element will give you the DC value (the average intensity), which you could ignore if you are looking for streaks. Then the other elements, moving outward from 0,0 will give you the amplitude of the components of the image at frequencies getting higher as you move away from element 0,0. By looking at the results across various clean and dirty sections, you might be able to come with a frequency range and threshold limits.


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.