| |
Heavy Stylus
Registered: Apr 2007 Posts: 62 |
Counting unique chars in an image...?
Hey there,
I'm actually writing on behalf of Smila with regard to his soon-to-be-released Soulless game.
He was asking if there is an easy way or analyse an image on a PC and count how many unique characters are used in in (8x8 blocks).
Surely people don't always do this manually? Is there a tool or plugin that's available to count how many chars are used (and ideally display them all separately). Does Studio 64 do this when it imports images?
Any help would save hours of work!
James. |
|
| |
MagerValp
Registered: Dec 2001 Posts: 1078 |
Bitmap -> charset converters do that, lots of suggestions in this thread: png/jpg/bmp to char mode
|
| |
The MeatBall
Registered: Dec 2001 Posts: 367 |
Backdrop-Designer V2.0 will search for unique chars and "compress" your charset to the least amount, but I don't think it counts the result for you. |
| |
Skate
Registered: Jul 2003 Posts: 495 |
i believe you're gonna choose an existing tool but if you want to code your own tool, logic is very simple actually.
every 8x8 block can be represented with a 64-bit integer value. use a unique container like "set" in your favorite language and just push all 1000 values to this container. at the end, just look at the count. |
| |
Heavy Stylus
Registered: Apr 2007 Posts: 62 |
This has been a great help! Thanks :) |
| |
Romppainen Account closed
Registered: Apr 2008 Posts: 40 |
I've used Tile Extractor for quickie checks: Convert your image to .bmp format and feed it to utility using 8x8 px matrix, it'll output several files which all ain't necessarily usable in C64 enviroment as-is but you can see amount of both used and duplicate chars straight in the processing window. |
| |
Wisdom
Registered: Dec 2001 Posts: 90 |
Mega Logo Converter V1.3 will do the job if you convert the picture to a C64 bitmap first. Despite its name, it can convert fullscreen pictures.
There are probably better ways to do it in this age though. |
| |
enthusi
Registered: May 2004 Posts: 677 |
If you are only interessted in exact copies (not same bitmap, but different colors) you can do it in a few lines of python.
(pseudocode)
tiles=[]
for x in range(0,width/8):
for y in range(0,height/8):
char=image.crop(8x8box)
if char not in tiles:
tiles.append(char)
...
print len(tiles)
|
| |
Endurion
Registered: Mar 2007 Posts: 73 |
Cute!
I've just added that to C64Studio for Soulless ;) |
| |
MagerValp
Registered: Dec 2001 Posts: 1078 |
Quoting enthusiIf you are only interessted in exact copies (not same bitmap, but different colors) you can do it in a few lines of python. Python even has a built in datatype for collections of unique objects, the set:
tiles = set()
for y in range(0, height, 8):
for x in range(0, width, 8):
tiles.add(image.crop((x, y, x + 7, y + 7)))
print len(tiles)
Of course it turns much more complex if you want to account for (invisible) variance in color mapping, and things like mixed hires/mc chars. |