[Gimp-developer] A simple (?) question...

Torsten Neuer tneuer at inwise.de
Wed Apr 9 01:14:19 PDT 2008


Hi David,

> >  Since I haven't been able to find a function within the libraries that I
> > could use as a starting point (and of course I do not want to re-invent
> > the wheel), my question is, if there is such a function that would
> > provide an identical value for any identical image - or would I have to
> > write a kind of pre-filter in order to generate that value ?
>
> What you are talking about is a hash function. There is a string
> hasher in GLib that should do what you want.

Quite so, yes - thank you, I'll try that out.

> However, be aware,
> the criteria 'a random number seed that is unique for every image that
> is going to be processed,' cannot be fulfilled in an absolute way.
> With a hash value of 32bits, that's > 4 billion possible hashes.
> Practically speaking, you are likely to encounter a hash collision*
> unless the amount of images in the set you're processing gets very
> large, you should be aware that it is always possible though.

I am aware of that. The point is, that the function is a random but - 
according to it's documentation should behave identically for identical 
images.  The idea behind this is, that you should be able to recreate the 
same effect on the same image - even if there is such a thing called random.

The cheapest possible solution to that would be to use a constant as the 
random number seed.  This, however, would make the random function very 
predictable, which I feel is horribly wrong - so I'd rather go with a hash 
which may collide from time to time, yet still will be a good enough seed.


  Torsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : /lists/gimp-developer/attachments/20080409/5b4bc0b6/attachment.bin 


More information about the Gimp-developer mailing list