Getting a thin vertical line as output image.
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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 件のコメント
Nidhi Kumari
2018 年 10 月 14 日
I have to display it in the compressed form only.
Image Analyst
2018 年 10 月 14 日
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.
Nidhi Kumari
2018 年 10 月 14 日
So in short i cant see the compressed image?
Walter Roberson
2018 年 10 月 14 日
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.
Nidhi Kumari
2018 年 10 月 14 日
Is it not possible in Huffman method only or in others too?
Image Analyst
2018 年 10 月 14 日
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.
Walter Roberson
2018 年 10 月 14 日
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
