Image Processing in Java – Creating a Mirror 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
In this set, we will be creating a mirror image. The image of an object as seen in a mirror is its mirror reflection or mirror image. In such an image, the object’s right side appears on the left side and vice versa. A mirror image is therefore said to be laterally inverted, and the phenomenon is called lateral inversion. The main trick is to get the source pixel values from left to right and set the same in the resulting image from right to left.
- Read the source image in a BufferedImage to read the given image.
- Get the dimensions of the given image.
- Create another BufferedImage object of the same dimension to hold the mirror image.
- Get ARGB (Alpha, Red, Green, and Blue) values from the source image [in left to right fashion].
- Set ARGB (Alpha, Red, Green, and Blue) to newly created image [in the right to left fashion].
- Repeat steps 4 and 5 for each pixel of the image.
Note: This code will not run on online ide since it requires an image in the drive.
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.