Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ONLY NEED TO EDIT distortion.py and interpolation.py # Please do not change the structure Do not import cv2, numpy and other third party libs Distortion:

ONLY NEED TO EDIT distortion.py and interpolation.py

# Please do not change the structure

Do not import cv2, numpy and other third party libs

Distortion: Write code to perform barrel distortion on an image.

Starter code available in directory Tranform/

Transform/distortion.py: Edit the function distortion to implement this part.

Correction Naive: Write code to perform correction on the input distorted image, by appying the inverse distortion function.

Starter code available in directory Tranform/

Transform/distortion.py: Edit the function correction_naive to implement this part.

(35 pts.) Correction with interpolation: Write code to perform correction on the input distorted image, and using nearest neighbor and bilinear interpolation.

Starter code available in directory Tranform/

Transform/distortion.py: Edit the function correction to implement this part.

Transform/interpolation.py: Write code for linear and bilinear interpolation in there respective function definitions, you are welcome to write new functions and call them from these functions

The assignment can be run using dip_hw1_rotate.py (there is no need to edit this file)

Usage: python dip_hw1_distortion.py -i image-name -k parameter_k -m method

image-name: name of the image

k: Parameter k (eg. 0.005)

method: "nearest_neightbor" or "bilinear"

Please make sure your code runs when you run the above command from prompt/Terminal

Any output images or files must be saved to "output/" folder

One images is provided for testing: kenny.jpg

Notes:

Files not to be changed: requirements.txt, dip.py, and Jenkinsfile

the code has to run using one of the following commands

Usage: ./dip_hw1_distortion.py -i image-name -t parameter_k -m methodExample: ./dip_hw1_distortion.py -i kenny.jpg -k 0.0005 -m bilinear

Usage: python dip_hw1_distortion.py -i image-name -t parameter_k -m methodExample: python dip_hw1_distortion.py -i kenny.jpg -k 0.0005 -m bilinear

Any output file or image should be written to output/ folder

The code has to run on jenkins CI/CD

Note: We are restricted from importing cv2, numpy, stats and other third party libraries, with the only exception of math, importing math library is allowed (import math).

While you can import it for testing purposes, the final submission should not contain the following statements.

import cv2

import numpy

import numpy as np

import stats

etc...

The essential functions for the assignment are available in dip module one can import using the following statement

import dip from dip import * 

The following functions are available

from cv2 import namedWindow, imshow, waitKey, imwrite, imread from numpy import zeros, ones, array, shape, arange from numpy import random from numpy import min, max from numpy import int, uint8, float, complex from numpy import inf from numpy.fft import fft 1. distortion.py from .interpolation import interpolation from dip import * import math class Distort: def __init__(self): pass def distortion(self, image, k): """Applies distortion to the image image: input image k: distortion Parameter return the distorted image""" return image def correction_naive(self, distorted_image, k): """Applies correction to a distorted image by applying the inverse of the distortion function image: the input image k: distortion parameter return the corrected image""" return distorted_image def correction(self, distorted_image, k, interpolation_type): """Applies correction to a distorted image and performs interpolation image: the input image k: distortion parameter interpolation_type: type of interpolation to use (nearest_neighbor, bilinear) return the corrected image""" return distorted_image 2. interpolation.py class interpolation: def linear_interpolation(self): """Computes the linear interpolation value at some iD location x between two 1D points (Pt1 and Pt2). There are no arguments defined in the function definition on purpose. It is left upto the student to define any requierd arguments. Please change the signature of the function and add the arguments based on your implementation. The function ideally takes two 1D points Pt1 and Pt2, and their intensitites I(Pt1), I(Pt2). return the interpolated intensity value (I(x)) at location x """ # Write your code for linear interpolation here return def bilinear_interpolation(self): """Computes the bilinear interpolation value at some 2D location x between four 2D points (Pt1, Pt2, Pt3, and Pt4). There are no arguments defined in the function definition on purpose. It is left upto the student to define any requierd arguments. Please change the signature of the function and add the arguments based on your implementation. The function ideally takes four 2D points Pt1, Pt2, Pt3, and Pt4, and their intensitites I(Pt1), I(Pt2), I(Pt3), and I(Pt4). return the interpolated intensity value (I(x)) at location x """ # Write your code for bilinear interpolation here # Recall that bilinear interpolation performs linear interpolation three times # Please reuse or call linear interpolation method three times by passing the appropriate parameters to compute this task return  ONLY NEED TO EDIT distortion.py and interpolation.py # Please do not change the structure  Do not import cv2, numpy and other third party libs

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions