Evening out backgrounds

A forum to ask questions, post setups, and generally discuss anything having to do with photomacrography and photomicroscopy.

Moderators: rjlittlefield, ChrisR, Chris S., Pau

pwnell
Posts: 2029
Joined: Fri Dec 18, 2009 4:59 pm
Location: Tsawwassen, Canada

Evening out backgrounds

Post by pwnell »

What is the best technique in Photoshop for evening out backgrounds? Lets say I have uneven DIC illumination, or I have created a panorama where the original image had asymmetrical vignetting. How do I even out the background (I cannot merely replace the background as the tone varies along the subject boundaries).

Ideally I want to select the subject, invert the selection then blur / smoothen the background. Gaussian blur does not work in this case as it is only good for smoothing out small items, not large colour / luminosity differences.

Charles Krebs
Posts: 5865
Joined: Tue Aug 01, 2006 8:02 pm
Location: Issaquah, WA USA
Contact:

Post by Charles Krebs »

I'll be watching this to see what the PS experts have to say! :wink:

ImageJ has some plugins to do this sort of thing but I've never used it successfully.

Olympus put out a nice little program years ago:
http://www.olympusmicro.com/primer/digi ... nload.html

It actually worked well in many cases but was of ultimately of little use to me because it was very limited as to the size of image it could work with (only quite small images... I forget the pixel dimensions). Would love to have this in a form capable of dealing with larger images.

Here's an example of a correction made very quickly using this "tool".

Image

Peter M. Macdonald
Posts: 187
Joined: Tue Jan 20, 2009 2:59 pm
Location: Berwickshire, Scotland

Post by Peter M. Macdonald »

One simple way is with a gradient adjustment to exposure. I like to do this in Lightroom at the time of the initial raw conversion. A gradient set to increase the exposure by about 0.65 stops can be drawn up from the lower right hand corner of the original image. Stop pulling out the gradient about the centre of the image.

The other way to do this is in Photoshow, working on the otherwise finished image. The Raw Conversion Filter brings the same functionality into the workflow at any time. The same graduated exposure adjustment can be done at that stage.

There are, of course, other ways to achieve a graduated adjustment in Photoshop, but this is about as simple as it gets.

There are at least two other ways of doing this without using a graduated adjustment. If you do not use an "empty" image without the subject, proceed as follows: -

1. open the image;
2. duplicate the background layer;
3. blur the top layer using Gausian Blur with a radius over 100;
4. invert the blurred layer;
5. blend the top layer with hard light;
6. adjust the opacity until the background is even - usually about 50%;
7. if the colour does not look right, desaturate the blurred layer;
8. bring back the original image brightness using levels.

In the case of the example which Charles posted, an opacity of about 34% seems to work.

Alternatively, shoot an image through an empty portion of the same slide and coverglass. Then proceed as follows: -

1. open the image;
2. open the flatfield image;
3. copy the flatfield image;
4. paste it on top of the ordinary image;
5. invert the flatfield image;
6. set the layer blend to hard light;
7. adjust the opacity until the background is even - usually about 50%;
8. bring back the original image brightness using levels.

I have not save the copy images which I worked on for this post, but will be happy to rework them should Charles want, although I know that he will be able to do a better job with these methods than I can.

Peter

bernhardinho
Posts: 563
Joined: Sun Aug 13, 2006 6:28 am
Location: Germany
Contact:

Post by bernhardinho »

Hi folks

there is a nice tool from the astroworld that does a nice and simple to use job when it comes to flattening out backgrounds:

http://ukastroimaging.co.uk/forums/inde ... ic=36944.0

I have also given a try to Peters suggestion using GIMP. Works also very fine!!


Kind regards

Bernhard

johan
Posts: 1005
Joined: Tue Sep 06, 2011 7:39 am
Contact:

Post by johan »

bernhardinho wrote:Hi folks

there is a nice tool from the astroworld that does a nice and simple to use job when it comes to flattening out backgrounds:

http://ukastroimaging.co.uk/forums/inde ... ic=36944.0

I have also given a try to Peters suggestion using GIMP. Works also very fine!!


Kind regards

Bernhard
fyi - the links on this page are missing "404"
My extreme-macro.co.uk site, a learning site. Your comments and input there would be gratefully appreciated.

johan
Posts: 1005
Joined: Tue Sep 06, 2011 7:39 am
Contact:

Post by johan »

My extreme-macro.co.uk site, a learning site. Your comments and input there would be gratefully appreciated.

Ichthyophthirius
Posts: 1152
Joined: Thu Mar 07, 2013 5:24 am

Post by Ichthyophthirius »

Hi,

I would suggest taking an image of the background before and after the main shooting (just empty part of the slide in exactly the same focus as the other images). Then perform background substraction.

In Photoshop:

- open both image files
- IMAGE: Apply image
Blending: Substract
Offset: 120

Another thing to keep in mind is that the "vignetting" is in fact an interference fringe. There is contrast inversion on either side of the main black interference fringe. So even after background correction the contrast is not homogenous across the whole frame in extreme cases and it looks "off". It might be worth cutting off image area along the corners.

Regards, Ichty

bernhardinho
Posts: 563
Joined: Sun Aug 13, 2006 6:28 am
Location: Germany
Contact:

