1 year ago

#341978

test-img

Lorenzo Epifani

Geometric transformation: reproducing the Gimp warp tool in python

I would like to reproduce the Gimp warp tool in python, specifically the "Grow" transformation.

For example, having the input image:

enter image description here

I would like to obtain:

enter image description here

This is a template for the code that I want to write:

import cv2
import numpy as np
import math
from operator import itemgetter

def growth_area(in_img, parameters):
    #in_img comes from cv2.imread('./test_image.png', cv2.IMREAD_GRAYSCALE)
    size, strength, hardness, position = itemgetter('size', 'strength', 'hardness', 'position')(parameters) 
    img_out = np.zeros(in_img.shape, dtype=in_img.dtype)
    rows, cols = in_img.shape
    # Here I want to implement the code 
    # to get the transformation shown in 
    # the pictures, and show the result in img_out
    cv2.imshow('warp', img_out)
    cv2.waitKey()

I would like to control the execution of the growth_area() with the 4 parameters 'size', 'strength', 'hardness', 'position', where the first 3 parameters behave as the 3 parameters in Gimp, and the last one 'position' represent the center of the transformation. How can I implement this?

python

opencv

image-processing

gimp

0 Answers

Your Answer

Accepted video resources