I'm trying to shift pixels in a jpg, to adjust for photos being taken through glass that is not perpendicular to the camera.
1) convert to grayscale
2) adjust for glass (smearing between closest points as needed)
3) create new jpg
Is this something I can do with ImageMagick?
Can I do it at the pixel level, or do I need go to a matrix, then convert back to pixels?
Adjusting for non-straight glass?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Adjusting for non-straight glass?
I am sure something like this can be done. the question is the details, and how difficult it is.
God is in the details.
It's always the details that get you in trouble.
-- Rick Cook, "Wizardry Cursed"
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Adjusting for non-straight glass?
the math behind the shifting is done, just need to know how to extract the jpg's raw coordinates.
Any thoughts on how that's done with ImageMagick?
Any thoughts on how that's done with ImageMagick?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Adjusting for non-straight glass?
In what API: command line, perl?
You may like to look though
http://imagemagick.org/Usage/distorts/#lut
Note that the maps are from destination pixel to source pixel
You may like to look though
http://imagemagick.org/Usage/distorts/#lut
Note that the maps are from destination pixel to source pixel
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Adjusting for non-straight glass?
Although command line is also an option for me.Moonsteel wrote:Perl.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Adjusting for non-straight glass?
The distort LUT method (or any -fx) method can be directly converted to a
perl form. basically you would follow the pixel handling methods.
A demo called "pixel_fx.pl" is in the latest IM PerlMagick demo sub-directory.
Other than that the technique is basically as given in the link above for the command line. You create two gray scale images, one for X and another for Y which maps destination coordinates to the right source image coordinates (with interpolation filtering).
A simple way to do this without needing maths, would be to take a photo of three items though the glass, a vertical gradient, a horizontal gradiant, and a perfect grey. The latter will correct the gradients to a proper black and white coordinate mappings. It would also let you correct the photo coloring.
With math you would just need to generate the LUT's directly.
Using an LUT means you only need to generate them once using complex maths to speedup processing a LOT of images. the alturnative is to do the coordinate maths for each and every coordinate for each and every image, instead of the LUT lookup.
Actually if you have a good example of this before/after and mapping images, I would love it as a final inclusion for that IM examples section.
perl form. basically you would follow the pixel handling methods.
A demo called "pixel_fx.pl" is in the latest IM PerlMagick demo sub-directory.
Other than that the technique is basically as given in the link above for the command line. You create two gray scale images, one for X and another for Y which maps destination coordinates to the right source image coordinates (with interpolation filtering).
A simple way to do this without needing maths, would be to take a photo of three items though the glass, a vertical gradient, a horizontal gradiant, and a perfect grey. The latter will correct the gradients to a proper black and white coordinate mappings. It would also let you correct the photo coloring.
With math you would just need to generate the LUT's directly.
Using an LUT means you only need to generate them once using complex maths to speedup processing a LOT of images. the alturnative is to do the coordinate maths for each and every coordinate for each and every image, instead of the LUT lookup.
Actually if you have a good example of this before/after and mapping images, I would love it as a final inclusion for that IM examples section.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/