Image Processing in Java – Changing Orientation of Image
- Image Processing in Java – Read and Write
- Image Processing In Java – Get and Set Pixels
- Image Processing in Java – Colored Image to Grayscale Image Conversion
- Image Processing in Java – Colored Image to Negative Image Conversion
- Image Processing in Java – Colored to Red Green Blue Image Conversion
- Image Processing in Java – Colored Image to Sepia Image Conversion
- Image Processing in Java – Creating a Random Pixel Image
- Image Processing in Java – Creating a Mirror Image
- Image Processing in Java – Face Detection
- Image Processing in Java – Watermarking an Image
Changing the Orientation of Image
Here we will use OpenCV to change the orientation of any input image, by using the CORE.flip() method of the OpenCV library. The main idea is that an input buffered image object will be converted to a mat object and then a new mat object will be created in which the original mat object values are put after orientation modification. For achieving the above result, we will be requiring some of the OpenCV methods:
- getRaster() – The method returns a writable raster which in turn is used to get the raw data from the input image.
- put(int row, int column, byte data) or get(int row, int column, byte data): Used to read/write the raw data into a mat object.
- flip(mat mat1, mat mat2, int flip_value): mat1 and mat2 correspond to input and output mat objects and the flip_value decides the orientation type.flip_value can be either 0 (flipping along the x-axis), 1 (flipping along the y-axis), -1 (flipping along both the axis).
Implementation: Let the sample image be as follows:
Note: Do not scale for resolution as the output image is appended bigger to perceive better, it will be generated on IDE of same size as that of resolution and size passed of the input image.
This article is contributed by Pratik Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Please Login to comment...