how can I minimize the total number of bits for an image?
조회 수: 3 (최근 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.
댓글 수: 1
Walter Roberson
2019년 11월 3일
See my recent discussion at https://www.mathworks.com/matlabcentral/answers/488758-how-can-i-reduce-the-bits-per-pixel-in-an-image
답변 (3개)
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
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
2019년 11월 4일
댓글 수: 1
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
2019년 11월 4일
댓글 수: 2
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
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 Center 및 File Exchange에서 Denoising and Compression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!