views:

367

answers:

4

Hello all im transeffing image throw tcp/ip and i like to optimize it and still good quality as much as possible what kind of methods or algorithms i can use ? p.s now if i think about it maybe i should ask what is the best and the fast way to send image via tcp/ip

A: 

You may take a look at this. It's a comparison between common compression algorithms (quality and compression rate).

Edit: it is not directly java, but you probably can find an implementation of the desired algorithm.

Burkhard
A: 

You should check Java Advanced Imaging API.

But to use it effectively you will need to understand what type of image operations are right for your problem. This will depend, among other things, on the encoding of your source image.

As for the "good quality as much as possible", you will most likely need to experiment with various compression techniques and their relevant parameters before deciding which one gives the right balance of speed, size and quality for your needs.

Tahir Akhtar
A: 

For images intended for human viewing JPEG is quite nice. What is in the remote end? A browser?

Thorbjørn Ravn Andersen
its remote desktop kind of app
Unless you have good reason not to, then use the VNC protocol. This will also let you reuse other clients and servers if you want to.
Thorbjørn Ravn Andersen
Good idea ThorbjornI found this on wikipedia : http://en.wikipedia.org/wiki/Virtual_Network_Computing
Tahir Akhtar
+2  A: 

To find the right answer to your question, you need to have a look at the images themselves. Are they real world images captured on camera? Or are they synthetic images, like icons or graphs?

Lossy compression (like JPEG) works very well for real scenes with many gradients and smooth edges. For images with solid colors and hard edges, you have a much higher (even perceived) loss in image quality and less gain in compression rates compared to lossless compression.

Basically, established image formats for your domain are PNG (Portable Network Graphics) and JPEG. PNG images are always compressed lossless, but their compression algorithm works better than competition, i.e. GIF. If the images are well-suited, you gain compression rates comparable to JPEG, if not (like real world images), you gain typical ZIP compression rates (around 50%).

After determining lossy/lossless compression (or a combination, based on picture type -- you could also think of compressing images first in both formats and then compare, if processing time does not matter as much as network througput), you should also take the advantage of progressive coding, which is supported both by JPEG and PNG formats. With progressive coding, basically the data is organized in a way that the more data you receive, the better the quality (other than just sending the images row-by-row). The advantage here is that you can show the image to the user already while it is still being received. However, for this you need a decoder who exposes this functionality.

I don't know about the libraries available in Java for this.

ypnos
its desktop image ...
For a desktop screenshot you probably want to use lossless compression, although software exists which uses lossy for them.One good idea is to use lossless compression, but reduce the number of colors beforehand.
ypnos