Approve the Cookies
This website uses cookies to improve your user experience. By using this site, you agree to our use of cookies and our Privacy Policy.
OK
Forums  •   • New posts  •   • RTAT  •   • 'Best of'  •   • Gallery  •   • Gear
Guest
Forums  •   • New posts  •   • RTAT  •   • 'Best of'  •   • Gallery  •   • Gear
Register to forums    Log in

 
FORUMS Post Processing, Marketing & Presenting Photos RAW, Post Processing & Printing 
Thread started 06 Jan 2016 (Wednesday) 15:32
Search threadPrev/next
sponsored links (only for non-logged)

help me photomerge SEM photos to eliminate a brightness gradient

 
Kent ­ Clark
Senior Member
359 posts
Likes: 9
Joined Sep 2007
Post edited over 7 years ago by Kent Clark.
     
Jan 06, 2016 15:32 |  #1

I use a scanning electron microscope at work. I frequently take overlapping photos that I merge into a larger photo using CS4. At low magnification the electron beam is not completely uniform over the entire photo. This means that one side of the photo is slightly brighter than the other side. In a single photo this is barely noticeable unless you look carefully. I sometimes have to merge 6-12 photos into a linear array. But what happens is that the slight brightness gradient in each single photo is magnified during the merge so that the array ends up being very overexposed on one side and very underexposed on the opposite side. If I try and correct the resulting array with a gradient it ends up blotchy and variable. So I've been taking each individual photo, opening it in ACR, applying a slight gradient and then merging the resulting photos. This takes a lot of time but it is the best solution I've been able to find.

If I unclick the blend option in the photomerge window I just get a very mosaicy looking array that looks like a patchwork quilt instead of a single photo. Is there a way to correct this in the photomerge process? Another way that I can save some time?




  
  LOG IN TO REPLY
kirkt
Cream of the Crop
6,600 posts
Gallery: 5 photos
Likes: 1548
Joined Feb 2008
Location: Philadelphia, PA USA
     
Jan 06, 2016 16:20 |  #2

Do you have a sample image set that we can take a look at? Are you wed to using CS4 or are you open to using dedicated pano stitching/blending/mos​aic software? Also, for pre-conditioning of the images (to remove the gradient) you may have success with ImageJ/Fiji.

Kirk


Kirk
---
images: http://kirkt.smugmug.c​om (external link)

  
  LOG IN TO REPLY
BigAl007
Cream of the Crop
Avatar
8,118 posts
Gallery: 556 photos
Best ofs: 1
Likes: 1681
Joined Dec 2010
Location: Repps cum Bastwick, Gt Yarmouth, Norfolk, UK.
     
Jan 06, 2016 17:38 |  #3

Assuming that the gradient across the image is constant for every frame, could you not save the gradient that you have to apply as a preset, and then just apply it in bulk. If the gradient varies between sessions, but is constant throughout the session then you could open all of the images from one session in ACR and apply the gradient filter on the top image, where you can adjust it, and it will also be applied automatically to all of the other images. If the gradient error is different on every single "exposure" then I really see no other way than to make manual adjustments to every image.

Alan


alanevans.co.uk (external link)

  
  LOG IN TO REPLY
Kent ­ Clark
THREAD ­ STARTER
Senior Member
359 posts
Likes: 9
Joined Sep 2007
     
Jan 07, 2016 11:36 |  #4

Unfortunately, I don't think I should post some examples on a public forum, this is mostly R&D with nondisclosures, etc. But I appreciate the responses. kirkt, right now I have CS4, I could investigate other software but buying it is a hassle, big corp bureaucracy and all that. I'd never heard about Fiji before, I'll look into it. BigAl, thanks for the comments about presets and bulk applications of a setting. The degree of light variation usually changes from one job to another but the series of photos within a job usually show the same variation.




  
  LOG IN TO REPLY
kirkt
Cream of the Crop
6,600 posts
Gallery: 5 photos
Likes: 1548
Joined Feb 2008
Location: Philadelphia, PA USA
Post edited over 7 years ago by kirkt. (2 edits in all)
     
Jan 07, 2016 13:34 as a reply to  @ Kent Clark's post |  #5

Usually, this kind of issue is handled (in whatever specific application or workflow) by compensating for uneven lighting with a "flat field" frame (google "flat field illumination correction"). A flat field image may be a shot of a uniform wall or a shot taken through a translucent, neutral filter placed in front of the lens (for example, to make a LCC image for Capture One automatic correction of such issues). I asked if you could post an example so I could see the scale of the problem relative to the scale of the structures in the image - I understand your limitation in doing so, no worries. I can imagine that trying to find a flat, uniform surface to image at the SEM level is a lot more difficult than shooting an image of a flat wall!

