(To Anthony, especially.)
I need to do something more or less like the following.
I figure that this should be easy with the new IM7 API, but I'm fine with IM6 too. (Custom compile in HDRI, either way.)
Command line or PERL (had to learn this language that many use to put together useful obfuscated abominations). Either way, this will sit inside a PERL script.
Eventual goal:
I want to get quick and dirty Jacobian adaptive blended resize through ImageMagick, in such a way that I get the following:
If the transformation enlarges or keeps dimensions the same (in which case, it's basically no-op), use pure -resize wxh or wxh^ or wxh> (whichever is "asked").
If the transformation shrinks, figure out the resize ratio, which is then automatically less than 1. (For example, if I am doing -resize 50x100 to an image which is 200x400, this ratio is .25.) Let's call this ratio "r".
Then, the output (a ppm, after cropping and a few other shenanigans) is r * [result of -resize] + (1-r) * [result of -distort Resize through linear RGB].
In other words, I'm blending the result of -resize with the result of -distort Resize (through linear light) with a weight that's set up so that if you don't shrink, you get pure -resize, and if you shrink a lot, you almost get pure -distort Resize through linear light.
First step:
Is there an easy way to figure out the Jacobian matrix that corresponds to an aspect ratio preserving operation which could be -resize wxh or wxh> or wxh^?
This Jacobian matrix is a 2x2 diagonal one with the same entry all along the diagonal, because this is a plain resize. Really, I want to know this entry. When the image is halved (50%), it's .5. When it's enlarged by a factor or 2, it's 2.
Of course, the relationship between the output image width and height and the input can be found in the source code for all three of -resize wxh, -resize wxh> and -resize wxh^. I'm hoping I can be lazy.
how to get quick and dirty Jacobian adaptive blended resize
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
how to get quick and dirty Jacobian adaptive blended resize
Last edited by NicolasRobidoux on 2013-05-13T10:49:07-07:00, edited 1 time in total.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: how to get quick and dirty Jacobian adaptive blended res
Note that in GEGL (the new compute engine of GIMP), I use r^2 as blending factor, not r. For my current work, I want r.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: how to get quick and dirty Jacobian adaptive blended res
I'm also not particularly concerned about using the exact value of the ratio. If things are complicated, I may do a dirty estimate.
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: how to get quick and dirty Jacobian adaptive blended res
I think I found another way to deal with my issues, so I probably will not explore this further.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: how to get quick and dirty Jacobian adaptive blended res
I'll wait.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 1944
- Joined: 2010-08-28T11:16:00-07:00
- Authentication code: 8675308
- Location: Montreal, Canada
Re: how to get quick and dirty Jacobian adaptive blended res
Turns out my client discards all images that result from enlargement, so this is not needed (by me).