• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
October 27, 2022 |640 Views

C Program to turn an image by 90 degree

  Share   Like
Description
Discussion

In this video, we will write a C Program to turn an image by 90 degrees. Rotation of an Image is one of the image transfigures operations that can be applied to an image. By using Image rotation, the image is rotated about its center by a specified number of degrees. 

Rotation is a geometric conversion. This can be done by using either forward mapping or inverse mapping.

For Example:

Input image:
1  2  3  0
5  6  7  8
9 10 11 12

Output Image

9     5    1
10   6    2
11   7    3
12   8    0

Then we see 2 different approaches for turning the image 90 degrees:

1. Using another array: In this approach, we've another array to store the rotated image of an array. Then we use nested for loop to store the 2D array.

2. Using the Inplace methodology: In this approach, rather than creating another array, we will exchange the elements in the original array image itself. So we switch the top element to right, the right element to the bottom, the bottom element to left, and the left element to the top to have 90 degrees rotated image of an array.

Here, 

  • Time Complexity O( N * M)
  • Auxiliary Space O( N * M)

C Program to turn an image by 90 degrees : https://www.geeksforgeeks.org/c-program-for-turn-an-image-by-90-degree/