Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user maak ! (Registered 2024-04-18) 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: 1055
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: 363
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: 490
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: 674
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: 1055
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
Mike
Didi/Laxity
Mason/Unicess
Alakran_64
kbs/Pht/Lxt
mutetus/Ald ^ Ons
Guests online: 64
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 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.9)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 Wafer Demo  (9.5)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Onscreen 5k  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (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 Diskmag Editors
1 Jazzcat  (9.4)
2 Magic  (9.4)
3 hedning  (9.2)
4 Newscopy  (9.1)
5 Elwix  (9.1)

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