Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user dstar ! (Registered 2024-05-25) 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: 61
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: 1060
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: 366
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: 491
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: 61
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: 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.
2012-03-20 16:13
enthusi

Registered: May 2004
Posts: 675
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: 72
Cute!

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

Registered: Dec 2001
Posts: 1060
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
niallquinn
DKT/Samar
E$G/hOKUtO fOrcE
Yogibear/Protovision
Kruthers
Smasher/F4CG
El Jefe/Slackers^sidD
Mibri/ATL^MSL^PRX
Viti/Hokuto Force
Airwolf/F4CG
Pajda/Faith Design
Guests online: 138
Top Demos
1 Next Level  (9.8)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.7)
5 Edge of Disgrace  (9.6)
6 No Bounds  (9.6)
7 Comaland 100%  (9.6)
8 Uncensored  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 Layers  (9.6)
2 It's More Fun to Com..  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Rainbow Connection  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Covert Bitops  (9.4)
2 Nostalgia  (9.4)
3 Oxyron  (9.3)
4 Booze Design  (9.3)
5 Crest  (9.3)
Top Logo Graphicians
1 Sander  (9.9)
2 Facet  (9.6)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

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