开发者

PNG Encoder - Add own filter implementation

I am currently working on my own implementation of a PNG Filter. I am using a Neural Network to try to create a better prediction than the current existing PNG Filters:

  • 0 - None
  • 1 - Sub
  • 2 - Up
  • 3 - Average
  • 4 - Paeth
  • 5 - My Implementation (with Neural Network prediction)

For further info: http://www.w3.org/TR/PNG/#9Filters

I already looked at several Libraries:

  • pngcrush (is implemented in c.开发者_JS百科.)
  • Keypoint - PngEncoder (is my current favourite)
  • ObjectPlanet - PngEncoder (I have to pay 1000$ for the src.. :P)

There are some more. But my question is now, do you know some other PNG Encoders (written in Java) where it is easy possible to add an own implementation of a filter or are there any other possibilities to use my own filter?

Thanks very much for your answers!


A while ago I made a small pure Java PNG library (encoder-decoder)
http://code.google.com/p/pngj/

It's small, quite complete (not fully), it has no dependencies on third party libs, and the code is available (and, I hope, easy to understand). You can dig there if you want to implement a custom filter. If you need some help, you can ask me.

But bear in mind that (as pointed out by other answer) PNG standard does not support custom filters, only you will be able to read your encoded images.


This is not an answer to the question, but more a "it will not work this way".

The PNG specification section you linked defines the Filter method 0, and a list of filter types (functions) for this method. This list is fixed:

Filter method 0 specifies exactly this set of five filter types and this shall not be extended. This ensures that decoders need not decompress the data to determine whether it contains unsupported filter types: it is sufficient to check the filter method in IHDR.

So, you can't simply add your neural network prediction here.

What you could do, is to create a new Filter method (method 1, or such - but see Section 4.9) which then can include your neural network filter type.

But the problem is, that then every software which would want to read the PNGs your software produced would need to support this new filter method, too. So, if you don't want to do this simply for your internal image storage, this is not something useful to do.


Where you actually could use your neural network, is for selecting the right filter type (of the five ones given) for each scanline, such that the resulting gzipped data stream is as small (or efficient or ...) as possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