Code to compute the absolute error between the colors of the original image’s pixels and the colors of the image after it’s been rotated 360⁰

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I dont know how to do this. I am not sure how to calculate any errors with my given code.

question: Absolute color error calculation: Code to compute the absolute error between the colors of the original image’s pixels and the colors of the image after it’s been rotated 360⁰

import cv2
import numpy as np
from PIL import Image
import math
image = np.array(Image.open("Cones1. png"))
for x in range (3):
ang=int (input("Enter the angle of rotation : "))
angle=math.radians (ang)
cosine=math.cos(angle)
sine=math.sin(angle)
height=image.shape[0]
width=imagel. shape[1]
height1
width1
= round (abs (image.shape[0]*cosine)+abs (image.shape[1]*sine))+1
= round (abs (image.shape[1]*cosine)+abs (image.shape[0]*sine))+1
output=np.zeros ( (height1, width1, image.shape[2]))
originalHeight = round ( ((image.shape[0]+1)/2)-1)
originalwidth = round( ( (image.shape[1]+1)/2)-1)
newHeight= round ( ( (height1+1)/2)-1)
newwidth= round (( (width1+1)/2)-1)
for i in range (height):
for j in range (width):
y=image.shape[0]-1-i-originalHeight
x=image.shape[1]-1-j-originalwidth
newY=round(-x*sine+y*cosine)
newX=round (x*cosine+y*sine)
newY=newHeight-newY
newX=newWidth-newX
if 0 <= newX <width1 and 0 <= newY < height1 and newX>=0 and newY>=0:
output[newY, newX, :]=image[i,j,:1
cv2.imshow("Rotating "+str(ang)+' degrees',output/255.0)
cv2.waitKey(0)
cv2.destroyAllWindows ( )
Transcribed Image Text:import cv2 import numpy as np from PIL import Image import math image = np.array(Image.open("Cones1. png")) for x in range (3): ang=int (input("Enter the angle of rotation : ")) angle=math.radians (ang) cosine=math.cos(angle) sine=math.sin(angle) height=image.shape[0] width=imagel. shape[1] height1 width1 = round (abs (image.shape[0]*cosine)+abs (image.shape[1]*sine))+1 = round (abs (image.shape[1]*cosine)+abs (image.shape[0]*sine))+1 output=np.zeros ( (height1, width1, image.shape[2])) originalHeight = round ( ((image.shape[0]+1)/2)-1) originalwidth = round( ( (image.shape[1]+1)/2)-1) newHeight= round ( ( (height1+1)/2)-1) newwidth= round (( (width1+1)/2)-1) for i in range (height): for j in range (width): y=image.shape[0]-1-i-originalHeight x=image.shape[1]-1-j-originalwidth newY=round(-x*sine+y*cosine) newX=round (x*cosine+y*sine) newY=newHeight-newY newX=newWidth-newX if 0 <= newX <width1 and 0 <= newY < height1 and newX>=0 and newY>=0: output[newY, newX, :]=image[i,j,:1 cv2.imshow("Rotating "+str(ang)+' degrees',output/255.0) cv2.waitKey(0) cv2.destroyAllWindows ( )
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education