All Projects → yu4u → imgcrop

yu4u / imgcrop

Licence: MIT license
Simple image augmentation library focusing on random geometric cropping

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to imgcrop

Edafa
Test Time Augmentation (TTA) wrapper for computer vision tasks: segmentation, classification, super-resolution, ... etc.
Stars: ✭ 107 (+296.3%)
Mutual labels:  segmentation, augmentation
Caer
High-performance Vision library in Python. Scale your research, not boilerplate.
Stars: ✭ 452 (+1574.07%)
Mutual labels:  segmentation, augmentation
Instaboost
Code for ICCV2019 paper "InstaBoost: Boosting Instance Segmentation Via Probability Map Guided Copy-Pasting"
Stars: ✭ 368 (+1262.96%)
Mutual labels:  segmentation, augmentation
Torchio
Medical image preprocessing and augmentation toolkit for deep learning
Stars: ✭ 708 (+2522.22%)
Mutual labels:  segmentation, augmentation
Pytorch Toolbelt
PyTorch extensions for fast R&D prototyping and Kaggle farming
Stars: ✭ 942 (+3388.89%)
Mutual labels:  segmentation, augmentation
Segmentation
Catalyst.Segmentation
Stars: ✭ 27 (+0%)
Mutual labels:  segmentation, augmentation
Ttach
Image Test Time Augmentation with PyTorch!
Stars: ✭ 455 (+1585.19%)
Mutual labels:  segmentation, augmentation
Albumentations
Fast image augmentation library and an easy-to-use wrapper around other libraries. Documentation: https://albumentations.ai/docs/ Paper about the library: https://www.mdpi.com/2078-2489/11/2/125
Stars: ✭ 9,353 (+34540.74%)
Mutual labels:  segmentation, augmentation
CAP augmentation
Cut and paste augmentation for object detection and instance segmentation
Stars: ✭ 93 (+244.44%)
Mutual labels:  segmentation, augmentation
image segmentation dl
🍞 基于深度学习方法的图像分割(含语义分割、实例分割、全景分割)。
Stars: ✭ 76 (+181.48%)
Mutual labels:  segmentation
hyperseg
HyperSeg - Official PyTorch Implementation
Stars: ✭ 174 (+544.44%)
Mutual labels:  segmentation
Active-Contour-Model-Matlab
Some matlab code of Active Contour Model for image segmentation
Stars: ✭ 44 (+62.96%)
Mutual labels:  segmentation
PragmaticSegmenterNet
Port of PragmaticSegmenter for sentence boundary detection
Stars: ✭ 25 (-7.41%)
Mutual labels:  segmentation
rembg-greenscreen
Rembg Video Virtual Green Screen Edition
Stars: ✭ 210 (+677.78%)
Mutual labels:  segmentation
keras-semantic-segmentation-example
Example of semantic segmentation in Keras
Stars: ✭ 53 (+96.3%)
Mutual labels:  segmentation
ETCI-2021-Competition-on-Flood-Detection
Experiments on Flood Segmentation on Sentinel-1 SAR Imagery with Cyclical Pseudo Labeling and Noisy Student Training
Stars: ✭ 102 (+277.78%)
Mutual labels:  segmentation
axondeepseg
Axon/Myelin segmentation using Deep Learning
Stars: ✭ 102 (+277.78%)
Mutual labels:  segmentation
navis
Python 3 library for analysis of neuroanatomical data
Stars: ✭ 68 (+151.85%)
Mutual labels:  segmentation
Awesome-Vision-Transformer-Collection
Variants of Vision Transformer and its downstream tasks
Stars: ✭ 124 (+359.26%)
Mutual labels:  segmentation
SemanticSegmentation-Libtorch
Libtorch Examples
Stars: ✭ 38 (+40.74%)
Mutual labels:  segmentation

imgcrop

Simple image augmentation library focusing on random geometric cropping. Different from pipeline-based augmentation libraries, this library efficiently performs cropping and geometric transformations at once. As image processing functions such as adding Gaussian noise, blurring, and contrast adjustment are not provided, please use the other great libraries like imgaug [1], Augmentor [2], and albumentations [3] to further transform images cropped by this library.

Features

  • Simple API, easy to use
  • Efficient; cropping and all geometric transformations are performed at once (by a single perspective transformation)
  • Multiple images and points can simultaneously be transformed with the same transformation
  • Guarantee that all pixels in cropped image are taken from inside the original image (if margin is not used)

Installation

pip install imgcrop

APIs

imgcrop.get_cropper

get_cropper(patch_size=128, scale=(1.0, 1.0), rotate=(0, 0), distort=0.0, flip=0.0, margin=0)

parameters

  • patch_size: int, default 128
    • output patch size (in pixel)
  • scale: tuple of float, default (1.0, 1.0)
    • sampling scale range
  • rotate: tuple of int, default (0, 0)
    • sampling rotation range (in degree)
  • distort: float, default 0.0
    • distortion strength in perspective transformation (ratio to output image scale)
  • flip: float, default 0.0
    • horizontal flip probability
  • margin: int, default 0
    • margin in cropping around original image

returns

  • random_crop: function

random_crop

random_crop(img, points=None) -> cropped_img[, output_points], src_points, m

parameters

  • img: numpy array (single image) or list of numpy arrays (multiple images)
    • input image(s) to be cropped with the same geometric transformation
  • points: numpy array with the shape (point_num, 2), default None
    • input points to be transformed with the same transformation matrix as input image(s)

returns

  • cropped_img: numpy array or list of numpy arrays)
    • cropped output image(s)
  • output_points: numpy array with the shape (point_num, 2)
    • output points if input points are given
  • src_points: numpy array
    • points defining the cropped region in the input image(s)
  • m: numpy array
    • 3x3 perspective transformation matrix from the input image(s) to the output image(s)

Example

Pleaes run or refer to the example script to see how this library works:

python example/example.py

You can easily try different parameters by arguments:

optional arguments:
  -h, --help            show this help message and exit
  --patch_size PATCH_SIZE
                        output patch image size (default: 256)
  --scale SCALE SCALE   scale range in sampling (default: [0.8, 1.2])
  --rotate ROTATE ROTATE
                        rotation range in sampling (default: [-60, 60])
  --distort DISTORT     distortion strength for perspective transformation
                        (default: 0.2)
  --flip FLIP           horizontal flip probability (default: 0.5)
  --margin MARGIN       margin around original image (default: 0)
parameters cropping results (input, cropped, mask, keypoints)
scaling
rotation + scaling
distortion + scaling
flip + rotation
margin + scaling
all

Algorithm

Patch region in the original image is defined by a set of four points. These points are randomly transformed according to transformation parameters. The transformation matrix from input image to output image is then calculated using these points. Finally, cropping is performed by applying perspective transformation.

References

  1. imgaug, https://github.com/aleju/imgaug
  2. Augmentor, https://github.com/mdbloice/Augmentor
  3. albumentations, https://github.com/albu/albumentations
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].