Hello,
lame question... how can I divide two images? Multiplying is simple (-compose multiply), but dividing? Maybe I can use -evaluate or -fx somehow to achieve it?
how can I divide two images?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Dividing is not a normal composition operation for images. Basically as it is not very simple to achieve any useful results.
What do you wnt to use divide using an image for? Can you give an example use?
What about the Alpha channel? Always a problem with mathematical operators.
In the mean time you can do it with -fx
Note this is with all colors in the 0.0 to 1.0 range and as such the image will always be 'brightened' and often brightened until it is clipped at the 'max' limits. For any useful result the source, second, or 'v' image will need to be mostly white.
The -evaluate operator only applys a fixed constant to ALL images in the current image sequence. Results are of course clipped to the 0.0 to 1.0 bounds. For example make an image half transparent
That is useful!
What do you wnt to use divide using an image for? Can you give an example use?
What about the Alpha channel? Always a problem with mathematical operators.
In the mean time you can do it with -fx
Code: Select all
convert dest.png src.png -fx 'u/v' result.png
The -evaluate operator only applys a fixed constant to ALL images in the current image sequence. Results are of course clipped to the 0.0 to 1.0 bounds. For example make an image half transparent
Code: Select all
-channel A -evaluate divide 2
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Thanks!
Thanks! It seems to be what I need! I will only have to tweak it a bit, probably add some coeficient, maybe add some normalize option. I need it cause I want to automate postprocessing of photographed books, which now I do like that:
http://sobolewscy.in5.pl/piotr/grafika/ ... e_ksiazek/
Thanks a lot!
http://sobolewscy.in5.pl/piotr/grafika/ ... e_ksiazek/
Thanks a lot!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Hmmm. Very interesting link, perhaps a -compose divide should be provided.
In the mean time this is not too slow
convert mini_00.jpg \( +clone -blur 0x8 \) -fx 'u/v' x:
I would also consider starting by normalizing the image, then adjusting the greyscale histogram to appropriate levels BEFORE dividing, so that the image colors do not get clipped by the division. Especially watch out for a 'division by zero' fault, though that is unlikely due to the blur.
I would finally look at a related example for removing vignettation effects from a photo.
http://www.cit.gu.edu.au/~anthony/graph ... gnettation
This also happens to be a 'divide function'
In the mean time this is not too slow
convert mini_00.jpg \( +clone -blur 0x8 \) -fx 'u/v' x:
I would also consider starting by normalizing the image, then adjusting the greyscale histogram to appropriate levels BEFORE dividing, so that the image colors do not get clipped by the division. Especially watch out for a 'division by zero' fault, though that is unlikely due to the blur.
I would finally look at a related example for removing vignettation effects from a photo.
http://www.cit.gu.edu.au/~anthony/graph ... gnettation
This also happens to be a 'divide function'
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/