Post by bernhardinho »

johan wrote:
bernhardinho wrote:Hi folks

there is a nice tool from the astroworld that does a nice and simple to use job when it comes to flattening out backgrounds:

http://ukastroimaging.co.uk/forums/inde ... ic=36944.0

I have also given a try to Peters suggestion using GIMP. Works also very fine!!


Kind regards

Bernhard
fyi - the links on this page are missing "404"

oops..I am sorry. I didn´t check them, just tried to make it easier for you guys maybe not so familiar with the german language . Maybe this link is more helpfull:

http://www.fitswork.de/software/softw_en.php


Cheers

Bernhard

pwnell
Posts: 2029
Joined: Fri Dec 18, 2009 4:59 pm
Location: Tsawwassen, Canada

Post by pwnell »

This is great info - thanks for everyone's detailed responses. I tried Peter's second last method and it worked well... My subject was a horrible example as I merged several polarized shots into a panorama, but the vignetting was very strong, so I had repeated vignetting patterns throughout the image.

I will review the other techniques too.

Charles - I found a similar feature in I believe one of Olympus' deconvolution software packages. It worked awesome and for bigger files, however I did not have the stomach for the software's price tag.

spongepuppy
Posts: 87
Joined: Mon Nov 26, 2012 11:03 pm
Location: Sydney, Australia

Post by spongepuppy »

I have an action that I built for photo retouching in my work that does something similar. In my case, we often want to change the overall tonal distribution of an image while retaining the texture, but it can also be used to correct uneven lighting in some cases.

Essentially it simply separates the image into two layers by taking the difference of a blurred version of the original with itself, thereby creating a "high frequency" layer and a "low frequency" layer that can be manipulated separately. Using a sufficiently large radius at the blurring stage lets you simply average the low frequency layer to even up illumination across the field. Colours can be restored by moving the original layer to the top and selecting "color" as the layer blending mode.

I would imagine that DIC images are dominated by high-frequency detail, so you may have some luck with it. I tried it on Charles' image, and the results are encouraging:

Image

Note that Photoshop uses the edgemost pixels of the image to "extend" the canvas for the purposes of calculating values for the blurring operation - so don't try this on an image with a border or other non-representative pixels at the boundary.

I have placed a copy of my Photoshop action here if you would like to try it out:
http://cb96fa519d58f475432f-70c9e55d824 ... Detail.atn

I suspect that it would also be reasonably straightforward to do this in batch with ImageMagick's command-line tools. ImageMagick also allows you to set how it generates virtual pixels for convolutions close to the image boundary as well, which could make it more useful in this application.
---
Matt Inman

discomorphella
Posts: 607
Joined: Sun Oct 01, 2006 7:26 pm
Location: NW USA

Post by discomorphella »

the simplest way to correct in imageJ if you have a high SNR image and a good blank image is to use the image calculator plus and divide the original by the background. This will fail miserably if you have a noisy image (I would guess that SNR > 20 at least would be required but I'd have to sit down with matlab and test it out). if you do have a clean image then it normalizes the background out (to first order). There are other imageJ plugins which purport to be background correction code but I've never found any of them to work well.

David

spongepuppy
Posts: 87
Joined: Mon Nov 26, 2012 11:03 pm
Location: Sydney, Australia

Post by spongepuppy »

As a small update to this topic, I did end up writing a small Windows batch script for Imagemagick 6, because I wanted something that was a bit more portable that Photoshop to process image sequences.

I used it to even up the field on a couple of videos I did. It worked really well - so please find it below. I hope it proves useful to other members for their own endeavours.

Code: Select all

@echo off
SETLOCAL

for %%f in (%1) do (call :processimg "%%f" %2 %3)
goto :eof

:processimg
	SET INPUT_FILE=%~1
	SET OUTPUT_FILE=%~dpn1_out.jpg
	identify -format "%%[w]x%%[h]" "%INPUT_FILE%" > %~dpn1_dims.txt
	SET /p IMAGE_SIZE=<%~dpn1_dims.txt
	DEL  %~dpn1_dims.txt
	ECHO %INPUT_FILE% outputs to %OUTPUT_FILE% - image size %IMAGE_SIZE%
	convert  "%INPUT_FILE%" -alpha off -background none -virtual-pixel mirror &#40; +clone &#41; &#40; +clone -blur 0x%2  &#41; &#40; -clone 1,2  -compose mathematics -set option&#58;compose&#58;args "0,-0.5,0.5,0.5" -composite &#41; &#40; -compose src-over -clone 2 -filter box -resize 1x1 -resize %IMAGE_SIZE%! &#41; &#40; -compose linear-light -clone 4 -clone 3 -composite -compose Colorize -clone 0 -composite &#41;  -compose src-over -delete 0,1,2,3,4 -alpha Off -quality 100 %~3 "%OUTPUT_FILE%"
Arguments are:
1. A filename or wildcard
2. Blur size
3. Additional commands to run immediately before the output file is generated. These should be placed inside quotes.

Note that this script outputs a jpeg, but altering the OUTPUT_FILE line to use an filetype extension that suits your requirements will change that.
---
Matt Inman

Post Reply Previous topicNext topic