Skip to content

AlbertoLanaro/ImagePatchExtractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Patch Extractor with Masks

Simple python script that extract a given number of overlapping patches from a set of images and their corresponding masks (optionally). The script can be run with several input parameters:

  • --input_imgs_path: path to images folder [str - required]
  • --input_masks_path: path to masks folder [str - optional]
  • --n_patches: number of extracted patches per image. If None, the maximum number of patches is extracted [int - optional].
  • --patch_size: patch dimensions, i.e. (patch_size, patch_size) [int - required]

Dependencies

All the dependencies are detailed in the requirements.txt file and can be installed with pip and the following command: pip3 install -r requirements.txt

Example

The script can be launched as follows:

python3 patch_extractor.py -i samples/ -s 50

Here are two examples of patches extracted from a set if images and their correnspondent masks: