Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

ImageColorAverager



The ImageColorAverager class allows to compute the average color of an area around one pixel in an image.

Configuration

The constructor allows to specify the spread around the pixel, which will define the area which will be used to average the color.
coloraverager
If the spread if less than 2, then the averager will only return the color of the pixel itself.

Usage

The ImageColorAverager.averageColor(int, int) computes the average color in an area defined by the spread around the specified pixel:
  • If the pixel is outside the limits of the image, it will return null
  • Else the class will compute the average color using the pixels in the area defined by the spread

Behavior when the spread area is partly outside the image

If the spread area is partly outside the image, only the pixels in the image will be used. For example:
coloraverager2

Example

   BufferedImage bi = ImageIO.read(<my image file>);
   ImageColorAverager averager = new ImageColorAverager(bi, 10);
   int x = <x position of the pixel>
   int y = <y position of the pixel>
   Color color = averager.averageColor(x, y);      

See also


Categories: Awt.image | Packages

Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences