Problems with Convert
Posted: 2010-01-16T09:42:54-07:00
I am using ImageMagick-6.5.8-Q16-windows-Portable-static on Win XP.
I have put files worked with at: http://www.kleinfeldtechnical.com/im for reference.
I created a small image with gray values, greyscale.gif, which ranges from a level of 94 to 255. It is used as the starting point for the testing I did. I ran various options, creating a .pgm file as well to examine the pixel values. The file testandnotes.txt has the history of my tests and notes. I used it as a .bat file, remarking out old commands as I tried new ones.
greyscale.gif
I am trying to rescale some scientific images in the long run.
I have tried some manipulations with convert (math function) and with convert (level functions).
Some of these worked as expected. Others would not work at all or gave unexpected results. Any help in guiding me to get these to work the way I think they should, or, more likely, changing my expectations would be appreciated.
Here's a summary of what I tried and where I am having trouble:
for convert math funciton : Multiply and Divide worked as expected, although limited by the 0-255 range available in the image. Add and Subtract did not work as expected. I used pure numbers in the Add and Subtract commands, not %numbers. The commands had no effect at all. Here is the code I used:
And here is a sample line of code I used to generate the .pgm files.
Do the Add and Subtract options on convert work? Do they require %number? If using a % is it of the range available (0-255) or of the range in the particular image (94-255 for mine) or does it relate to the histogram?
In reading further, I realized that the Convert -level function would be a better approach to rescaling the images I am planning on adjusting. I also am having similar problems getting this to work.
Here are the commands I tried, with the result I got following the command:
The last three tries above used 36.9% as the black_point. I derived this as 94/255, treating the % as related to the scale, not as related to the histogram or distribution of the pixels in the image. Is this the correct interpretation of the %?
All guidance is much appreciated.
JK
I have put files worked with at: http://www.kleinfeldtechnical.com/im for reference.
I created a small image with gray values, greyscale.gif, which ranges from a level of 94 to 255. It is used as the starting point for the testing I did. I ran various options, creating a .pgm file as well to examine the pixel values. The file testandnotes.txt has the history of my tests and notes. I used it as a .bat file, remarking out old commands as I tried new ones.
greyscale.gif
I am trying to rescale some scientific images in the long run.
I have tried some manipulations with convert (math function) and with convert (level functions).
Some of these worked as expected. Others would not work at all or gave unexpected results. Any help in guiding me to get these to work the way I think they should, or, more likely, changing my expectations would be appreciated.
Here's a summary of what I tried and where I am having trouble:
for convert math funciton : Multiply and Divide worked as expected, although limited by the 0-255 range available in the image. Add and Subtract did not work as expected. I used pure numbers in the Add and Subtract commands, not %numbers. The commands had no effect at all. Here is the code I used:
Code: Select all
convert greyscale.gif -evaluate divide 2 gover2.gif
convert greyscale.gif -evaluate multiply 2 gtimes2.gif
convert greyscale.gif -evaluate add 25 gplus25.gif
convert greyscale.gif -evaluate subtract 50 gscale-min50.gif
Code: Select all
convert gscale-min50.gif -colorspace gray -compress none -depth 8 gscale-min50.pgm
In reading further, I realized that the Convert -level function would be a better approach to rescaling the images I am planning on adjusting. I also am having similar problems getting this to work.
Here are the commands I tried, with the result I got following the command:
Code: Select all
convert greyscale.gif -level 94,255 gscale-level94-255.gif --this creates an all white image (255)
convert greyscale.gif -level 100,255 gscale-level100-255.gif --this creates an all white image (255)
convert greyscale.gif -level 100 gscale-level100-def.gif -- this had no effect
convert greyscale.gif -level 50,255 gscale-level50-255.gif --this creates an all white image (255)
convert greyscale.gif -level 36.9% gscale-level36pct.gif -- this had no effect
convert greyscale.gif -level 36.9,100% gscale-level36-100pct.gif --this creates an all white image (255)
convert greyscale.gif -level 36.9%,100% gscale-level36pct-100pct.gif -- this had no effect
All guidance is much appreciated.
JK