image processing - Changing exposure of jpeg -


given jpeg, formula change exposure of jpeg +/-1 stop or known 1 ev? want simulate exposure change. there formula/ method so?

i can demonstrate using imagemagick, included in linux distros , available osx , windows here.

first, @ terminal command line create image:

convert -size 512x512 gradient:black-yellow gradient.png 

enter image description here

now, way effect +1 stop exposure increase composite image using screen blending mode - available in photoshop , imagemagick , described here.

so, formula composite image a image b is:

1-stop brighter image = 1-(1-a)(1-b) 

but compositing image itself, a , b same, have

1-(1-a)(1-a) 

imagemagick refers pixels of image using p rather a, can 1-stop increase this:

convert gradient.png -colorspace rgb -fx "(1-(1-p)(1-p))" result.png 

note wikipedia article, , imagemagick's -fx both assume pixel intensities vary between 0 , 1.0. if using 8-bit images, should calculate 255 in place of 1, namely

+1 stop brighter image = 255-(255-a)(255-a) 

or if using 16-bit values

+1 stop brighter image = 65535-(65535-a)(65535-a) 

the above fx-based method however, slow because -fx interpreted rather compiled, faster way is:

convert gradient.png gradient.png -colorspace rgb -compose screen -composite screen.png 

just fun, way of looking @ take inverse of a, 1-a, , square it, , take inverse, can done this:

convert gradient.png -colorspace rgb -negate -evaluate pow 2 -negate result.png 

enter image description here

the equivalent of -1 stop exposure decrease composite image using multiply blend mode, formula being

1-stop darker image = x b 

which faster with

convert gradient.png gradient.png -colorspace rgb -compose multiply -composite result.png 

or faster, using memory-to-memory cloning rather reading disk twice, with

convert gradient.png -colorspace rgb +clone -compose multiply -composite result.png 

but equally with

convert gradient.png -colorspace rgb -evaluate pow 2 result.png 

enter image description here


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -