Suggesting a floating point Q32 image format
Posted: 2007-09-09T18:22:45-07:00
Hello,
I have been doing image processing and scripting of image functions since 1978, but am relatively new to IM. I want to build more IM scripts (see my web page at http://www.fmwconcepts.com/imagemagick/index.html), but I find that although -fx can do a lot, it is still restrictive.
I would like to suggest that you implement a 32-bit image format (at least for grayscale images, but better if for truecolor, i.e. 32-bits per channel).
One of the problems that I have is doing image arithmetic - both single image and multiple image operations - and stringing them together to get some particular result. Your -evaluate is a start for single image operations, but it clips the data between each step. Thus doing something like a*u + b does not work in all cases and the result depends upon whether you do it that way or b + a*u, i.e. it is order dependent. I have tried implementing a simple script to do brightness and contrast adjustment in one step using slope and intercept and -evaluate cannot handle all the possible cases of slope and intercept without premature clipping. So I went to -fx to handle this, but is of course rather slow.
For single image operations with functions like you use in -fx (add, subtract, multiply, divide, ln, exp, sqrt, sin, cos, atan etc and polynomial) -evaluate would work fine if you could put multiple evalutes in a single command line, BUT not clip until the end. This could be done by having a floating point image type and not clipping for each evaluate and then add a new function that would use the min and max values from the floating point format and linearly scale them to 0 and Q for 8-bit or 16-bit results in order to convert the floating point format to normal 8 or 16 bit per channel.
If you had a floating point image format, then one could also do things to combine 2 images with functions like add (plus or minus weights), multiply, divide, pow, min, max, mod, etc, like you do in -fx. Some of these can be done now with -compose (plus, minus, multiply) -composite. But again you get clipping after each step.
Also, if you had a complex dataype image (real part and imaginary part, i.e. 64-bit), then you could consider doing Fourier transform processing so as to deblur images that suffer from lens defocus and motion blur and also do filtering such as noise removal in the frequency domain. Also doing image correlation matching is much easier in the fourier (frequency) domain. Of course new functions would need to be written to do many of these things. So I know this is much further in the future.
However, with the floating point image datatype, you have many of the required functions built in -fx and -evaluate could be expanded to more of these functions if it were modified so as not to clip after each operation if the datatype is float.
I hope you will consider this suggestion.
Thanks for listening
Fred Weinhaus
I have been doing image processing and scripting of image functions since 1978, but am relatively new to IM. I want to build more IM scripts (see my web page at http://www.fmwconcepts.com/imagemagick/index.html), but I find that although -fx can do a lot, it is still restrictive.
I would like to suggest that you implement a 32-bit image format (at least for grayscale images, but better if for truecolor, i.e. 32-bits per channel).
One of the problems that I have is doing image arithmetic - both single image and multiple image operations - and stringing them together to get some particular result. Your -evaluate is a start for single image operations, but it clips the data between each step. Thus doing something like a*u + b does not work in all cases and the result depends upon whether you do it that way or b + a*u, i.e. it is order dependent. I have tried implementing a simple script to do brightness and contrast adjustment in one step using slope and intercept and -evaluate cannot handle all the possible cases of slope and intercept without premature clipping. So I went to -fx to handle this, but is of course rather slow.
For single image operations with functions like you use in -fx (add, subtract, multiply, divide, ln, exp, sqrt, sin, cos, atan etc and polynomial) -evaluate would work fine if you could put multiple evalutes in a single command line, BUT not clip until the end. This could be done by having a floating point image type and not clipping for each evaluate and then add a new function that would use the min and max values from the floating point format and linearly scale them to 0 and Q for 8-bit or 16-bit results in order to convert the floating point format to normal 8 or 16 bit per channel.
If you had a floating point image format, then one could also do things to combine 2 images with functions like add (plus or minus weights), multiply, divide, pow, min, max, mod, etc, like you do in -fx. Some of these can be done now with -compose (plus, minus, multiply) -composite. But again you get clipping after each step.
Also, if you had a complex dataype image (real part and imaginary part, i.e. 64-bit), then you could consider doing Fourier transform processing so as to deblur images that suffer from lens defocus and motion blur and also do filtering such as noise removal in the frequency domain. Also doing image correlation matching is much easier in the fourier (frequency) domain. Of course new functions would need to be written to do many of these things. So I know this is much further in the future.
However, with the floating point image datatype, you have many of the required functions built in -fx and -evaluate could be expanded to more of these functions if it were modified so as not to clip after each operation if the datatype is float.
I hope you will consider this suggestion.
Thanks for listening
Fred Weinhaus