Image Processing in Java | Set 11 (Changing orientation of image)
In this article we will use opencv to change orientation of any input image, by using the CORE.flip() method of 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 input image.
- put(int row, int column, byte data) / 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 corresponds to input and output mat objects and the flip_value decides the orientation type.flip_value can be either 0 (flipping along x-axis), 1 (flipping along y-axis), -1 (flipping along both the axis).
This article is contributed by Pratik Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.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.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.