|
|
An image includes two dimensional array of pixels. It is known as the value of those pixels that creates an image. While,an image can be color or grayscale.
The BufferedImage class in java is used to manage the images. For this you need to get getRGB() method of the BufferedImage class to grab the value of the pixel.
Use following syntax to get the value of syntax with that:
The method getRGB() uses the row and column index as a key parameter and returns the exact pixel. To get the color image, it gives back three values which are (Red, Green, Blue). They can be get as follows:
The height and width of the image can done by using the getWidth() and getHeight() methods of the BufferedImage class. Its syntax is given below:
The other methods to that can be supported in the BufferedImage class are described briefly:
Sr.No. |
Methods |
1 |
copyData(WritableRaster outRaster) It computes an arbitrary rectangular region of the BufferedImage and copies it into a specified WritableRaster. |
2 |
getColorModel() It returns ColorModel of an image. |
3 |
getData() It returns the image as one large tile. |
4 |
getData(Rectangle rect) It computes and returns an arbitrary region of the BufferedImage. |
5 |
getGraphics() This method returns a Graphics2D, but is here for backwards compatibility. |
6 |
getHeight() It returns the height of the BufferedImage. |
7 |
getMinX() It returns the minimum x coordinate of this BufferedImage. |
8 |
getMinY() It returns the minimum y coordinate of this BufferedImage. |
9 |
getRGB(int x, int y) It returns an integer pixel in the default RGB color model (TYPE_INT_ARGB) and default sRGB colorspace. |
10 |
getType() It returns the image type. |
Let’s see the use of java BufferedImage class that explain the pixels of an image of size (10 x 10):
After executing the above code, it would print the pixels of the following image:
If you scroll down the ouput, the following pattern is seen:
|
|
Digital image processing Related Tutorials |
|
---|---|
Python Tutorial | MATLAB Tutorial |
wxPython Tutorial | Digital Signal Processing Tutorial |
Digital image processing Related Practice Tests |
|
---|---|
Python Practice Tests | MATLAB Practice Tests |
Machine design Practice Tests |
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.