Page 1 of 1
compare calculate function params
Posted: 2012-03-27T14:45:25-07:00
by inkrement
Would it be possible to calculate the params of a special image function if two pictures (before-function and after-function) are given.
Example: I have two Images (an old one and a result of an gaussian blur) would it be possible to detect the used function (blur, median, ...) and to calculate the exact parameters of the given function?
Re: compare calculate function params
Posted: 2012-03-27T16:53:14-07:00
by fmw42
No that I know about with things that are spatially dependent or mix values from a local region without a lot of trial an error. You would have to pick a function (blur or median, etc), loop over the parameter(s) applying those values to your original image, incrementing as desired and use IM compare to get an error metric value for each result relative to your known result to find the best match. Then try the same with another function.
However, I will defer to anyone who has some good ideas on this kind of thing.
Not really related, but worth noting:
If you have point modification functions, such as color, brightness, contrast, etc, you can generate a Hald clut image by processing a specially created Hald image with the same functions. Then that image can be used to modify any other image the very same way quickly. But you have to know beforehand what was done to the image so that you can apply that to the Hald image.
Re: compare calculate function params
Posted: 2012-03-27T18:48:07-07:00
by anthony
Figuring out what was done to transform an image is VERY hard.
Even when you know the function that was used, calculating the parameters can also be very hard, and often devolves to trial and error.
It should however be posible! How is the problem.
Re: compare calculate function params
Posted: 2012-03-30T09:59:00-07:00
by inkrement
thanks... but would it be possible to view the amout of different pixels? then i could write a simple brute force tool and walk in the right direction!
Re: compare calculate function params
Posted: 2012-03-30T10:58:45-07:00
by fmw42
see the compare function. you can choose a number of metrics and get an image that shows where the differences are greatest.
see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
Re: compare calculate function params
Posted: 2012-03-30T17:49:51-07:00
by anthony
If Just the pixel values were directly chnaged, (-nornalize, -negate, -level, -gamma)
you can 'fit' a mathematical function to the pairs of before and after values.
Note however that different channels may use diffenet parameters and co-efficents. (as in '-sepia')
If the channel values become 'mixed' such as using '-module hue rotations' or '-recolor' then it gets even harder
They could even be modified by a free form color modification '-clut' (per channel) or '-hald' (channel mixing).
Of course it can be imposible to recover in color replacements and composition, as some of the original data may have been replaced by data from another source.
And that is just for per-pixel changes.
For convolutions and morphology (-convolve, -blur, -median, -sharpen, -unsharp, etc etc) you get pixels being modified depending on their neighbours. That is a completely different and even harder problem!
As for distortions (pixel being moved spatially) well you will never get the exact original, but typically you can guess as to how an image was distorted and work out a reverse. However some things has no 'true' reverse. (shepard's distortion, barrel lens correction). Especially when you get to free-form distortion/displacement mapping
As mentioned... it is posible... but not easy. Even when you know what was done!