Another issue to consider is how you acquire and process your images - do you work in 32bit? Adding and subtracting light in 32bit (linear) files is fairly straightforward and it may be easier to work in 32bit mode to remove the uneven "illumination" or perform flat field correction.

As far as purchasing software, consider trying the following:

1) stitching: Hugin: http://hugin.sourcefor​ge.net (external link)
2) blending and stacking: enfuse and enblend: http://enblend.sourcef​orge.net (external link)
3) image processing: Fiji/ImageJ: http://fiji.sc/Fiji (external link)

All of these are free and well documented.

Good luck,

kirk


Kirk
---
images: http://kirkt.smugmug.c​om (external link)

  
  LOG IN TO REPLY
kirkt
Cream of the Crop
6,600 posts
Gallery: 5 photos
Likes: 1548
Joined Feb 2008
Location: Philadelphia, PA USA
     
Jan 07, 2016 13:38 |  #6

See also:

https://www.researchga​te.net …_what_do_you_do​_about_it2 (external link)

and not SEM, but a tutorial in brightfield correction with ImageJ:

http://imagejdocu.tudo​r.lu …in_brightfield_​microscopy (external link)

kirk


Kirk
---
images: http://kirkt.smugmug.c​om (external link)

  
  LOG IN TO REPLY
kirkt
Cream of the Crop
6,600 posts
Gallery: 5 photos
Likes: 1548
Joined Feb 2008
Location: Philadelphia, PA USA
     
Jan 07, 2016 14:50 |  #7

I contrived an example that, if close to your issues, may work for you. I am using PS for this approach. I did a Google image search for SEM images and picked one that had a relatively uniform flat field (at least in appearance) and a full range of tones - it was an 8bit, gray JPEG. I applied two "typical" kinds of uneven illumination

1) a radial gradient (like vignetting) with a skewed center - that is, the center of the vignetting is not aligned with the center of the image.
2) a linear gradient across the image.

For each of these scenarios, I used the original SEM image and applied a gradient from white to black on a layer above the original image and set this layer to "Multiply" blend mode. This creates an image with a "simulated" non-uniform illumination field.

The trick is to try to extract the gradient layer blindly from the image with the non-uniform illumination - that is, we assume that we have no a priori knowledge of the flat field non-uniform gradient.

For each non-uniformly illuminated image we can apply a gaussian blur of a high radius - the radius is obviously highly dependent on the scale of the non-uniform lighting compared to the size of various features within the image. The assumption that may allow this approach to work is that the non-uniform illumination field is low frequency compared to the frequency of the image features of the structures that you are interested in imaging.

Naturally, if the non-uniformity is based on multiplication we should consider trying to extract the gradient (via blurring) and then divide the image by the extracted gradient to reconstruct the original image. The key to this math working is to use 32bit, floating point images. Even if you use raw images from a camera and convert those to 16bit TIFFs, bring them into PS and then change their mode to 32bit, this will work. You jus want to be able to have floating point math do the calculations.

Currently working on a little tutorial. Will post it here.

kirk


Kirk
---
images: http://kirkt.smugmug.c​om (external link)

  
  LOG IN TO REPLY
kirkt
Cream of the Crop
6,600 posts
Gallery: 5 photos
Likes: 1548
Joined Feb 2008
Location: Philadelphia, PA USA
Post edited over 7 years ago by kirkt. (4 edits in all)
     
Jan 08, 2016 11:42 |  #8

Well, I think the operation is a lot easier, faster and more flexible in ImageJ and you can spend not a whole lot of time to automate it too.

The basic idea is to generate a pseudo-flat-field image by applying a large kernel Mean filter to the original image with the non-uniform lighting. The size of the Mean kernel (in pixels) will depend upon the size of your image and the size of the non-uniform lighting artifact (versus the size of your image features). I imagine that you can probably start to home in on a typical range of kernel size pretty quickly.

The workflow goes like this:

1) convert your input image (INPUT) to a 16bit TIFF.
2) open INPUT in ImageJ and make a duplicate of it (DUP)
3) Choose Process > Filters > Mean... in ImageJ and, checking the "Preview" box, work out your kernel radius in pixels.
4) Accept the choice and run the Mean filter on DUP to make the blurred, pseudo-flat-field image.
5) Use the Image Calculator (Process > Image Calculator) and process INPUT with DUP by dividing INPUT by DUP - make sure you enable 32bit output - to RESULT.
6) Convert RESULT to 16bit (Image > Type > 16-bit).
7) Save RESULT as a TIFF.

See attached screenshots (the banding is from compressing the screenshot, not the actual working images). You can write a macro in ImageJ to automate the process and then apply the macro to a folder of images using the "Process > Multiple Image Processor" menu item in ImageJ.

