Getting a thin vertical line as output image.
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I have applied Huffman encoding to compress an image but the output image is a thin vertical line. I guess it is because it is still in vector form. So my question is about how to convert it to the desired form.
채택된 답변
Image Analyst
2018년 10월 14일
Uncompress, then display it.
댓글 수: 7
I have to display it in the compressed form only.
You can use imshow() to do that. It will display a stream of single numbers as a 1-D line of pixels, which is exactly what it is. imshow() doesn't need a 2-D image, it works find with the compressed stream of numbers. Of course it won't look like an image, it will look just like the compressed stream of pixels.
So in short i cant see the compressed image?
Is the question about decompressing the image and displaying the decompressed image?
The compressed form of the image is data, not an image itself. You could interpret it as an image, but doing so probably will not be very useful.
Is it not possible in Huffman method only or in others too?
You can display the compressed data as an image regardless of how you did it, though as Walter says, it is not really an image even though you're displaying it as an image. To see the image, you'd have to reconstruct the image and then it will look exactly, or roughly, like the original image depending on how much compression was done.
For example let's say that I had a square 10x10 image (100 pixels) of pixels all with the value 137. I could compress this into only two numbers [100, 137]. I could then show two pixels with a value of 100 and a value of 137, but of course this two pixel image doesn't look anything like the original 10x10 2-D image since it's just two values, not 100 values.
Suppose I had
Carol Alice Alice Carol Bob Bob Ted Alice Ted Alice Bob Alice Ted Bob Ted Carol Ted Ted Alice Carol
then I could compress that to symbols = {'Bob', 'Ted', 'Carol', 'Alice'} together with idx = [3 4 4 3 1 1 2 4 2 4 1 4 2 1 2 3 2 2 4 3] where idx is the index into the symbols array. In turn idx has only four possible states (in this example) and could be written into binary as 1011111000000111011100110100011001011110 where each 2 digits together encodes an idx value, 00 -> 1, 01 -> 2, 10 -> 3, 11 -> 4
So in this example we have now encoded Carol Alice Alice Carol Bob Bob Ted Alice Ted Alice Bob Alice Ted Bob Ted Carol Ted Ted Alice Carol as {'Bob', 'Ted', 'Carol', 'Alice'} (the dictionary) and 1011111000000111011100110100011001011110 (binary).
And you are doing the equivalent of asking to see the the stream of characters associated with the binary, because the original were characters.
Well, it is possible to do that:
char(bin2dec(reshape(dec2base(idx-1,2).',8,[]).').')
ans =
'¾sF^'
where the character between the 3/4 and the s is the ASCII BELL character... but is this even slightly meaningful as an displayed output?
The huffman encoding of your image is similar to the above case, except worse in the sense that the encoding for the different symbols is different lengths, so if you happened to see the same character on output (such as 's') then you could not assume that it was encoding the same input: it could have been caused in multiple ways since the boundary between symbols can be inside the middle of a character (when you define a character as being 8 bit.)
The huffman encoding is not an image itself: it is just data similar to 1011111000000111011100110100011001011110 -- and in fact the same data might encode quite different images, depending on the dictionary that was being used.
For lossy image compression formats, it can make sense to reconstruct the image from the compressed data and then to compare the original image to the degraded image.
For a lossless image compression format, you could reconstruct the image from the compressed data and then compare to the original image for the purpose of proving that the compression / reconstruction routines are working.
But in both cases, lossy and lossless, the compressed data is not an image itself, and would look like noise when viewed. Indeed, if you can see structure in the compressed data, then that indicates that there was probably room for a better compression routine.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
