Skip to content

Latest commit

 

History

History
78 lines (51 loc) · 2.02 KB

README.md

File metadata and controls

78 lines (51 loc) · 2.02 KB

Super duper special flake detector

Uses OpenCV to filter an image by colour, then finds contours and selects only blobs of at least some specific size. It can process both JPG and PNG formats and creates a new file with the same filename + "_processed.png" appended to it. It can either process a single file or all files in a directory (ignoring those generated by this script, so you can re-run it to regenerate the processed images).

Requirements:

  • Python 3.7
  • OpenCV 3.4
  • numpy 1.15

Other versions may work as well, but I know these work. Python 3.6 didn't work.

Usage

To process a single image:

python detect_flakes.py -i path/to/image.jpg
python detect_flakes.py --image path/to/image.jpg

To process all *.jpg and *.png files in a directory:

python detect_flakes.py -d path/to/images
python detect_flakes.py --dir path/to/images

To print help:

python detect_flakes.py -h

Editing the source

Based on the quality and/or the capture of the input images, you may need to change some variables in the source.

The first is the zoomToAreaMapping dictionary, which maps a zoom level (as a string), to the size of the expected flake. The higher the magnification, the larger the flake, of course. Smaller values might include more false positives, higher values may omit some smaller flakes.

The second dictionary, zoomToColourMapping, maps zoom level to flake colours. There are always two colours, the lower and upper limits. The values are Blue-Green-Red values (reversed RGB). These may vary as visible from the difference between flake and flake2 samples.

You can add more zoom levels and relevant values to both dictionaries if you're going to be using different magnification levels.

Other than that, there are some OpenCV-related constants, but those shouldn't be necessary to change.

Bugs

Create an issue on github if you want to report something or e-mail me directly: user bremby at the seznam.cz domain.