If you are working in microscopy and image processing, you should consider becoming proficient in ImageJ anyway, so here is your excuse! Hope this helps.

Kirk

IMAGE: https://photography-on-the.net/forum/images/hostedphotos_lq/2016/01/2/LQ_768720.jpg
Image hosted by forum (768720) © kirkt [SHARE LINK]
THIS IS A LOW QUALITY PREVIEW. Please log in to see the good quality stuff.

IMAGE: https://photography-on-the.net/forum/images/hostedphotos_lq/2016/01/2/LQ_768721.jpg
Image hosted by forum (768721) © kirkt [SHARE LINK]
THIS IS A LOW QUALITY PREVIEW. Please log in to see the good quality stuff.

Kirk
---
images: http://kirkt.smugmug.c​om (external link)

  
  LOG IN TO REPLY
kirkt
Cream of the Crop
6,600 posts
Gallery: 5 photos
Likes: 1548
Joined Feb 2008
Location: Philadelphia, PA USA
Post edited over 7 years ago by kirkt.
     
Jan 08, 2016 11:43 |  #9

Here are screenshots of the results for the linear and radial non-uniform lighting simulations, after division with the image calculator. Both results are from using the same kernel radius (300 pixels).

Kirk

IMAGE: https://photography-on-the.net/forum/images/hostedphotos_lq/2016/01/2/LQ_768722.jpg
Image hosted by forum (768722) © kirkt [SHARE LINK]
THIS IS A LOW QUALITY PREVIEW. Please log in to see the good quality stuff.

IMAGE: https://photography-on-the.net/forum/images/hostedphotos_lq/2016/01/2/LQ_768723.jpg
Image hosted by forum (768723) © kirkt [SHARE LINK]
THIS IS A LOW QUALITY PREVIEW. Please log in to see the good quality stuff.

Kirk
---
images: http://kirkt.smugmug.c​om (external link)

  
  LOG IN TO REPLY
kirkt
Cream of the Crop
6,600 posts
Gallery: 5 photos
Likes: 1548
Joined Feb 2008
Location: Philadelphia, PA USA
Post edited over 7 years ago by kirkt. (4 edits in all)
     
Jan 08, 2016 11:54 |  #10

You can also write/run a macro that will determine the pseudo-flat-field image for each image in your mosaic set and then AVERAGE or MEDIAN all of those images into a single master pseudo-flat-field image that you can apply to all of the mosaic images. This will get rid of image features that get caught in the Mean filtering and leave just the nice flat-field as the result.

You can also adjust the intensity of the pseudo-flat-field image prior to dividing it into the INPUT if you want to match maximum intensities across images - this way the "white" of your INPUT will be the same as your "white" of the flat-field and the overall intensity of the corrected image will not change compared to the original. I did not do this in the above examples, and you may be able to see the subtle intensity shift in the corrected image when compared to the INPUT image.

Final note: you really need to work in 32bit to make all of this work correctly and cleanly. There is nothing hard about this, but just be aware that the math relies on linear light.

Kirk


Kirk
---
images: http://kirkt.smugmug.c​om (external link)

  
  LOG IN TO REPLY
Kent ­ Clark
THREAD ­ STARTER
Senior Member
359 posts
Likes: 9
Joined Sep 2007
     
Jan 11, 2016 13:29 as a reply to  @ kirkt's post |  #11

Wow, kirk, thanks for taking so much time with this. I'll have to take some time to work on it but the effort is really appreciated.




  
  LOG IN TO REPLY
kirkt
Cream of the Crop
6,600 posts
Gallery: 5 photos
Likes: 1548
Joined Feb 2008
Location: Philadelphia, PA USA
Post edited over 7 years ago by kirkt. (2 edits in all)
     
Jan 11, 2016 13:49 as a reply to  @ Kent Clark's post |  #12

You're welcome. You can also stitch in ImageJ:

http://fiji.sc/Image_S​titching (external link)

and

http://bigwww.epfl.ch/​thevenaz/mosaicj/ (external link)

(MosaicJ is a plug-in in ImageJ - under the Plug-Ins > Stitching menu).

Read up and see if you can get everything done in ImageJ, and automate it with the ImageJ macro language.

kirk


Kirk
---
images: http://kirkt.smugmug.c​om (external link)

  
  LOG IN TO REPLY
kirkt
Cream of the Crop
6,600 posts
Gallery: 5 photos
Likes: 1548
Joined Feb 2008
Location: Philadelphia, PA USA
Post edited over 7 years ago by kirkt.
     
Jan 11, 2016 14:19 |  #13

