'''
===============================================================================
-- Author:      <NAME>, <NAME>
-- Create date: 05/11/2020
-- Description:	This code is for translating, rotating and resizing of images.
-- Status:      In progress
================================================================================
'''

import numpy as np


import cv2
import os
import sys


def translate(image, x, y):
    M = np.float32([[1, 0, x], [0, 1, y]])
    shifted = cv2.warpAffine(image, M, (image.shape[1], image.shape[0]))

    return shifted


def rotate(image, angle, center=None, scale=1.0):
    (h, w) = image.shape[:2]

    if center is None:
        center = (w / 2, h / 2)

    M = cv2.getRotationMatrix2D(center, angle, scale)
    rotated = cv2.warpAffine(image, M, (w, h))

    return rotated


def resize(image, width=None, height=None, inter=cv2.INTER_AREA):

    dim = None
    (h, w) = image.shape[:2]

    if width is None and height is None:
        return image

    if width is None:

        r = height / float(h)
        dim = (int(w * r), height)

    else:

        r = width / float(w)
        dim = (width, int(h * r))

    resized = cv2.resize(image, dim, interpolation=inter)

    return resized


image = cv2.imread(sys.argv[1])
translate = translate(image, 100, 100)

cv2.imwrite('trans.jpg', translate)

'''
===============================================================================
-- Author:      <NAME>, <NAME>
-- Create date: 05/11/2020
-- Description:	This code is for translating, rotating and resizing of images.
-- Status:      In progress
================================================================================
'''

import numpy as np


import cv2
import os
import sys


def translate(image, x, y):
    M = np.float32([[1, 0, x], [0, 1, y]])
    shifted = cv2.warpAffine(image, M, (image.shape[1], image.shape[0]))

    return shifted


def rotate(image, angle, center=None, scale=1.0):
    (h, w) = image.shape[:2]

    if center is None:
        center = (w / 2, h / 2)

    M = cv2.getRotationMatrix2D(center, angle, scale)
    rotated = cv2.warpAffine(image, M, (w, h))

    return rotated


def resize(image, width=None, height=None, inter=cv2.INTER_AREA):

    dim = None
    (h, w) = image.shape[:2]

    if width is None and height is None:
        return image

    if width is None:

        r = height / float(h)
        dim = (int(w * r), height)

    else:

        r = width / float(w)
        dim = (width, int(h * r))

    resized = cv2.resize(image, dim, interpolation=inter)

    return resized


image = cv2.imread(sys.argv[1])
translate = translate(image, 100, 100)

cv2.imwrite('trans.jpg', translate)

===============================================================================
 -- Author:      <NAME>, <NAME>
 -- Create date: 05/11/2020
 -- Description:	This code is for translating, rotating and resizing of images.
 -- Status:      In progress
 ================================================================================