Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Converting animation into lossy charset - how ?
2015-07-12 12:14
Oswald

Registered: Apr 2002
Posts: 5017
Converting animation into lossy charset - how ?

I've always wondered how an algorithm decides how far is a char from another. any pointers ?
 
... 38 posts hidden. Click here to view all posts....
 
2015-07-12 16:39
4mat

Registered: May 2010
Posts: 63
I think my petscii converter does a simple tally per 8x8 grid against the char rom, then picks the highest scoring char. Good thing is if you use a custom char set it'll always pick something regardless of the size. (in Party Bit the credit pictures were done with a 6 char font) Doing colour pics was a bit more involved, I went with a threshold level around the rgb values in the pic and compared against the palette's rgb. (Probably should have used luminance as well but I didn't)
2015-07-12 17:08
Krill

Registered: Apr 2002
Posts: 2844
Quoting 4mat
I think my petscii converter does a simple tally per 8x8 grid against the char rom, then picks the highest scoring char. Good thing is if you use a custom char set it'll always pick something regardless of the size.
Matching against an existing set of chars makes the problem a lot easier, i think. Generating an "optimal" set of arbitrary chars, on the other hand... :)
2015-07-12 17:12
Krill

Registered: Apr 2002
Posts: 2844
Quoting Oswald
I'm just lazy to mess with FFT totally new territory for me, altho i know what its basically, but its a totally different thing when you have to code it (or make some alien code to work)
Actually, playing around with libjpeg for this purpose and maybe hacking it to produce 256 characters doesn't sound like a half-bad idea to me.

Groepaz, what's your verdict? And algorithm, please do tell us some details of what you did so far! :)
2015-07-12 17:35
algorithm

Registered: May 2002
Posts: 702
I wont post everything here. But for a quick insight into the basics of what I am doing. please read the manual of one of my tools here

https://www.dropbox.com/s/ygmfp8nd0o4z35m/CSAM%20Super%20-%20Ma..
2015-07-12 18:21
chatGPZ

Registered: Dec 2001
Posts: 11116
Quote:
Groepaz, what's your verdict?

i have not yet seen anything lossy on C64 that i liked (sorry algo) and i dont think i can make it better either :) (and i dont find it an interesting subject in the first place)
2015-07-12 18:23
ChristopherJam

Registered: Aug 2004
Posts: 1378
FWIW, both the zoomer in Effluvium and the animated ball in Jam Ball 2 use variations on k-means clustering, with a fair amount of tweaking.

Basics are explained at https://en.wikipedia.org/wiki/K-means_clustering where each observation X corresponds to an 8x8 tile from one of the source images. (or, in Effluvium's case, an L shaped tile that covers three chars..)

I tend to work in greyscale until I have a decent dictionary, then dither that to hires or multicolor before requantising the frames to the final character set. For Jam Ball 2 I actually built dictionary of somewhere around 260-265 entries, as several of the final entries merged once I dropped to one bit per pixel.

A JPEG style DCT means you can start with comparing overall luminance and low frequency components, but really that's mostly a speed optimisation. A simple sum of squared differences works pretty well, and at one bit per pixel that turns out to just be a count of the pixels that are different.
2015-07-12 18:24
JackAsser

Registered: Jun 2002
Posts: 1989
Oswald: The technique is called clustering. The algorithm below is naive and extremely slow. Finding the optimal solution is NP-complete. You need to cut corners, but just to give you an idea:

1) Generate all possible chars the animation has. It can be millions depending on how long it is etc.

2) You need to keep track of the frequencies, i.e. how often is a particular char used.

3) You need to create a function which calculate the difference between two characters and give a score. 0 == equal. >0 != equal. A method could be using least squares (https://en.wikipedia.org/wiki/Least_squares) or so.

4) Loop until your charset is x characters long.
4.1) Find all character pairs.
4.2) Generate an intermediate char. F.e. by averaging the two, or so.
4.3) Calculate the visual impact if you should pick that intermediate char by looking up in your frequency tables.
4.4) Pick the pair with the lowest possible visual impact and replace the two source chars with the intermediate char. Delete the source chars from the charset and update the frequencies.

Eon later you will have your clustered charset. This is how the rotator work in Mekanix. How the horizontal twister in Amplifire work etc.
2015-07-12 19:27
Oswald

Registered: Apr 2002
Posts: 5017
suprisingly good considering it basically only counts and compares set pixels yet.

2015-07-12 19:29
Oswald

Registered: Apr 2002
Posts: 5017
holy cow, least squares and k-means makes me wanna code FFT. respect guys you can understand and implement that :)
2015-07-12 20:24
Oswald

Registered: Apr 2002
Posts: 5017
another bug ironed, quite puzzling, I only compare pixels at te same place, if not distance = +1. the result is much better than expected.


Previous - 1 | 2 | 3 | 4 | 5 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Matt
www.gb64.com
stephan-a
Krill/Plush
Dymo/G★P
TheRyk/MYD!
Majikeyric
Guests online: 89
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 S!R  (9.9)
3 Antitrack  (9.8)
4 Mr Zero Page  (9.8)
5 OTD  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.058 sec.