MosaicJ is pretty much exactly what you are looking for. It would be super sweet to be able to automate the entire process in ImageJ, simply by designating a folder of images that will make up the mosaic and letting the macro you write do all of the pre-processing (the pseudo-flat-field conditioning) and then sending the results to MosaicJ for stitching. All in 32bit.

Sweet.

Here is a PDF Reference Guide to the ImageJ macro language:

http://imagej.nih.gov …macro_reference​_guide.pdf (external link)

kirk


Kirk
---
images: http://kirkt.smugmug.c​om (external link)

  
  LOG IN TO REPLY
kirkt
Cream of the Crop
6,600 posts
Gallery: 5 photos
Likes: 1548
Joined Feb 2008
Location: Philadelphia, PA USA
Post edited over 7 years ago by kirkt. (2 edits in all)
     
Jan 11, 2016 15:41 |  #14

Here is a rough macro that performs the above exercise on a source image with the non-uniform illumination and adds a bit of local contrast enhancement to boot! The Mean kernel radius is hardcoded to be 300 pixels, but you can change that in the code or bring up a dialog window to change it. I also implemented the scaling of the pixel intensity for the pseudo flat field image so that the maximum pixel values in the two images match prior to division.

Cut and paste the macro test into a new macro in ImageJ and give it a try on one of your own images. You just need to make the source image active (click on it to bring it to the front of all of the images you have open) to run the macro on that image. You can comment out the local contrast step (it takes the longest to run out of all of the operations) by using a double slash // in front of the line of code.

kirk


macro "TEST" {
//activate source image to correct prior to running macro
titleName = getTitle();
titlePath = getDirectory("image");

//get the max pixel intensity for the source image
getStatistics(area, mean, min, max);
origMax = max;

//log window will display info about image FYI
print("\\Clear");
print("Image: "+titlePath+titleName)​;
print("min: "+min);
print("max: "+max);

//duplicate source image to make pseudo flat field image
run("Duplicate...", "title=DUP");
selectWindow("DUP");
//run Mean filter with a hardcoded kernel of 300 pixels - this can be changed here, or make a dialog
run("Mean...", "radius=300");
//get max pixel intensity in the psuedo flat field image, for determining scaling to match source
getStatistics(area, mean, min, max);
dupMax = max;

//info about DUP FYI
print("");
print("min2 :"+min);
print("max2: "+max);

//calculate scaling factor to match intensity of DUP to source
factor = origMax/dupMax;

//factor info FYI
print("");
print("Factor= "+factor);

//Multiply DUP by factor to scale pixel intensity to match source
run("Multiply...", "value=&factor");

//Divide source by the scaled pseudo flat field image to remove illumination artifact
imageCalculator("Divid​e create 32-bit",titleName,"DUP");

//Enhance local contrast on result using the CLAHE filter - you can comment this out to prevent it from running
selectWindow("Result of "+titleName);
run("Enhance Local Contrast (CLAHE)", "blocksize=127 histogram=1024 maximum=3 mask=*None*");

}

Kirk
---
images: http://kirkt.smugmug.c​om (external link)

  
  LOG IN TO REPLY
sponsored links (only for non-logged)

3,283 views & 1 like for this thread, 3 members have posted to it.
help me photomerge SEM photos to eliminate a brightness gradient
FORUMS Post Processing, Marketing & Presenting Photos RAW, Post Processing & Printing 
AAA
x 1600
y 1600

Jump to forum...   •  Rules   •  Forums   •  New posts   •  RTAT   •  'Best of'   •  Gallery   •  Gear   •  Reviews   •  Member list   •  Polls   •  Image rules   •  Search   •  Password reset   •  Home

Not a member yet?
Register to forums
Registered members may log in to forums and access all the features: full search, image upload, follow forums, own gear list and ratings, likes, more forums, private messaging, thread follow, notifications, own gallery, all settings, view hosted photos, own reviews, see more and do more... and all is free. Don't be a stranger - register now and start posting!


COOKIES DISCLAIMER: This website uses cookies to improve your user experience. By using this site, you agree to our use of cookies and to our privacy policy.
Privacy policy and cookie usage info.


POWERED BY AMASS forum software 2.58forum software
version 2.58 /
code and design
by Pekka Saarinen ©
for photography-on-the.net

Latest registered member is zachary24
1125 guests, 125 members online
Simultaneous users record so far is 15,144, that happened on Nov 22, 2018

Photography-on-the.net Digital Photography Forums is the website for photographers and all who love great photos, camera and post processing techniques, gear talk, discussion and sharing. Professionals, hobbyists, newbies and those who don't even own a camera -- all are welcome regardless of skill, favourite brand, gear, gender or age. Registering and usage is free.