Minimal bounding box extraction and alignment. This project is implmentation of recruitment task for Konica - Research Position.
Main purpose of this project is implementation of an algorithm for minimal bounding box extraction from segmentation map. Additionaly each of extracted bounding boxes is alligned to the xy axis with the longer dimnesion being aligned to the y axis. This project can be used directly with the existing example or as a pip package library.
docker-compose build
docker-compose run app -i assignment/RS_homework_BB.png -o output -t 4 -a True -cThe same can be achieved using Makefile
make build
COMMAND="-i assignment/RS_homework_BB.png -o output -t 4 -a True -c" make rundocker build . -t image-extraction --target build
docker run -v ${PWD}:/app -w /app -it image-extraction -i input/test.png -o output -t 4 -a True -cpip install -r requirements.txt
python main.py -i input/test.png -o outputs -t 128 -o output -t 4 -a True -c -v
-i,--inputTEXT Input file for bbox extraction.-o,--outputTEXT Directory to store extracted bbox images. (defaultoutput/{input_filename})-t,--thresholdINTEGER Image intensity threshold used to extract contours. (0-255, default4)-a,--alignBOOLEAN Align the bbox dominant dimension with the Y axis. (defaultTrue)-c,--centerBOOLEAN Center bbox around the contour. (defaultFalse)-f,--min_factorINTEGER Bounding box dimension will be divisible by specified value. (default1)-v,--visualInput image and bounding box visualization usingopencv.imshow.
Visualization requires installation of dev_requirements and in case of docker enabled X11 forwarding.
pip install git+https://github.com/mroncka/image-extraction.gitgit clone [email protected]:mroncka/image-extraction.git && cd image-extraction && pip install -e .import cv2
from image_extraction.bbox import get_bounding_boxes
image = cv2.imread(input, cv2.IMREAD_GRAYSCALE)
bboxes = get_bounding_boxes(image)
for i, bbox in enumerate(bboxes):
crop = bbox.crop_axis_aligned(image)docker-compose build
docker-compose run testThe same can be achieved using Makefile
make build
make testpip install -r test_requirements.txt
pytest testsRunning examples require installation of dev_requirements and in case of docker enabled X11 forwarding.
python example.py min
python example.py visual
python example.py rotationclick==8.1.3
opencv-python-headless==4.6.0.66






