Small repository to store the "cropping" step of the BGNN project.
This repo is linked to main BGNN Core Workflow that encompasses a complete analysis workflow. It contained the code for the "Cropping" part see here. It is easier to understand the purpose this code and its application if you are familar with BGNN_Snakemake repo.
- We use raw fish image available at Fish-AIR and Metadata json file generated by Drexel_metadata and reformatted by Drexel_metadata_formatter to crop the fish out of a more complexe image.
Input example :
- fish image .jpg see INHS_FISH_000742.jpg
- Metadata.json see INHS_FISH_000742.json
Ouput :
- Cropped image .jpg [see INHS_FISH_000742_cropped.jpg]Test_data/INHS_FISH_000742_cropped.jpg)
Usage in python you need the environment define by crop_env.yml. I suggest to use anaconda or miniconda as environment manager
Crop_image_main.py [-h] [--increase] input_image imput_metadata output
Example using the Test_data with 10% increase in size
Crop_image_main.py INHS_FISH_000742.jpg INHS_FISH_000742.json INHS_FISH_000742_cropped.jpg --increase 0.10
The --increase
parameter defines the fractional increase of the bounding box from the original metadata size in each direction (10% in this example). The default value in 0.05.
The container can be download here:
docker pull ghcr.io/hdr-bgnn/crop_image:latest
#or
singualarity docker://ghcr.io/hdr-bgnn/crop_image:latest
Container Usage:
In this section the name of the container "crop_image_0.0.2.sif" will depend on the version you are downloading or the name you give to container .sif
The usage can be display like this:
singularity run crop_image_0.0.2.sif
To execute the code on the test images test data, run the following
singularity exec crop_image_0.0.2.sif Crop_image_main.py Test_data/INHS_FISH_000742.jpg Test_data/INHS_FISH_000742.json Test_data/INHS_FISH_000742_cropped_test.jpg