Sounds like what you want is a histogram: essentially, an x-y diagram of frequency of colors in an image. Your basic idea is sound, but things get complicated quickly. Do you have RGB data or transparency as well? How many bits deep are the images? Do you want to do any binning (group "similar" colors for some suitable definition of similar)?
As a first shot, you may want to try writing some Perl-Fu scripts in The GIMP to test your ideas, rather than starting completely from scratch. That way, you can get a better feel for how hard or easy it is to do what you want.
| [reply] |
Histogram? Excellent. If I know a word is associated with it, then I can search on how to do it. That's a start.
Do I have transparency? I will assume no, or if I do (by "I" I of course really mean "the image" - everyone knows that I'm transparent), then I will just ignore the transparency.
How many bits deep? Don't know. Some will be black and white, some will be 256, some will be "bunches o' colors" (sorry to get all technical there).
This is going to be tied into images originating from an infinite supply (the web), so the pool is varied.
If that is bad, then I can limit the pool - assuming there is an "easy" way to do so (for starters ignoring extensions - ie only look at gifs).
Do I want binning? Sure! I'll take two.
Hmm... scripting in GIMP... sounds like I'm going to have to figure out how to get the GIMP working on my Win laptop (none of my Linux machines have heads).
I am essentially going to be pushing my way towards Bayesian classification of images - so I need access to the grid of colors so that I can see what colors are there, and ideally where they are as well (although that feature can be tacked on in a much later version).
-------------------------------------------------------------------
There are some odd things afoot now, in the Villa Straylight.
| [reply] |
An alternative which might make your linux machines
more fun would be to install Cygwin on your windows box,
including XFree86. Then you could ssh to one of them, and
run whatever unix software you like over the network.
| [reply] |
| [reply] |
All I really need is the grid of colors that make up an image.
I wasn't sure how to access that (made especially hard since I wasn't sure how it was referred to) - but then I remembered the ThousandWords module - it looks at each pixel and then looks at the color for that pixel, and then puts a character down that is colored that same color.
Looking through that code, it uses GD and image->getPixel which is accessed via iterating the pixels (you can get the size of the image from other calls and then use that to know how to iterate) - and then off of the getPixel call, you can get the rgb for that pixel.
That will be enough for me to get the color data from and then run the analys from there.
I have a few thousand pictures now to program this for - hopefully I can get this banged out in the next few days.
-------------------------------------------------------------------
There are some odd things afoot now, in the Villa Straylight. | [reply] |
UGH!!!
I was cranking along with GD and thinking I was doing pretty well with this and should easily finish the first major chunk of it by the end of the week (maybe even the day if things stay slow at work like they have been so far today).
I have a dir full of images that this will scan over and "learn" on - those images are all jpegs.
I didn't think anything of it and was merrily trying to test my code and I kept getting the error "Usage: newFromJpeg(class,filehandle)" and was getting annoyed trying to figure out what was wrong with the code that I was using.
But alas - after a Google search, it seems that is a common error response that one gets if the GD install doesn't have the jpeg support in there.
Like I said in my first post, I am on a shared pair.com server, and just use the modules that they have installed... so it looks like they haven't installed jpeg support for GD (which makes sense since I think I recall that the php access to GD on the server also can't do jpeg - and I assume that they are likely calling the same C libraries?).
So now I have crunched up against a wall - GD has the method calls that I want/need - but I can't use jpegs.
Off the top of my head, I know that the install of GD that I have can do png files - and I think there is likely an easy way to convert jpegs to png (png even has a 24bit deal I think - even though GD only goes up to 18bit - whatever).
So I will try to add in some code to convert from jpeg to png and then do the scan on the png instead.
If anyone else has any ideas (aside from installing more modules/libraries) - feel free to toss them up.
-------------------------------------------------------------------
There are some odd things afoot now, in the Villa Straylight. | [reply] |