Coder Social home page Coder Social logo

Performance X Size Compress about kanzi HOT 5 CLOSED

flanglet avatar flanglet commented on May 30, 2024
Performance X Size Compress

from kanzi.

Comments (5)

flanglet avatar flanglet commented on May 30, 2024

Hi Rafael,

I am not sure what you are trying to do and what you call 'kanzi format'.
The block compressor allows many different options for transform and
entropy. Depending on the option you choose, you decide whether you want
fast compression (but low compression ratio ... like LZ4) or slow
compression (but high compression ratio, say BWT+CM). Block size also
matters. Which option combination are you using ? BWT+CM or BWT+PAQ is
going to beat GZ hands down in compression ratio. So, it really depends on
your compression command line options.

Frederic

On Sat, Apr 18, 2015 at 6:22 PM, rafaelpivetta [email protected]
wrote:

I have tested the kanzi package with a image and the performance is
fastest than LZ4 and GZ, you really has done a great job.
But the gz format is more compressed than that kanzi, 7 kb aproximately.
It's possible reduce the size of the kanzi format? Or this is not the
objective of the kanzi format?
In my test the size buffer in .gz is the same that kanzi format 32768.

GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(outfile));
byte[] buf = new byte[32768];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}


Reply to this email directly or view it on GitHub
#1.

from kanzi.

rafaelpivetta avatar rafaelpivetta commented on May 30, 2024

Frederic,
Two objectives:
1 - resize a large image to 640x480 ( pixels ) if possible without losing quality , the image should have a maximum of 35 Kb . I'm not sure if kanzi.jar is used for this.
2 - Compress the previous image using BlockCompressor line command or the method compressKanzi(String arg) of the class TestSnappy.java (BWT + CM).
I would like the file size was smaller than using GZIPOutputStream.

Rafael

from kanzi.

flanglet avatar flanglet commented on May 30, 2024

Rafael,

A few comments.
First, using a generic data compressor will not work as well as an image compressor. You may just want to try Java's JPEG encoder:
JPEGImageWriter imageWriter = (JPEGImageWriter) ImageIO.getImageWritersBySuffix("jpeg").next();
ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
imageWriter.setOutput(ios);
Second, if you want to use Kanzi's block compressor, do not use TestSnappy.java. Snappy is geared towards speed but has a weak compression ratio and the class TestSnappy is not part of the project but used to compared implementation speeds. To get a better compression ratio with the block compressor,
from the command line: java -cp kanzi.jar kanzi.app.BlockCompressor -input=XXX -output=XXX.knz -overwrite -block=1m -transform=bwt -entropy=cm
from code: you can instantiate BlockCompressor or CompressedOutputStream. See BlockCompressor.java.
EG: new CompressedOutputStream("CM", "BWT", fileouputstream, 1024*1024, true, null, 1);
Obviously the block compressor is lossless, so in order to achieve a goal of 35 kb, you may have to drop some data during phase 1 (resize). Take a look at kanzi.util.sampling (and the use in kanzi.test.TestColorModel). You could down sample the image by 2 (x4 smaller) then block compress with a miminal quality loss or transform to YUV420 color model (U&V down sampled by 2).

from kanzi.

rafaelpivetta avatar rafaelpivetta commented on May 30, 2024

Frederic,
Ok.
With the "-options" -transform=bwt -entropy=cm or -transform=bwt -entropy=paq, the image file (jpeg) compressed (.knz) is smaller than .gz.

In the TestColorModel test, the error below occurs. My image is 640x480 and the source code kanzi-master.zip.

640x480
================ Test round trip RGB -> YXX -> RGB ================
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at kanzi.util.color.XYZColorModelConverter.convertYUVtoRGB(XYZColorModelConverter.java:200)
at kanzi.test.TestColorModel.test(TestColorModel.java:155)
at kanzi.test.TestColorModel.main(TestColorModel.java:120)

from kanzi.

flanglet avatar flanglet commented on May 30, 2024

I fixed the ArrayIndexOutOfBoundsException in the latest push.

from kanzi.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.