Arithmetic coding for image compression
26 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
haithem abdelghany
il 25 Lug 2017
Commentato: Walter Roberson
il 16 Lug 2021
I am working on the topic of image compression I found built in matlab function for arithmetic coding which is arithenco I want to use it in image compression can any give me example on how to this function for image compression.
0 Commenti
Risposta accettata
Walter Roberson
il 25 Lug 2017
reshape() the image into a vector. Apply arithmetic encoding.
11 Commenti
Walter Roberson
il 16 Lug 2021
bytes = uint8([]);
bytes = [bytes, uint8(length(unique_symbols)) ];
bytes = [bytes, uint8(unique_symbols)];
coded_as_uint8 = uint8(bin2dec(char(buffer(coded_result,8) + '0').'));
unused_bits_of_last_byte = uint8(length(coded_as_uint8) * 8 - length(coded_result) );
bytes = [bytes, unused_bits_of_last_byte];
bytes = [bytes, coded_as_uint8];
imwrite(bytes, 'useless_image.tif');
The above will fail if the encoding requires more than 4 gigabytes. You must use .tif to be able to handle that size; if you can be sure that the encoding will be no more than 2 gigabytes (minus one byte) then you can use .png .
.tif and .png files can be used to store arbitrary bytes without loss. (.bmp too, but .bmp has a limit of 30000 bytes for this purpose.)
You will not get any useful output if you ask to display an image created in this way: if the arithematic encoding worked properly, then the output will look pretty much random. Just because you can create an image file does not mean that the image file is understandable to humans.
People keep expecting that compressed images look like... I don't know. A distorted but partly recognizable version of the original, I guess? A smaller and possibly recolored version of the original?
But compression theory says that you can continue to compress until one of two things happens:
- the compressed values become statistically indistinguishable from random; or
- the overhead needed to describe the data transformations to apply more compression starts to take more space than just listing the compressed bytes as they are.
If you could still make out any resemblence between the original image and the data representing the compressed image, then you did not do a good enough job of compression !!
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Denoising and Compression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!