Page 1 of 1

Script for batch correction Underwater submarine pictures

Posted: 2010-01-13T14:28:58-07:00
by xaser
Hello!
I would like to make a script in order to batch process a large group of underwater pics, and would like ask for help

I would like to ask if somebody may make a traslation of the steps in the method of this page:

http://www.scubaboard.com/forums/digita ... ethod.html

I would be very gratefull if may be provided the form of a line of commands in a way that ImageMagick may could do the same process to the target pic.

Also have these other link pages about the same picture process method if may help with the request.

http://www.scubaboard.com/forums/tips-t ... robes.html

http://www.tankedup-imaging.com/red_enhance1.html

Thanks for attention , and would be very gratefull for help, since I would like to use imagemagick since it is far fast in my computer, and as I may see it is very powerfull so I suspect that the steps of the method may be don in a line on imagemagick syntax.

Thanks again and best regards!

Re: Script for batch correction Underwater submarine pictures

Posted: 2010-01-13T19:35:04-07:00
by fmw42
Here is the best method I have developed so far (from quite a few that I have tried).

Your example with original on left and PS processing on right.

Image

My processing steps on the left hand image:

convert \( underwater.jpg -auto-level \) \
\( +clone -colorspace gray -fill red -tint 50 \) \
-compose screen -composite -channel rgb -auto-level -modulate 100,120,80 -sharpen 0x3 \
underwater_tintr50_screen_alrgb_ms120h80_s0x3.jpg

Image

First line auto-levels all channels together. Second line converts copy of image to grayscale and tints midgray to red. Third line does a screen composite, then auto-levels each channel separately, then adjusts the saturation (120) and hue (80) using -modulate. (note the hue change of 20=100-80 is equivalent to 36 degrees shift which is similar to 33 degrees mentioned in one of the references).

See -modulate http://www.imagemagick.org/script/comma ... p#modulate

I am not sure how robust this method is with only one example. But you can play with the saturation and hue for other images if needed.

I suspect the original (thumbnails) above came from much larger and sharper images. But you can adjust the sharpness further if you want.


This method (which is probably closer to the Photoshop scheme) also works but not quite as good for this picture.

convert \( underwater.jpg -auto-level \) \
\( -clone 0 -colorspace gray \) \
\( -clone 0 -fill red -colorize 100 \) \
\( -clone 1 -clone 2 -compose multiply -composite \) -delete 1,2 \
-compose screen -composite -channel rgb -auto-level -modulate 100,120,80 -sharpen 0x3 \
underwater_rcolorize_screen_alrgb_m100x120x80_s0x3.jpg

Image

However, it works better than the first method for this image without any modulation (hue shift) or sharpening (but it can be added as above):

original:
Image

PS processed (see http://www.divester.com/2005/03/08/how- ... photoshop/ )
Image

convert \( coral_orig.jpg -auto-level -write coral_al.jpg \) \
\( -clone 0 -colorspace gray -write coral_tmpg.png \) \
\( -clone 0 -fill red -colorize 100 \) \
\( -clone 1 -clone 2 -compose multiply -composite -write coral_multred.png \) -delete 1,2 \
-compose screen -composite -channel rgb -auto-level \
coral_rcolorize_screen_alrgb.jpg

Image

Adding a little saturation boost it is a bit closer:

convert \( coral_orig.jpg -auto-level \) \
\( -clone 0 -colorspace gray \) \
\( -clone 0 -fill red -colorize 100 \) \
\( -clone 1 -clone 2 -compose multiply -composite \) -delete 1,2 \
-compose screen -composite -channel rgb -auto-level -modulate 100,130,100 \
coral_rcolorize_screen_alrgb_m100x130x100.jpg

Image

And this produces the same results as above, but is shorter:

convert \( coral_orig.jpg -auto-level \) \
\( +clone -colorspace gray +level-colors black,red \) \
-compose screen -composite -channel rgb -auto-level -modulate 100,130,100 \
coral_lcbr_screen_alrgb_m100x130x100.jpg

Re: Script for batch correction Underwater submarine pictures

Posted: 2010-01-14T17:59:36-07:00
by fmw42
I have created a bash unix script to perform these techniques. It is called uwcorrect (under water correct). It is available at my web site linked below.

Re: Script for batch correction Underwater submarine pictures

Posted: 2010-01-17T06:34:58-07:00
by xaser
Hello!

Well, first of all thank You really very much for take time for so good answers.

I really appreciates that, and the examples are Great, since are too many others posts based on others diferent topics, but these are very welcome because I could learn about how to use the various layers process and because they are linked with the page with the step by step process, is very informative to study the examples.

Also, Fred, Thank You really much for Your great site, previous my question, I was using Your scripts for my process, but since I would like to use some example for the multi file copyright and process, I ended using a script to calling some of Yours, so I was looking for make my own script in more compact way.

Your great examples are excelent for that, and by now I am trying to getting the last IM version compiled on Ubuntu Karmic, since is what I use, but the old version that came with Karmic seems that not include the -autolevel option and my first compiling try gets me some errors, and I suspect that I meesed some others things in my machine. :-P

Thanks again and best regards!

Pura Vida from Costa Rica!

Re: Script for batch correction Underwater submarine pictures

Posted: 2010-01-17T13:17:18-07:00
by fmw42
auto-levels is relatively new. But I wrote a script to do that before it was developed. It basically computes the min and max stats from

min=`convert image -format "%[min]" info:` etc and then feeds those variables to -level ${min}x${max}

so you can substitute something like that or use/convert my script