The project was implemented during 24h hackaton competition in Brno organised by UnIT Brno on 6-7.4.2018.
Implement an application which is able to load and analyze a picture containing grains in TIFF format. The application is supposed to find all grains and calculate their properties which will be exported in CSV format.
Requirements:
-
CLI parameters:
- Path to a file to be analyzed (--image-path)
- Path to a CSV file for exporting the calculations (--csv-path)
-
Each line of the CSV file contains informations about one grain.
-
Information about grains to be collected:
- Width = it's a width of a bounded box in pixels
- Height = it's a height of a bounded box in pixels
- Max Length = flowline of the most distance between two points on the grain, the flowline can go through outside of the grain - in case of a irregular shape of the grain
- Thickness = perpendicular flowline on the Max Length distance, the flowline mustn't go outside of the grain
-
Usage of opensource libraries for image recognition, filtration is not allowed. They can be used only for loading an image.
-
The grains which are located at the borders of the image - only a part of the grain is shown and the rest is outside of the image - can't be processed
-
The grains which are overlapping are processed as one grain.
- Python 3.6 or higher (but it may work even with older versions of Python 3)
- pip3
- Install requirements which are listed in the requirements.txt
$ ./tools/install_venv.sh
- The script creates a .venv where all requirements are installed, source it:
$ source .venv/bin/activate
$ ./main.py [-h] --image-path IMAGE_PATH --csv-path CSV_PATH [--resize RESIZE]
- -h, --help => show this help message and exit
- --image-path IMAGE_PATH => Path to an image to be processed
- --csv-path CSV_PATH => Path where csv file will be stored
- --resize RESIZE => Percentage to scale picture down
- An image in .TIFF format is loaded
- (optional) If
--resize
argument is present, the loaded image is resized - Blur filter is applied
- Threshold is calculated by OTSU algorithm
- Thresholding - the threshold is applied on the image
- Each grain is wrapped inside a bounded box
- Border points are discovered
- Lengths and thickness are calculated