Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing the pixels of an image [closed]

Tags:

java

swing

Could someone show me here how to access all the pixels of an image in order to be able to build a histogram of that image ?

like image 492
klaus johan Avatar asked Dec 11 '25 01:12

klaus johan


1 Answers

You can use

java.awt.image.BufferedImage image = ImageIO.read( "image.gif" );
int[] samples = image.getData().getPixel( x, y, null );

// or the pixel converted to the default RGB color model:
int rgb = image.getRGB( x, y )

I think the samples you get from there are the RGB values, but you have to check that...

like image 117
tangens Avatar answered Dec 13 '25 14:12

tangens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!