Log In  

ha
by dw817
Cart #ha-1 | 2019-11-20 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

Having been experimenting with compressing screens of pixels I was wondering if it were possible to write a compressor that returned the results of a dithered image. That is, where the output results would be difficult or impossible to compress effectively using standard methods of image compression.

And this is a 1st stage. Tomorrow if I have time I'll work on and post the 2nd stage. If it's successful it will also dither an image but in a third of the current compression space (less than 512-chars) yet still span the full screen.

For instance this particular image compresses from 16384-chars (raw image) to 1457-chars. Obviously it does not include all 16-colors and instead relies on a black and white table that is a size of 5. Five because I want to have both solid black and white in it.

Yet I think this is useful, especially if someone wants to include a large number of "clipart" images in their cart and for them to be dithered, perhaps for an adventure or mystery game that relies on many pictures.

P#70058 2019-11-20 05:05 ( Edited 2019-11-20 05:08)

1

Hi dw817,

I played around with lossy grayscale image compression a while back using something kinda resembling jpeg algorithms. Ultimately, it could only get about 12 heavily artifacted 64x64 grayscale images in code space (and maybe 10 more in sprite and sound), and I didn’t pursue further, but maybe there’s something in it or in the comments that would be relevant to your compression.

https://www.lexaloffle.com/bbs/?tid=30013

P#70084 2019-11-21 02:16 ( Edited 2019-11-21 02:19)

Looking at what you did, @electricgryphon, you are LIGHT YEARS ahead of me. Wow. Not going to touch JPEG but I think I can do tighter compression than you though with the 2nd method (not today but tomorrow).

Right now I'm unsuccessfully finding a tool to convert my PNGs to raw lookup color data (not 24-bit but 4-bit). I made a 16-color table in Paintshop Pro using the standard 17-method (Lord I couldn't even find that provided) and am going to extrapolate the data manually by writing a converter in Blitzmax using the same table to convert 24-bit .PNG to 4-bit ASCII.

Nasty I know but dang if there isn't anything out there to decode a picture for me to raw .TXT index palette. Not Paintshop Pro and not even IrfanVIEW. Very disappointing.

I also can't rely on Pico-8's own PNG import converter as I cannot get a true 16-color B&W out of it.

. . .

Can I ask what the average size (in characters) each of your sample 64x64 pictures are from your own code ? Then I'll have some basis for comparison as I work on mine.

P#70088 2019-11-21 02:29 ( Edited 2019-11-21 02:59)

Each image takes up about 850 characters. In theory, it outputs 256 shades of gray... but not really.

Generally, compressed code limit is going to get you before token limit or character count becomes an issue if you are storing data in strings. I stored these with base 64 characters, but using hex characters would have probably resulted in the same compressed cart space.

Python NUMPY is pretty good for importing PNG, iterating through the pixels, doing magic, and exporting into a text file. My code for that is embarrassingly hacky. https://github.com/electricgryphon/pico_8_jpg

P#70091 2019-11-21 05:18

Everybody is always programming in PYTHON it seems.

Makes me wonder if I shouldn't have learned it instead of Pico-8 to write better games and tools in.

I'm relaxing with Adventures To Go ATM. Bed soon, and tomorrow - will tackle that 2nd level image compression.

I know I can beat 850 even without a 3rd slower-method compressor. I just don't know how blurry the final result of my picture will be until I code it ...

P#70092 2019-11-21 05:39 ( Edited 2019-11-21 05:49)

This reminds me a talk I've watched some time ago.
In a GDC talk https://youtu.be/z1aVDael-KM Brian Moriarty talks how LucasArts added support for compressing dithered images to Scumm engine, to be able to use beautiful 16 color dithered images in Loom.
Nostalgic, but not necessarily useful. :)

P#70097 2019-11-21 17:15

It might be, @wieczu - if I understood it. Something that is a treasure and a plague at the same time is while I can often understand my own mechanics on things, and they might be complex, I seldom can understand the mechanical doings of other peoples codes.

Let me see ...

GEORGE WASHINGTON AT 637-CHARS

"--|bc01*qa1pc0'd=*a!qavqqab}o4(5w-5qnj9yoa1pq8(5*-8qk79yoa1oq0jd!pacqfv.c2pyoa1oq059md|1cfu.q2e>-7%}-a7@-na8^-5yn7[)n29*nfx@-ua9-a#>t24qqf1pm57c<-8oqa)>a2boca,@q0f!<-5}-a1*c29o;51p0b=p00'1q-7}-f7>oafoca7o|0d@q0^po0>1o01*q08pqf7}-05o|0d{o0!dqca9q01*cbbpca3*-f?p-e7!'9a9o0d}-a%ycad}oa#*cefpo089m82dg-5@|0?*ca7}|ab}q08!o559n8m405f};a?o-23}-afc(0m8o}2!o01y-a5co53}q05900m8o*2!o0?ynabyoa1@-02cqda6-05}o(d}-a^9tqjc-a1*ca<}q05cq-(9;qjcon?oo089o-2cq-0d)-89-07};a1oq0r9n0a8t}2cq88ocadp-12c(k0d.c8@c42cn0f9k8(ea03}c1!!o0850-0d_889oae}n1f!j--8-80di-aq|2zp-1n0n-ae;-0oo76>-2d8--|0c-ae(-7qq3eoc--87-nd:-(8q-@*qf4c(pc8o@j8o-7}oa3q-a'8bcjdc-8p-a%}q00d("

[8x8]
"

But blurry as heck.

Ah, back to the drawing board ...

I wonder if it's possible to superimpose a 1-bit picture as 4-bit.

P#70129 2019-11-22 23:51 ( Edited 2019-11-23 04:20)
1

Let's try that again.

Here is superimposed George Washington, 682-chars.

Cart #yumodiyoga-0 | 2019-11-23 | Code ▽ | Embed ▽ | No License
1

Better source preparation (11-23-19)

A little rough around the edges but viewable. One thing interesting about this compression is it will ALWAYS be 682-chars no matter the image.

P#70138 2019-11-23 02:57 ( Edited 2019-11-23 06:51)

Here is a Thanksgiving Cornucopia.

Cart #pabonosehe-0 | 2019-11-23 | Code ▽ | Embed ▽ | No License

Hmm ... I suppose I could save the color scheme as part of the picture. Might add 3-chars to total as last is always white and I'm dealing with 5 "colors."

You know, I may have answered my own question on how to reverse-engineer this so it can take a true 256-grayscale where the brightness pixel flags are desired and still keep the same compression. Hmm ... Will give it some thought.

Also I can see how to get greater compression too without affecting the picture, but it would be based on the source input given.

P#70142 2019-11-23 03:29 ( Edited 2019-11-23 07:35)

I started a fresh tab - and final work for this image compression method can be found HERE:

https://www.lexaloffle.com/bbs/?tid=36028

Now I'm working on a game, yep, a real game, an action game if you can believe that. Hopefully be done within this week.

P#70221 2019-11-25 18:58

jorg washingmachine

P#70352 2019-11-29 03:17
1

Stay in school kids, or you may wind up like Scrub here. :)

P#70355 2019-11-29 05:32

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 10:54:17 | 0.026s | Q:38