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?
compare calculate function params
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: compare calculate function params
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.
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.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: compare calculate function params
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.
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: compare calculate function params
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!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: compare calculate function params
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/
see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: compare calculate function params
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!
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!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/