![]() |
[Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: C, C++, & Obj-C (https://sinister.ly/Forum-C-C-Obj-C) +--- Thread: [Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ (/Thread-Source-Lossy-Text-Compression-BitSqueeze-algorithm-Silly) |
[Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ - Frooxius - 09-04-2011 Prequel Quote:OIg*OAABqIYPZn!ZdsQHu%KOdKIls!rcyGAgT/aMAPoqwoRgn#ZdPPXoQos!aDy(CdS$qAiQ+B Hello there, recently I've been working day/night on some serious projects, so I decided to make something funny/silly instead and inspiration was something I said in one IRC before: that I can write seven letter word with six characters. Well this thought lead to something that I call Lossy Text compression. I created algorithm called BitSqueeze, because it literally squeezes an extra bit from every character written. It's capable of shortening a bit even short sentences or even words. It also works only with printable characters, making it suitable for easy copying, pasting and spreading of the compressed text. NOTE: This is just silly, non-serious project made in a few hours, don't take it too seriously, though it can still have quite educational value as proof of concept and so far, people say it's fun to play with ![]() The principle The idea behind this is that when I can loose some information from the original text - mostly capitalization and special characters, I will get a reduced input set, however I can express it using the larger output set - more characters, therefore compressing it a little by loosing some information and then using information that's normally lost, to encode it. Algorithm translates input string to just 32 characters - 5 bits, that are imputed into a bitstream. Once there's at lest 6 bits in the bitstream, then one of 64 characters from the output set is selected. Decompression works in an opposite way: it converts the input characters into a bit stream, each character adding 6 bits to the stream and then new characters are taken from this stream by using only 5 bits. Thus this algorithm saves 1 bit per character, while loosing capitalization and special characters. However, there's a problem: I didn't squeeze whole alphabet and numbers into 32 characters, so 32th character is actually special extensive character, that's followed by 3 additional bits, which encode another 8 characters. I have ideas for even better algorithms, but this was done for fun and as proof of concept, so don't take it too seriously :3 Download Executable + GUI I made a GUI version of this, so you can play with it easily and have some fun while compressing your text ![]() DOWNLOAD ![]() C++ sourcecode I've written the algorithm in C++ language, the source (including command-line test of the algorithm) is freely available, feel free to study it and play with it if you want. It's not really very well polished, nor object oriented, because it was done without planning and quickly, just for fun x3 Code: /* ******************************************** Conclusion So I hope you like this at least a little bit and find it interesting. I'm not sure how useful it might be, but at least we can learn something new about compression I guess ![]() BitSqueeze Wrote:sNgPpUhrJDu/cPi)(bj#GPEraYPgOxO(Cr!b!udAdDb#gA!uJAtsKiNOM(BnsZ!n%ulPrI<&SAQKuOlnAQziZzQdeDGo#GPEraYP$s!cqtViGytlDmY+GAgDJy#GGJo#ch*fjsjY#!iTHsKsDazmrutxCrnOPbvseyi)j(o#ZdrlCSxKiLixthbtKtJKAq!rBd/N>ONhKudwsNMranPEEi)LRzir/+q!tYDQrs/+q!mxKOLpGGOTO#shiAjOsgFRrtTuZCrIwsrtqyr!fxuBJO(K!!tYDQhUMEQfo$lsKsT!XiZdQz!w!+OzGgwlFebcS!IdicetsuQxifrlD!OGOfUbrQlUOMCbS%IOdebGkj)(HijAlAT!bIE(KZV#fxutUa$Br!hsKOrs/+GK)hicmrW*OrnTWXErIusg)IlY!A The original text of the paragraph has 508 characters, the compressed version has 426 characters, thus it's 83.85 % of the original text :3 I hope you'll find this interesting, yours LOZDruP ;-) RE: [Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ - unu213 - 09-04-2011 Try to decompress this "yaupwUbq", and plaint text to decompress again, and so on,u must arrive at this: Code: sNgPpUhrJDu/cPi)(bj#GPEraYPgOxO(Cr!b!udAdDb#gA!uJAtsKiNOM(BnsZ!n%ulPrI<&SAQKuOlnAQziZzQdeDGo#GPEraYP$s!cqtViGytlDmY+GAgDJy#GGJo#ch*fjsjY#!iTHsKsDazm​rutxCrnOPbvseyi)j(o#ZdrlCSxKiLixthbtKtJKAq!rBd/N>ONhKudwsNMranPEEi)LRzir/+q!tYDQrs/+q!mxKOLpGGOTO#shiAjOsgFRrtTuZCrIwsrtqyr!fxuBJO(K!!tYDQhUMEQfo$lsKsT!XiZdQz!w!+O​zGgwlFebcS!IdicetsuQxifrlD!OGOfUbrQlUOMCbS%IOdebGkj)(HijAlAT!bIE(KZV#fxutUa$Br!h​sKOrs/+GK)hicmrW*OrnTWXErIusg)IlY!A It's amazing, woderfull, great. NICE DUDE. Like ur algorithm. RE: [Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ - Frooxius - 09-04-2011 Thanks! Though I'm not exactly sure what you mean: You mean decompress that short string and then decompress decompressed text again and repeat until you get that long string? Algorithm doesn't work that way, it's a lossy algorithm, so even when you compress the compressed string again once, you already destroy the original message, because data required for reconstruction of the original text are lost during this process. RE: [Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ - Frooxius - 09-09-2011 Umm... I don't want to sound rude, but any other feedback? O.o I mean... I got more responses on completely non-technical forums than here, where should be much higher concentration of programmers and computer geeks x3 +T<&yK>*BT!siZ>/BTXnDA<w RE: [Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ - 1234hotmaster - 10-30-2011 great algorithm i finally saw this ![]() RE: [Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ - 1234hotmaster - 10-30-2011 great algorithm i finally saw this ![]() RE: [Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ - Frooxius - 02-10-2012 This project is now also available on my personal website: http://frooxius.solirax.org/content/lossy-text-compression-bitsqueeze RE: [Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ - KrYsp4rk - 02-10-2012 AAARGH!!!! WHY IS THAT INFO WINDOW SLIPPING AWAY? xD Cool ![]() RE: [Source] Lossy Text Compression - BitSqueeze algorithm - Silly! ^^ - Frooxius - 02-10-2012 (02-10-2012, 08:52 PM)Kry-Spark Wrote: AAARGH!!!! WHY IS THAT INFO WINDOW SLIPPING AWAY? xDBecause it's shy and scared of you >:3 Also I didn't figure out how to calm little windows down in C++ *innocent puppy eyes* :3 |