Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python, The original Given code is Below: %matplotlib inline import matplotlib.pyplot as plt import imageio import scipy.ndimage as nd import numpy as np #

image text in transcribed

In Python, The original Given code is Below:

%matplotlib inline import matplotlib.pyplot as plt import imageio import scipy.ndimage as nd import numpy as np

# RPolar defined as follows def RPolar(data, pxy): ndx = np.indices(data.shape) v,h = data.shape a = ndx[1].astype(float) a = a / h * 2 * np.pi y = ndx[0] * np.cos(a) x = ndx[0] * np.sin(a) ndx[0] = x.astype(int) + pxy[0] ndx[1] = y.astype(int) + pxy[1] answ = nd.map_coordinates(data, ndx) return answ

# IRPolar defined as follows def IRPolar(rpdata, pxy): ndx = np.indices(rpdata.shape) ndx[0] -= pxy[0] ndx[1] -= pxy[1] v,h = rpdata.shape r = np.sqrt(ndx[0]**2 + ndx[1]**2) theta = np.arctan2(-ndx[0], -ndx[1] )/2p.pi*h ndx[0] = r.astype(int) ndx[1] = theta.astype(int) + h/2 answ = nd.map_coordinates(rpdata, ndx) answ[pxy[0],pxy[1]:] = answ[pxy[0]-1,pxy[1]:] return answ

# LogPolar defined as follows def LogPolar(data, pxy): ndx = np.indices(data.shape) v,h = data.shape a = ndx[1].astype(float) a = a / h * 2 * np.pi r = np.exp( ndx[0]/v * np.log(v/2))-1.0 y = r * np.cos(a) x = r * np.sin(a) ndx[0] = x.astype(int) + pxy[0] ndx[1] = y.astype(int) + pxy[1] answ = nd.map_coordinates(data, ndx) return answ

url = 'https://raw.githubusercontent.com/joefoxva1/CDS468/master/Lecture_6_7_8_9/clock.png' adata = imageio.imread(url,as_gray=True)

plt.title('Original Image') plt.imshow(adata, cmap='gray') plt.show()

# transforms around the same point RPimg = RPolar(adata, (100, 100)) plt.title('R Polar') plt.imshow(RPimg, cmap='gray') plt.show()

IRPimg = IRPolar(RPimg, (100, 100)) plt.title('Inverse R Polar') plt.imshow(IRPimg, cmap='gray') plt.show()

LPimg = LogPolar(adata, (100, 100)) plt.title('Log Polar') plt.imshow(LPimg, cmap='gray') plt.show()

Jsing the clock image and code for the rpolar, irpolar and log polar plots, shift the center of rotation to (200,200). Describe your interpretation f the results. Describe what happends if we shift the center of rotation to (400,400)

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions