It is currently Sat Aug 15, 2026 11:23 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Using BIMP to auto overlay pairs of images
PostPosted: Thu May 23, 2013 8:08 am  (#1) 
Offline
GimpChat Member

Joined: May 23, 2013
Posts: 10
I would like to use the BIMP plugin* to overlay my (hundreds of!) images in the following way. My images are named in this fashion:

Blah blah 1 - A.tif
Blah blah 1 - B.tif
Blah blah 2 - A.tif
Blah blah 2 - B.tif
Blah blah 3 - A.tif
Blah blah 3 - B.tif

I would like to create the files:

Blah blah 1 - C.tif
Blah blah 2 - C.tif
Blah blah 3 - C.tif

by overlaying image A on B using the 'Divide' image option.

The BIMP plugin is utilised via File > Batch Image Manipulation. Then, in the 'Manipulation Set' section, I click 'Add' and select 'Other GIMP procedure'. None of the many procedures contain the string 'overlay' or 'divide'. Can I procede with BIMP or doesn't it do what I'd like to do? Would writing a Fu-Script be trivial (I've never programmed a computer before, apart from once when I made a turtle move around a screen in some laughable school IT exercise).

Thanks a batch.

Edit: apparently my "post looks too spamy for a new user, [please remove off-site URLs]" so, I'm going to try and phase this link through the SPAM shield, because my post is clearly not SPAM of any sort.
*w WOAH, NELLY! ww.alessandrofrancesconi.it/projects/bimp/


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Thu May 23, 2013 10:11 am  (#2) 
Offline
GimpChat Member

Joined: May 23, 2013
Posts: 10
Thanks. I copied my query over, but given that there are only 10 threads and some have been unanswered for over a year, my expectations aren't too high :(


Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Thu May 23, 2013 11:02 am  (#3) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2612
I am not saying that it is impossible with BIMP but really that plugin is meant for single images.

The author does respond and quickly, I reported a bug once and it was acted on straight away. For various (linux) reasons I am stuck in a time warp on version 0.5 so maybe latest will do what you want.

I would say for batch processing ImageMagick would be a better bet

convert image01.tiff image02.tiff -compose Divide -composite out.tif


is equivalent to two layers with the top in divide mode.

example (helps if the 2 images are the same size)

http://i.imgur.com/54oTiSO.jpg

Top is gimp with the top layer mode = divide
and the bottom is IM applied to the same images

Obviously you would need a batch/bash file depending on OS. Worth asking at the IM forum


Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Thu May 23, 2013 11:30 am  (#4) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Or you could use a bespoke script...

(define (sg-batch-merge-divide directory centered)
  (let loop ((filelist (cadr (file-glob (string-append directory
                                                       DIR-SEPARATOR
                                                       "*A.tif")
                                        1 ))))
    (unless (null? filelist)
      (let* ((filename-a (car filelist))
             (filename-b (string-append (car (strbreakup filename-a "A.tif")) "B.tif"))
             (image-a (car (gimp-file-load RUN-NONINTERACTIVE
                                           filename-a filename-a)))
             (image-b (catch #f (car (gimp-file-load RUN-NONINTERACTIVE filename-b filename-b))))
             (layer-a (car (gimp-image-get-active-layer image-a)))
             (layer-b (if image-b
                             (car (gimp-image-get-active-layer image-b))
                             #f )))
        (if layer-b
          (let ((layer (car (gimp-layer-new-from-drawable layer-a image-b))))
            (gimp-image-add-layer image-b layer 0)
            (gimp-layer-set-mode layer DIVIDE-MODE)
            (unless (zero? centered)
              (gimp-layer-set-offsets layer (- (/ (car (gimp-image-width image-b)) 2)
                                               (/ (car (gimp-drawable-width layer)) 2))
                                            (- (/ (car (gimp-image-height image-b)) 2)
                                               (/ (car (gimp-drawable-height layer)) 2)) ))
            (set! layer (car (gimp-image-merge-down image-b layer EXPAND-AS-NECESSARY)))
            (let ((filename-c (string-append (car (strbreakup filename-a "A.tif")) "C.tif")))
              (gimp-file-save RUN-NONINTERACTIVE image-a layer filename-c filename-c) )
            (gimp-image-delete image-b) ))
        (gimp-image-delete image-a) )
      (loop (cdr filelist)) )))
     
(script-fu-register "sg-batch-merge-divide"
  "Merge TIF files per THX1138"
  "Merge the layers from two files in DIVIDE mode"
  "Saul Goode"
  "Saul Goode"
  "May 2013"
  ""
  SF-DIRNAME "Directory"    ""
  SF-TOGGLE "Centered" TRUE
  )
(script-fu-menu-register "sg-batch-merge-divide"
  "<Image>/File/"
  )


EDITED because I originally had B atop A.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Fri May 24, 2013 7:35 am  (#5) 
Offline
GimpChat Member

Joined: May 23, 2013
Posts: 10
Hi everyone, thanks for your replies.

I think I'll probably end up using ImageMagick but what about that script?; I saved it in C:\Users\Sean\.gimp-2.8\scripts as 'Auto Merge Divide.scm'. Should it appear in the GIMP filters menu?


Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Fri May 24, 2013 8:09 am  (#6) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
THX1138 wrote:
I think I'll probably end up using ImageMagick but what about that script?; I saved it in C:\Users\Sean\.gimp-2.8\scripts as 'Auto Merge Divide.scm'. Should it appear in the GIMP filters menu?

It should appear as the command "Merge TIF files per THX1138" at the bottom of your File menu. It has only two options. You can choose whether the top image is centered relative to the bottom image (which does not matter if the two images are the same size). And you can choose the directory containing the TIF files.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Fri May 24, 2013 8:37 pm  (#7) 
Offline
GimpChat Member

Joined: May 23, 2013
Posts: 10
How does it know which files to merge and what to name them afterwards? The reality is a lot more complicated than the problem as I introduced it :(


My file names are things like:

Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - Brightfield - Field 1 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - UV green - Field 1 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - UV red - Field 1 - 2012-05-23.tif

Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - Brightfield - Field 2 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - UV green - Field 2 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - UV red - Field 2 - 2012-05-23.tif

Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - Brightfield - Field 3 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - UV green - Field 3 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - UV red - Field 3 - 2012-05-23.tif

Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - Brightfield - Field 1 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - UV green - Field 1 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - UV red - Field 1 - 2012-05-23.tif

Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - Brightfield - Field 2 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - UV green - Field 2 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - UV red - Field 2 - 2012-05-23.tif

Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - Brightfield - Field 3 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - UV green - Field 3 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - UV red - Field 3 - 2012-05-23.tif

The outputs would be:

Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - Merged B-G - Field 1 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - Merged B-R - Field 1 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - Merged B-G - Field 2 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - Merged B-R - Field 2 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - Merged B-G - Field 3 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - With Antibiotic - Sample 1 - Merged B-R - Field 3 - 2012-05-23.tif

Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - Merged B-G - Field 1 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - Merged B-R - Field 1 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - Merged B-G - Field 2 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - Merged B-R - Field 2 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - Merged B-G - Field 3 - 2012-05-23.tif
Exp.SS.4.4.167 - DF1 cells - Without Antibiotic - Sample 1 - Merged B-R - Field 3 - 2012-05-23.tif



Is that easy to do with a script? The filenames are basically WILDCARD - Brightfield - WILDCARD, WILDCARD - UV green - WILDCARD, and WILDCARD - UV red - WILDCARD?


Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Sat May 25, 2013 12:28 am  (#8) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Could you download and try the updated script at the location below?

http://chiselapp.com/user/saulgoode/rep ... dc193c91f8

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Thu May 30, 2013 9:32 am  (#9) 
Offline
GimpChat Member

Joined: May 23, 2013
Posts: 10
Hi, I get the following error when I try to run the script on a folder:

Edit, as a new user, I'm not permitted to post images. I will try to circumvent this with cunning:
i.imgur.co m/JlQalU9.jpg

Incidentally, I've found that I prefer the result of using 'overlay' with the brightfield image as the bottom layer.

I'm not sure if this is the cause of the error but it's worth noting that in this case I didn't have any "UV green" images. Some times it's the other way around, and sometimes I do have both.


Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Thu May 30, 2013 3:07 pm  (#10) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Here is a screenshot of the error message (for any lookie-lous in the audience):
Image

I don't understand this. The only line using "DIVIDE-MODE" has it in all caps.
(gimp-layer-set-mode sample-layer DIVIDE-MODE)


Did you perchance do a search and replace on the file (while trying different modes)? If so, make sure that the chosen -MODE is in all capital letters.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Thu May 30, 2013 4:30 pm  (#11) 
Offline
GimpChat Member

Joined: May 23, 2013
Posts: 10
lol, I totally did that man; I messed with the code! Sorry! I'll try this again tomorrow!

Edit: Hi Saul. The script works great but it does produce errors for some reason (that don't seem to interfere with the process). The error says "C: cannot open" and repeats for every image set in the targeted folder. Is it relevant that I'm using Win 7?

Image


Last edited by THX1138 on Thu Sep 26, 2013 9:09 am, edited 4 times in total.

Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Wed Sep 11, 2013 10:29 am  (#12) 
Offline
GimpChat Member

Joined: May 23, 2013
Posts: 10
bump


Top
 Post subject: Re: Using BIMP to auto overlay pairs of images
PostPosted: Thu Sep 26, 2013 9:06 am  (#13) 
Offline
GimpChat Member

Joined: May 23, 2013
Posts: 10
It also seems to fail if the images are on my D: partition instead of C:

I get this error:

Image

and the script halts. If I copy and paste the images to my desktop then it works (except Windows won't move all the files across because it makes the file path too long).

Does anyone else know how to fix the script that Saul made for me?


Top
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours [ DST ]


cron

* Login  



Powered by phpBB3 © phpBB Group