We strongly recommend to refer below post as a prerequisite of this.
Image Processing in Java | Set 1 (Read and Write)
In this set, we will learn about pixels of image. How we can get pixel values of image and how to set pixel values in an image using Java programming language.
Pixels are the smallest unit of an image which consists of four components Alpha (transparency measure), Red, Green, Blue and in short (ARGB).
The value of all the components lie between 0 and 255 both inclusive. Zero means the component is absent and 255 means the component is fully present.
Since, 28 = 256 and the value of the pixel components lie between 0 and 255, so we need only 8-bits to store the values.
SO, total number of bits required to store the ARGB values is 8*4=32 bits or 4 bytes.
As the order signifies Alpha acquires leftmost 8 bits, Blue acquires rightmost 8 bits.
Thus the bit position :
For blue component being 7-0,
For green component being 15-8,
For red component being 23-16,
For alpha component being 31-24,
Note : This code will not run on online IDE as it needs an image on disk.
In the next set we will be learning how to convert a colored image to grayscale image in JAVA.
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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Image Processing in Java | Set 6 (Colored image to Sepia image conversion)
- Image Processing in Java | Set 4 (Colored image to Negative image conversion)
- Image Processing in Java | Set 3 (Colored image to greyscale image conversion)
- Image Processing in Java | Set 5 (Colored to Red Green Blue Image Conversion)
- Image Processing in Java | Set 7 (Creating a random pixel image)
- Image Processing in Java | Set 8 (Creating mirror image)
- Image Processing in Java | Set 11 (Changing orientation of image)
- Image Processing in Java | Set 10 ( Watermarking an image )
- Image Processing in Java | Set 12 ( Contrast Enhancement )
- Image Processing in Java | Set 14 ( Comparison of two images )
- Image Processing in Java | Set 1 (Read and Write)
- Image Processing in Java | Set 9 ( Face Detection )
- Image Processing using OpenCV in Java | Set 14 ( Sharpness Enhancement )
- Image Processing using OpenCV in Java | Set 13 (Brightness Enhancement)
- Image Edge Detection Operators in Digital Image Processing
- Getting started with Scikit-image: image processing in Python
- Components of Image Processing System
- Histogram Equalisation in C | Image Processing
- Digital Image Processing Basics
- Image Processing without OpenCV | Python