Java – get the most common image colors

I want to get the most common colors from the image I use Java and I want to have the main color Is there any CBIR Java library to do this?

thank you

Solution

Do you want this to be accurate? You can use bozhos's method and loop through the entire image, but for large images, this may be slow There are 16777216 possible RGB values and their retention counters in the map are not very efficient

Another way is to resample the image using getscaleinstance to reduce it to a smaller version, such as a 1 × 1 image, and then use getrgb to obtain the color of the pixel You can try different resampling algorithms, such as scale_ Replicate and scale_ AREA_ Averaging, see what's best for you

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>