PHP Historgram Question
Moderator: General Moderators
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
PHP Historgram Question
I have some php code that analyses an image and returns all of the image info, for example the 'Red', 'Green', 'Blue', values for each pixel and from this I have the mean 'Red', 'Green', 'Blue', values and other averages of the image.
I want to use this information to search for similar images.
This is how I want it to work:
Basically a user uploads an image into a directory, the path and all of the histogram info is then entered into a database. Then these values are used to 'match' the image to other similar images.
Basically what I want to know is what is the best way to do the comparison, what is the best way to use the information I have gathered to find other similar images?
Thanks
RJ
I want to use this information to search for similar images.
This is how I want it to work:
Basically a user uploads an image into a directory, the path and all of the histogram info is then entered into a database. Then these values are used to 'match' the image to other similar images.
Basically what I want to know is what is the best way to do the comparison, what is the best way to use the information I have gathered to find other similar images?
Thanks
RJ
I'd suggest a FULL TEXT index. Making an index of each of your average values, will let you search that column and get results returned back in order of relevancy. Look at the MySQL documentation for more info.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
I had previously thought of that but i thought that doing a search like that would only return an image if the values were exactly the same. Ive never coded any search stuff before, so it would be a search that would find similar values. All i would have to do is define the tolerance of the search say return an image if the Red, Green and Blue values were within 10, 20 or 50 units of each other. Is that right?
Just as a side thought, if i was to try and do some kind of pattern matching to find images that had similar content and not just colours, would it be possible to put all of the actual values (and not just the averages) into a multi-dimensional array or matrix and then do a comparison? This isnt important to my project, just for an idea.
Cheers
Just as a side thought, if i was to try and do some kind of pattern matching to find images that had similar content and not just colours, would it be possible to put all of the actual values (and not just the averages) into a multi-dimensional array or matrix and then do a comparison? This isnt important to my project, just for an idea.
Cheers
Hmm, you could do a search kind of like this:
The RGB values could be figured out separately, and inserted.
Code: Select all
SELECT
*
FROM
pictures
WHERE
blue <= 40 AND
blue >= 0 AND
green <= 75 AND
green >= 35 AND
red <= 20 AND
red >= 0Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
OnionMosaic, my PHP photomosaic software uses:
That will get the nearest colour to an input colour.. Obviously $r, $g, and $b are the values of the colour you're after, and rVal, gVal, and bVal are the colour value fields in the database.
EDIT: the forum software is converting my red variable to $are. No idea why, its stupid.
Code: Select all
"e;select * from mos_sourceimage order by abs("e;.$r."e;-rVal)+abs("e;.$g."e;-gVal)+abs("e;.$b."e;-bVal) limit 1EDIT: the forum software is converting my red variable to $are. No idea why, its stupid.
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
feyd - what do you mean 'the separate parts' ?
pickle - cheers that all seems to make sense
onion2k - im new at all this and dont really understand that piece of code - ill give it a go and see if i can get my head round it -- 'mos_sourceimage ' is just the table in the DB that contains the pictures but still confused about $r, $b, $g and the rVal, gVal and bVal stuff
thanks for your help
pickle - cheers that all seems to make sense
onion2k - im new at all this and dont really understand that piece of code - ill give it a go and see if i can get my head round it -- 'mos_sourceimage ' is just the table in the DB that contains the pictures but still confused about $r, $b, $g and the rVal, gVal and bVal stuff
thanks for your help
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am