how can I minimize the total number of bits for an image?

6 次查看(过去 30 天)
Iam trying to reduce the number of bits for a 256x256 grayscale image..how does the compression do that using imwrite command or any other method..when I used the imwrite with compression command, the image size still 256x256 and still i have same number of bits.

回答(3 个)

Image Analyst
Image Analyst 2019-11-3
If you look at the size on disk, you will see that it's fewer bytes than you'd expect. imwrite() does the compression internally when you specify a filename with a compressed extension like PNG or JPG. Of course when you call imread(), it will uncompress the image back to it's original size and number of bits in your MATLAB program.
  2 个评论
Tasnim Nazzal
Tasnim Nazzal 2019-11-3
My aim is to compress the image in order to reduce the number of bits after converting it to binary so I can transmit less number of bits and in the receiver to uncompress the image back from the received bits to the original image..I dunno which method can be applied..
Image Analyst
Image Analyst 2019-11-3
Using imwrite() is one way. It will use it's internal compression methods to make the data in the file have fewer bits. Just try it and see. Compare the file size on disk for extensions .bmp and .jpg and .png and you'll see what I mean.

请先登录,再进行评论。


Tasnim Nazzal
Tasnim Nazzal 2019-11-4
OK I will try it but how to find the compressed array with lower number of bits per pixel to use it in the transmission in my code?
  1 个评论
Walter Roberson
Walter Roberson 2019-11-4
There are a lot of different techniques available that can reduce the average number of bits written to file per raw input bit. Run length encoding. Huffman encoding. Arithmetic encoding. Zig-Zag encoding with pulse-modulation techniques. LZW compression. And more. Sometimes DCT or wavelet techniques can be made lossless, but those techniques are better suited for lossy encoding.

请先登录,再进行评论。


Tasnim Nazzal
Tasnim Nazzal 2019-11-4
Can please any body provide me with simple code for imread() grayscale image 256x256 then use imwrite() with compression then show me how to get the compressed matrix to transmitted it..
I think I missed some small points I couldn't realized it
  2 个评论
Walter Roberson
Walter Roberson 2019-11-4
No, that is the wrong thing to do for your purposes. You should follow the hints I gave repeatedly, and do one of Run Length Encoding (look in File Exchange), or Huffman Encoding (see huffmanenc()) or LZW (multiple implementations in File Exchange), or similar, or use a lossy algorithm.
Walter Roberson
Walter Roberson 2019-11-4
For this purpose you should be assuming that the destination does not have any file system, so you should not be transmitting bits to be written to a file that is then to be read in.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Denoising and Compression 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by