Page 1 of 1
Images to overlayed layers
Posted: 2010-05-31T15:56:42-07:00
by biostech
Hi, I'm pretty new to imagemagick but i would like to have this:
In Gimp, i import the two images as layers and then i apply screen method to the first one.
I have to do this often now.
Is it possible to manage this process in ImageMagick?
thanks in advance
Re: Images to overlayed layers
Posted: 2010-05-31T16:02:12-07:00
by magick
Post a URL to your blue and red images. We need to download them to verify our solution works properly before we post it.
Re: Images to overlayed layers
Posted: 2010-06-01T02:44:50-07:00
by biostech
Here some example images:
Layer 1
http://img171.imageshack.us/img171/9655/tntb.jpg
Layer 2
http://img412.imageshack.us/img412/6971/tntrg.jpg
Overlay result with screen
http://img25.imageshack.us/img25/9655/tntb.jpg
In some cases the layers could be 3 so the screen mode shoul be applied both to the 2 upper layers.
Re: Images to overlayed layers
Posted: 2010-06-01T20:30:30-07:00
by anthony
Screen is applied between images not too images.
Also you can swap images being 'screen'ed without change.
Code: Select all
convert image1 image2 -compose Screen -composite \
image3 -composite \
result
Of as screen does not do anything with black you can use flatten...
Code: Select all
convert image1 image2 image3 -background black -compose screen -flatten result
Question are the images just differenet channels. If so you can channel copy them together too!
Re: Images to overlayed layers
Posted: 2010-06-02T10:59:07-07:00
by biostech
Hi Antony,
I can't understand very well what you are explaining me but both codes seem to take the desided effect!
So, thanks!!
(In the 2nd I have "convert: unable to access configure file `colors.xml' @ configure.c/GetConfigureOptions/589.
logout" but it can be configuration of IM installed with MacTex. The result is fine anyway.)
I'm writing the first one as bash scripts:
Complete layers
Code: Select all
#!/bin/bash
#
cd $(dirname $0)
convert *_A.jpg *_I3.jpg -compose Screen -composite \
*_N21.jpg -composite \
merge.jpg
exit 0
Usually the three images end with _A _I3 and _N21 which are the filters through the same sample is viewed.
In addition, i need to add a thick white bar at the bottom-right as a lenght indicator and hide the original thinner scale-bar.
I add a bar.png file as a white line in black background to fully cover the original bar.
2 layers with bar:
Code: Select all
#!/bin/bash
#
cd $(dirname $0)
convert *_A.jpg *_I3.jpg -compose Screen -composite \
bar.png -gravity Southeast -composite \
merge.jpg
the black region doesn't seem to cover anyway..
What's wrong?
Re: Images to overlayed layers
Posted: 2010-06-02T21:02:38-07:00
by anthony
Not quite sure what you mean from the last example. Do you have images?
However note that -composite only composes two images with a optional third masking image.
It does not work for more than two images at a time.
The -flatten however does work to merge multiple images. The only problem is that it requires an initial color canvas which it creates using the -background color.
I will look at expanding -evaluate-sequence to allow -flatten type compose operations but without needing an initial canvas (assumes all images are the same size).
The color.xml bug is a configuration option. IM did nto find that file which it uses to figure out what a color name like "black" actually means in terms of RGB values. You can down load from from sources and install into an appropriate directory. On my system (linux) that is in...
/usr/share/ImageMagick-6.6.2/config/colors.xml
You can also install it in a personal ~/.magick sub-directory too.
Re: Images to overlayed layers
Posted: 2010-06-03T02:42:32-07:00
by biostech
Ok let's make a sum:
Layers could be up to 3 and have the same dimensions. There's always a file_A which has to be overlayed with file_I3.jpg or file_N21.jpg or both them.
Layers:
File_A.jpg
http://img171.imageshack.us/img171/9655/tntb.jpg
FILE_I3.jpg
http://img193.imageshack.us/img193/6885/tnti3.jpg
File_N21.jpg
http://img412.imageshack.us/img412/6971/tntrg.jpg
I created 3 scripts corresponding to the 3 possible combination 1+2 1+3 1+2+3.
Full example in my previous message: result
http://img203.imageshack.us/img203/8995/merge.jpg
Now i want to hide the thin scalebar in right-bottom corner and overwrite with o thicker straight line like this one
http://img25.imageshack.us/img25/5205/barraxo.png
My latest code doesn't work because the black area of bar.png didn't cover the previous scalebar see here
http://img138.imageshack.us/img138/8686/85987719.jpg
I tried to modify it like this and works (maybe there was a simpler way):
Code: Select all
cd $(dirname $0)
convert *_A.jpg *_I3.jpg -compose Screen -composite \
*_N21.jpg -composite \
merge.jpg
convert merge.jpg barra.png -gravity Southeast -composite merge.jpg
exit
That's the result i wanted
http://img541.imageshack.us/img541/2258/mergel.jpg .
Re: Images to overlayed layers
Posted: 2010-06-03T20:55:47-07:00
by anthony
The images aprear to be purely separate Red/Green/Blur composites. that could be merged together.
Code: Select all
convert tntb.jpg tnti3.jpg -compose CopyGreen -composite \
tntrg.jpg -compose CopyRed -composite result.jpg
Though there seems to be some extra elements in other channels.
Hmmm rather than 'screen' 'Plus may work better...
convert tntb.jpg tnti3.jpg tntrg.jpg -background black -compose Plus -flatten result.jpg
As for the 'scale' at the bottom. why not just draw over it with a black rectangle!
Re: Images to overlayed layers
Posted: 2010-06-29T06:05:06-07:00
by Ntoriuscpm
I feel really silly asking this, but every time I try to implement an example it ends up not working...
From the PC command line, every time I try to string multiple commands together the "\" in all examples creates an error. I thought maybe it was a hard return, but I need all my logic to fire off at once. I'm trying to overlay a couple images, but would like to resize 1 image, so I need a way to break up my script. HELP! I know this is basic stuff, but I couldn't find a dummies guide to what this "\" meant.
Re: Images to overlayed layers
Posted: 2010-06-29T06:32:55-07:00
by snibgo
Backslash "\" in Unix means (a) the shell should treat the next character literally without interpreting it, or (b) when it is the final character on the line, the command continues on the next line.
The Windows equivalent is caret "^".
See also
http://www.imagemagick.org/Usage/windows/