DanielHry / imageTransform

Transform your images & labels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

image 3D rotation

Image

Use image_rotation.py to rotate your image!

Before After

Example:

image_rotation.py ${IMPUT_IMAGE} ${OUTPUT_PATH} [--theta] [--phi] [--gamma]
  • theta : rotation around the x axis

  • phi : rotation around the y axis

  • gamma : rotation around the z axis

python image_rotation.py demo/image_demo.jpg demo/img_rotate.jpg --theta 26 --phi 43 --gamma -66

Mask

You can specify [--mask] to export the mask:

Labels

Transform your labels

Before After

Example:

python image_rotation.py \
    ${IMPUT_IMAGE} \
    ${OUTPUT_PATH} \
    [--theta ${THETA}] \
    [--phi ${PHI}] \
    [--gamma ${GAMMA}] \
    [--labels ${TXT_FILE}] \
    [--labels-out ${OUTPTU_TXT_PATH}]
python image_rotation.py demo/image_demo.jpg demo/img_rotate.jpg --theta 26 --phi 43 --gamma -66 --mask demo/img_mask.jpg --labels demo/image_demo_labels.txt --labels-out demo/img_rotate_labels.txt

Other Image transformations

image foreground mask image background

Example:

from transformers import (rotate_layer, blend_layers, scale_layer, 
                          resize_poly, rotate_poly, translate_poly)
                          
scale = 0.8
image_fg = scale_layer(image_fg, scale)
image_fg_mask = scale_layer(image_fg_mask, scale)
poly = data["polygon"]
poly = resize_poly(poly, scale)


dicRotation = {'theta':-5, 'phi':-40, 'gamma':-10}
images_rotated = rotate_layer([image_fg, image_fg_mask], dicRotation)
image_fg, image_fg_mask = images_rotated
poly = rotate_poly(poly)


result = blend_layers(image_fg, image_bg, image_fg_mask, position=(275,70), opacity=0.85)
poly = translate_poly(poly, y=70, x=275)

Result:

image polygones

About

Transform your images & labels


Languages

Language:Python 100.0%