Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Get bits per pixel of a BufferedImage

I'm currently working on comparing a filtered image to its original (unfiltered) image using the SSIM (Structural similarity) index using Java.

My research brought me to a mathematical formula where the average, variance, covariance and the dynamic range of the two BufferedImages are needed.

Getting to calculate the average and the variance was not a big problem for me, however I can't figure out a way to get the number of bits per pixel needed to calculate the dynamic range, and the covariance value, is this something I can obtain from the BufferedImage.

like image 692
Walkaa Avatar asked Feb 06 '23 06:02


1 Answers

BufferedImage has a getColorModel() method, and in the returned ColorModel object there is a getPixelSize() method which returns the number of bits per pixel described by that ColorModel.

like image 62
Mike Nakis Avatar answered Mar 13 '23 00:03

Mike Nakis