Color reduction (in Java)

∥☆過路亽.° 提交于 2019-12-24 12:08:43

问题


I would like to find a way to take JPEG (or GIF/PNG) images and reduce the amount of colors to e.g. 20. Could someone recommend some library or other reference? Also source codes in other languages are welcome.


回答1:


Take a look at the Java Advanced Imaging API. There are a number of algorithms implemented in that API for doing color reduction.




回答2:


JAI (Java Advanced Imaging API) would do the work but it has some drawbacks.

The API is far from being easy to use, especially if you care about memory footprint...

IMHO Java is not the best platform for imaging tasks. You might try ImageMagick, a wonderful command line tool, used by popular sites such as Flickr. You can integrate ImageMagick in your java application using the command line (Runtime.exec()) or Jmagick which a java bridge to ImageMagick




回答3:


This seems like a simple implementation in java, based on ImageMagick:

http://gurge.com/amd/java/quantize/index.html




回答4:


Take a look at the image filters at http://www.jhlabs.com/ip/filters/index.html. The QuantizeFilter seems to do what you want.




回答5:


Look for algorithms on color quantization, especially median cut. You'll find many examples with those keywords. Libraries to do this for you include ImageMagick which has bindings for many languages. JMagick is the Java flavor.




回答6:


JAI API is the way to go. WIth today's JVM performance is very close to assembler code. I know I've done it.



来源:https://stackoverflow.com/questions/87062/color-reduction-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!