Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user NthSt4r ! (Registered 2025-05-17) You are not logged in - nap
CSDb User Forums


Forums > C64 Pixeling > Counting unique chars in an image...?
2012-03-20 11:11
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.
2012-03-20 12:09
MagerValp

Registered: Dec 2001
Posts: 1082
Bitmap -> charset converters do that, lots of suggestions in this thread: png/jpg/bmp to char mode
2012-03-20 12:10
The MeatBall

Registered: Dec 2001
Posts: 375
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.
2012-03-20 12:24
Skate

Registered: Jul 2003
Posts: 505
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.
2012-03-20 12:29
Heavy Stylus

Registered: Apr 2007
Posts: 62
This has been a great help! Thanks :)
2012-03-20 14:24
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.
2012-03-20 16:08
Wisdom

Registered: Dec 2001
Posts: 91
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.
2012-03-20 16:13
enthusi

Registered: May 2004
Posts: 679
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)
2012-03-20 19:49
Endurion

Registered: Mar 2007
Posts: 73
Cute!

I've just added that to C64Studio for Soulless ;)
2012-03-21 08:04
MagerValp

Registered: Dec 2001
Posts: 1082
Quoting enthusi
If 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.
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
DuncanTwain
Digger/Elysium
Scooby/G★P/Light
GuyGavin/HF
Yogibear/Protovision
Matt
Edhellon/Resource
LordNikon/Dekadence
zzarko/Avatar
Jammer
Technotron/I-I F
Rebok/BOOM!/Tropyx
t0m3000/bo0M!^hf^ibex
A3/AFL
Guests online: 140
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.6)
4 Coma Light 13  (9.6)
5 Codeboys & Endians  (9.6)
6 Edge of Disgrace  (9.6)
7 Signal Carnival  (9.6)
8 Comaland 100%  (9.6)
9 What Is The Matrix 2  (9.6)
10 Uncensored  (9.6)
Top onefile Demos
1 At the Cinema  (9.8)
2 Nine  (9.8)
3 Layers  (9.6)
4 Cubic Dream  (9.6)
5 Party Elk 2  (9.6)
6 Datastiltje 2014 Win..  (9.5)
7 Copper Booze  (9.5)
8 Onscreen 5k  (9.5)
9 Libertongo  (9.5)
10 Charflasher  (9.5)
Top Groups
1 Artline Designs  (9.4)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Performers  (9.3)
5 Censor Design  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Electric  (9.6)
5 Veto  (9.5)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 1.105 sec.