Ho we can Implement Unary compression method and create Unary encoder decoder in matlab?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi, I want to Implement the Unary compression method for compressing Grayscale images how I can do that?
My main goal is to create a function that the output must be the compression rate, which is calculated based on the size of the original image file and the size of the compressed file.
one function for the unary encoder and another one for the unary decoder.
Thank you for your participation
採用された回答
Mathematically, you can consider a file of bytes to be a Base 256 encoding of an integer. For example if the file contained just the bytes 241 217 (decimal) then that could be considered to mathematically be a representation of 241*256+217... whatever that number happens to work out as.
The unary representation of a number requires taking that many copies of a symbol in a row. For example if the value is 19 then the unary would be 19 copies of a symbol. Like ::::::::::::::::::: or 1111111111111111111. The end of the number is marked by the sequence stopping. The value represented is determined by counting the number of symbols.
Pure unary is only able to represent one number per universe. To represent two different numbers you would need to mark the boundary between the unary sequences, which requires a second symbol.
The smallest input image file you can have is one byte, which could represent a single grayscale pixel with intensity 0 to 255. (Or could represent a single pixel rgb image with 3 bits of red information, three green, and two bits of blue.)
You cannot write out less than 8 bits to a file, so input bytes in the range 1 to 8 require at least a single byte of output, and input bytes of value 9 and up require more output bytes when represented in unary. Therefore you cannot compress anything using a unary encoder.
Exception: if your input image consisted of a single pixel with value 0, then the unary encoding of it would be the empty file, which is indeed smaller. This is the only case that you can compress using unary.
5 件のコメント
Thanks a lot. First, I want to implement the Unary method in Matlab for a grayscale image, Second I want to find geometric distribution given the geometric necessity of data distribution for better performance of the Unary method, a solution to simulate the distribution of images to geometrically reversible distribution.
For the first step could you please help me?
How I can convert a grayscale image to unary format for each pixel?
My main problem is how I can save Unary codeword and after encode unary codeword.
UnaryImage = arrayfun(@(v)repmat('0',1,V), YourImage, 'UniformOutput', false);
The rest such as geometric distribution looks like nonsense in the context of unary representation.
What is the V parameter here?
How do this work for create Unary codeword for each pixel?
k=imread('./test.png');
V=5;
UnaryImage = arrayfun(@(v)repmat('0',1,V), k, 'UniformOutput', false);
I run it but I got UnaryImage matrix with whole of zero value each cells 00000 value
V was a typing mistake, should have been v
filename = 'cameraman.tif';
k = imread(filename);
k = imresize(k, [8 8]); %very small!
UnaryImage = arrayfun(@(v)repmat('#',1,v), k, 'UniformOutput', false);
k(1:2,1:2)
ans = 2×2
160 170
164 180
UnaryImage{1,1}
ans = '################################################################################################################################################################'
size(UnaryImage{1,1})
ans = 1×2
1 160
size(UnaryImage{1,2})
ans = 1×2
1 170
size(UnaryImage{2,1})
ans = 1×2
1 164
size(UnaryImage{2,2})
ans = 1×2
1 180
You can see from this that each cell is the unary representation of one pixel, repeated occurances of a single symbol, with each pixel intensity being repeated by that many occurances of the symbol.
For Unary, the choice of symbol does not matter: only the number of symbols is important.
If you approach counting as an ancient practical task, such as making one mark for each sheep, then making a simple solid mark such as "|" or "/" is most consistent with established history. It is common for "1" to be used, in analogy for the counting numbers starting with 1, but that is not really historic: "1" is a numeral, something that has history and theory attached to it, but if you are taking the "it is just counting" approach then using "|" or "/" would be more to be expected.
If, on the other hand, you approach Unary as a numeric base, a matter of positional notation representation of an abstract concept, then in Western mathematics, it would be more correct to use "0" as the symbol for the digit used in Unary. Positional notation representation does not start each digit with 1: it starts it with 0 -- for positional notation, the numeric sequence is not 1, 2, 3 and so on: for positional notion, the numeric sequence is 0, 1, 2, 3, and so on. 0 is the kernel left behind when you have reduced down to a single possibility per position in a numeric positional notation system.
Ok,thanks
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Denoising and Compression についてさらに検索
参考
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)
