-1

I have two separate folders with equal number of images from microscopy (134 images in each folder). These are two different dyes for a specific cells. What i want to do is merging each image from one folder with its corresponding image from another folder i.e. first image of the folder a with first image of folder b and so on. i have been trying to do this work, but since each image has a different name, i can not finish this job successfully by Batch processing. Can anyone help? Thnkas

I need to merge channels from the two images on the left to get the image on the right by using ImageJ --> Image --> Color --> Merge channels Using C1 (red) and C3 (blue) in the settings. [1]: https://i.stack.imgur.com/OUKkg.jpg

Anderson
  • 3
  • 4
  • Are they colour or greyscale images? What do you mean by *"merge"*? Will the two images be side-by-side after merging? Or above and below? Or will you take the brighter of the two images at each point? Or the blended average? Or will you use one as the red and the other as the blue channel? What OS do you use? – Mark Setchell Aug 05 '20 at 18:46
  • "merge" as Image --> Color --> Merge Channels C1 (color red) is coming from folder B and C3 (color blue) is coming from folder B. I do not have any other color (not using any other channel). I am using Windows. – Anderson Aug 05 '20 at 19:38
  • If **ImageMagick** is an acceptable tool, I can most likely get you to a solution. Are all the images the same size - please supply a pair of images and the expected result. – Mark Setchell Aug 06 '20 at 08:01
  • All the images have the same size. They are produced in an automated microscopy process. So, there is no human error. I am not sure how to post an image in the comment. Since the images can not be searched for, we are required to only leave comments. – Anderson Aug 06 '20 at 10:21
  • Click `edit` under your question and add images there. Or if you cannot, add instead a link to Dropbox or Google Drive with the images. – Mark Setchell Aug 06 '20 at 10:23
  • Come on! After assuring me they are all the same size, you've now provided only 80% of the second channel, followed by the first channel and most of the result all merged into a single amorphous glob! How do you imagine I am going to use this to help you merge two images? If you want to merge two images into one, you need to provide 2 complete, separate images and one complete example of the result. Thank you. – Mark Setchell Aug 06 '20 at 17:00

1 Answers1

1

As you didn't raise any objection to my suggestion of using ImageMagick, I will show you how to do it using that.

As you didn't provide any images, let's assume you have two directories called A and B with PNG files in A that you want to use as the red channel and PNG files in B that you want to use as the blue channel. I'll assume you want a zero/blank green channel.

./A/image1.png
./A/image2.png
./B/image1.png
./B/image2.png

Now, go into A and the basic command for one file is:

cd A
magick image1.png ( +clone -fx 0 ) ../B/image1.png -combine result.png

That says... "load image1.png, make a copy of it and fill the copy with zeroes, load ../B/image1.png and combine them assuming the first is red, the second is green and the third is blue, and save them as result.png".

Hopefully you can get that working. If it does what you want, we can work on a batch version. I don't use Windows, so I would write this on Linux:

#!/bin/bash

for f in *png ; do
   echo "Combining $f (as Red), zero (as Green) and ../B/$f (as Blue) to make res-$f"
   magick $f \( +clone -fx 0 \) ../B/$f -combine res-$f
done

I know a dangerously small amount of Windows BATCH script, so I'll do my best to guess how it will look. Save it as GO.BAT:

FOR %%G IN (*.png) DO (
ECHO %%G
magick %%G ( +clone -fx 0 ) ../B/%%G -combine res-%%G
)

If I load your "image" into Photoshop and cut out the salient parts and trim the 112 pixels off the second image to make it the same size as the first and then reverse the order and combine them using the commands suggested, I get:

enter image description here

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432