Adventures in flat field calibration

Jeffry7

Senior Member
Messages
1,337
Solutions
3
Reaction score
781
I took my Sigma sd Quattro h on a vacation to Gatlinburg TN. Besides my smart phone, it was the only camera I brought on that trip. The pictures I took on that trip all suffered from a blemish, a bit of hair(?) somewhere in the light path. I think it is on the IR/dust guard. I used some tools in GIMP to remove these marks, or for the pano shots, took advantage of the overlapping photos to remove the offending section.

More recently I went to Big Bend TX and again took the sdqh along with a Panasonic S1, and my smartphone. I had forgotten to clean the Sigma and so my pictures out in Big Bend had the same blemish.

Find the tree on the left. Go up and to a little to the right. That isn't a bird.
Find the tree on the left. Go up and to a little to the right. That isn't a bird.

This jpg is via SPP with all the sliders in the middle except the two NR ones which are all the way to the left. It is meant to be part of a pano and as such the repeating pattern of the blemish is particularly annoying.

I read articles about astrophotography and had come across the idea of flat field calibration. It seemed like a good time to try it.

I read up on it as well as I could as articles on the web about using it to remove dust are thin with many of them referring to how to push buttons in certain astrophotography programs.

Rawpedia, a source of reference for RawTherapee, has an article on it. It talks about how to take the pictures, the flats, and how to use RawTherapee to calibrate your pictures. Unfortunately, this only works on RAW images, and so without support for my X3F files, was a non-starter.

RawPedia Flat Field

Next came Adobe. Light Room Classic, which I was compelled to get a while ago, has a flat calibration built in and it does not require that the source images be RAWs. Unfortunately, whatever it is doing, it does not remove these kinds of marks.

Export from LRC after applying Flat Field Calibration.
Export from LRC after applying Flat Field Calibration.

The Flat Frame. Shot at Inf focus and the same aperture as the image.
The Flat Frame. Shot at Inf focus and the same aperture as the image.

OK, so now what?

It was at this point that I remembered that PIPP, an astrophotography preprocessing program I use can do flat field calibration. It can do many other things, but you can turn all those things off, and it is just fine with TIFFs.

PIPP

So that worked. Sorta.

Original TIFF on Left, Calibrated on Right
Original TIFF on Left, Calibrated on Right

100% compare of the before and after. Before on Left, After on Right
100% compare of the before and after. Before on Left, After on Right

I would be curious to know if it is obvious to you as it is to me. Especially after whatever DPReview will do to the image.

I tried taking 100 flat frames and giving these to PIPP for processing, but this actually made the calibrated blemish stand out more. It became lighter.

PIPP briefly described the flat field calibration as division, and I thought I would use ImageMagick to do this "manually". Something seemed off to me about this though. If you just do a straight division of one image from the other, the relative exposures of the two images come in to play.

But I figured I could mess around with and maybe even try some python scripts to scale the calibration image and so see what values worked best.

In looking for the syntax to divide one image by the other, I came across a blog that explained how to use Imagemagick to do this calibration. The author was only considering vignetting, which is maybe why I had not found it previously.

Vignetting Part 3

He explains that you should divide the flat frame by it's maximum value prior to dividing the image by it. This made instant sense and I discarded any notions of a python script.

This method also left traces in the image of the blot I wanted to remove.

It also left an obvious color shift. I presume that the idea of taking the maximum value and dividing every value by it is naive and is not the correct thing to do for color images.

Color Shift. New test shot on right and ImageMagick calibrated on right.
Color Shift. New test shot on right and ImageMagick calibrated on right.

My calibration frames up to this point had been made by setting my computer monitor to white and setting the camera close to it, so that the whole image was of the white screen. I have no idea if the monitor is genuinely uniform or even actually white. It was a quick and dirty solution to see if flat calibration would work.

I decided to try using the blue sky instead with the idea that the brightening after calibration might be due to the monitor's supposed short comings. I needed a blue sky shot.

As soon as I thought this, the weather changed and we got our ice storm. I'm sorry.

But there was some blue sky after a while and I went out with the camera and a filter called the expodisc 2.0. This is meant to be a white balance tool. You can use it to set the custom white balance in your camera and then your jpegs will have the correct white balance. Personally, this seems like a terrible use case. But, the directions mention, as if an after thought, that you can use it make flat frames.

With my blue sky and my expodisc, I shot a couple of frames outside. I figured that calibrating this would be as good as it got. The blemish would not have moved in the several seconds it took to get the shots. I could make sure the focus was at the same distance instead of guessing. I also took a flat by pointing at blue sky and another pointing towards the sun. (Via an EVF and with the expodisc over the lens. Put obligatory DON'T LOOK AT THE SUN warning here.)

Going back in and trying first PIPP and then the ImageMagick, I could still see some artifacts after the calibration. If I zoomed to 100% at the spot I knew where the correction had happened.

For these final shots, I think the imperfections come down to noise in both the original image and the flat frames.

I wouldn't be surprised if they weren't visible in the following image. (Correction via PIPP.)

100% Left is before calibration and right is after. V shaped hair and round dot removed
100% Left is before calibration and right is after. V shaped hair and round dot removed

My conclusions.

Flat field calibration via PIPP can work very well.

I have at least one image that slightly brightens the calibrated spot rather than appearing to remove the blemish. I think for that one image I can use other techniques. The other images in the Pano, after calibration, look good enough.

The expodisc 2 does indeed make a useful flat field tool. It has threads like a filter, but fits more like a pinch lens cap. Snap it on, take your flat, Carry on.

The obscurity of the Sigma system makes flat field calibration awkward. You are forced to convert to TIFF and then use a general tool. If SPP had layers, you could use that to apply the correction along with any other adjustments you wished to make to the RAW.

(There is lens based correction in SPP for the fp and fp L.)

Make your flats when you take your shots. I think anything that requires stitching or stacking should have flat calibrations.

If you have read this far, thanks for indulging my nonsense.
 
Last edited:
Hello!

Very interesting and for some pictures certainly worth a try.

One remark though: If you install the latest version of Affinity Photo (which usually sells for around 50$/Euros for a lifetime license) you can do the complete workflow from raw convesion (*) to applying all sorts of astronony corrections within a single piece of software.

Regards

Max

(*) I just saw that you have a Quattro. As I don't have one myself I can not say for certain that Affinity can process Quattro raw files. But it certainly does SD9...15, Merrill, Panasonic and most probably even your smartphone raws, if the phone lets you save them.
 
Hello!

Very interesting and for some pictures certainly worth a try.

One remark though: If you install the latest version of Affinity Photo (which usually sells for around 50$/Euros for a lifetime license) you can do the complete workflow from raw convesion (*) to applying all sorts of astronony corrections within a single piece of software.

Regards

Max

(*) I just saw that you have a Quattro. As I don't have one myself I can not say for certain that Affinity can process Quattro raw files. But it certainly does SD9...15, Merrill, Panasonic and most probably even your smartphone raws, if the phone lets you save them.
Affinity can open both X3F and DNG files from my sdQH. And DNG files from fp and fpL. And X3F files from Merrills.

The raw converter isn't as nice to use as Adobe Camera Raw, but it's perfectly capable.

Don
 
I took my Sigma sd Quattro h on a vacation to Gatlinburg TN. Besides my smart phone, it was the only camera I brought on that trip. The pictures I took on that trip all suffered from a blemish, a bit of hair(?) somewhere in the light path. I think it is on the IR/dust guard. I used some tools in GIMP to remove these marks, or for the pano shots, took advantage of the overlapping photos to remove the offending section.

I read articles about astrophotography and had come across the idea of flat field calibration. It seemed like a good time to try it.

I read up on it as well as I could as articles on the web about using it to remove dust are thin with many of them referring to how to push buttons in certain astrophotography programs.

Rawpedia, a source of reference for RawTherapee, has an article on it. It talks about how to take the pictures, the flats, and how to use RawTherapee to calibrate your pictures. Unfortunately, this only works on RAW images, and so without support for my X3F files, was a non-starter.

RawPedia Flat Field

Next came Adobe. Light Room Classic, which I was compelled to get a while ago, has a flat calibration built in and it does not require that the source images be RAWs. Unfortunately, whatever it is doing, it does not remove these kinds of marks.

Export from LRC after applying Flat Field Calibration.
Export from LRC after applying Flat Field Calibration.

The Flat Frame. Shot at Inf focus and the same aperture as the image.
The Flat Frame. Shot at Inf focus and the same aperture as the image.

OK, so now what?

It was at this point that I remembered that PIPP, an astrophotography preprocessing program I use can do flat field calibration. It can do many other things, but you can turn all those things off, and it is just fine with TIFFs.

PIPP

So that worked. Sorta.

Original TIFF on Left, Calibrated on Right
Original TIFF on Left, Calibrated on Right

100% compare of the before and after. Before on Left, After on Right
100% compare of the before and after. Before on Left, After on Right

I would be curious to know if it is obvious to you as it is to me. Especially after whatever DPReview will do to the image.
Obvious on my screen, Jeffry.
I tried taking 100 flat frames and giving these to PIPP for processing, but this actually made the calibrated blemish stand out more. It became lighter. <>

He explains that you should divide the flat frame by it's maximum value prior to dividing the image by it. This made instant sense and I discarded any notions of a python script.

This method also left traces in the image of the blot I wanted to remove.

It also left an obvious color shift. I presume that the idea of taking the maximum value and dividing every value by it is naive and is not the correct thing to do for color images.

Color Shift. New test shot on right and ImageMagick calibrated on right.
Color Shift. New test shot on right and ImageMagick calibrated on right.

My calibration frames up to this point had been made by setting my computer monitor to white and setting the camera close to it, so that the whole image was of the white screen. I have no idea if the monitor is genuinely uniform or even actually white. It was a quick and dirty solution to see if flat calibration would work.

I decided to try using the blue sky instead with the idea that the brightening after calibration might be due to the monitor's supposed short comings. I needed a blue sky shot.

As soon as I thought this, the weather changed and we got our ice storm. I'm sorry.

The obscurity of the Sigma system makes flat field calibration awkward. You are forced to convert to TIFF and then use a general tool. If SPP had layers, you could use that to apply the correction along with any other adjustments you wished to make to the RAW.

(There is lens based correction in SPP for the fp and fp L.) <>

If you have read this far, thanks for indulging my nonsense.
Wow ...

Have you proved to your satisfaction that the blemish is on the dustcover, perhaps by removing the dustcover carefully and shooting again?

Can the sd Q H be shot with no lens fitted?

As to operating on layers esp. division, the GIMP has bucket-load of blending modes, as I'm sure you know.

Would this help ...

... Remove your spot from a TIFF and save the PP3 for re-use?

http://rawpedia.rawtherapee.com/Spot_Removal

Also "Maybe check out G'Mic, they've been working a lot on the patch-based Inpaint filter and it works beautifully and is open source. See the examples here. I know some are quite old, so I suppose today's Inpainting filter would do an even better job: http://sourceforge.net/p/gmic/wiki/G'MIC Inpainting results/"

From 6 yrs ago:

https://github.com/Beep6581/RawTherapee/issues/2239

--
It's all in the numbers ...
 
Last edited:
I took my Sigma sd Quattro h on a vacation to Gatlinburg TN. Besides my smart phone, it was the only camera I brought on that trip. The pictures I took on that trip all suffered from a blemish, a bit of hair(?) somewhere in the light path. I think it is on the IR/dust guard. I used some tools in GIMP to remove these marks, or for the pano shots, took advantage of the overlapping photos to remove the offending section.

I read articles about astrophotography and had come across the idea of flat field calibration. It seemed like a good time to try it.
Wow ...

Have you proved to your satisfaction that the blemish is on the dustcover, perhaps by removing the dustcover carefully and shooting again?

Can the sd Q H be shot with no lens fitted?

As to operating on layers esp. division, the GIMP has bucket-load of blending modes, as I'm sure you know.

Would this help ...

... Remove your spot from a TIFF and save the PP3 for re-use?

http://rawpedia.rawtherapee.com/Spot_Removal


Also "Maybe check out G'Mic, they've been working a lot on the patch-based Inpaint filter and it works beautifully and is open source. See the examples here. I know some are quite old, so I suppose today's Inpainting filter would do an even better job: http://sourceforge.net/p/gmic/wiki/G'MIC Inpainting results/"

From 6 yrs ago:

https://github.com/Beep6581/RawTherapee/issues/2239
Oops, I just now looked at RT 5.8 and "Spot Removal" is still not implemented so you'd have to go to GitHub and download the branch, I guess. No idea how to do that, sorry.

How about ImageMagick ... can it Clone or Heal a TIFF then use a batch mode?

Yep: https://legacy.imagemagick.org/Usage/basics/#clone

Apparently ... doesn't look easy though. My inclination would be to find and physically fix the blemish ...
 
Last edited:
Adobe Camera Raw can load a number of photos which can all be selected at once. At least, the ancient Photoshop version I have has this feature. I presume the Lightroom version is the same.

It also has a kind of healing brush for removing dust marks, so you can load a number of photos that have dust in the same place and remove dust from them all at once.

Martin Evening's book on Photoshop includes a very complete manual for ACR.

Don
 
Adobe Camera Raw can load a number of photos which can all be selected at once. At least, the ancient Photoshop version I have has this feature. I presume the Lightroom version is the same.

It also has a kind of healing brush for removing dust marks, so you can load a number of photos that have dust in the same place and remove dust from them all at once.
Great minds think alike ... :-D
 
Adobe Camera Raw can load a number of photos which can all be selected at once. At least, the ancient Photoshop version I have has this feature. I presume the Lightroom version is the same.

It also has a kind of healing brush for removing dust marks, so you can load a number of photos that have dust in the same place and remove dust from them all at once.
Great minds think alike ... :-D

Don
 
I took my Sigma sd Quattro h on a vacation to Gatlinburg TN. Besides my smart phone, it was the only camera I brought on that trip. The pictures I took on that trip all suffered from a blemish, a bit of hair(?) somewhere in the light path. I think it is on the IR/dust guard. I used some tools in GIMP to remove these marks, or for the pano shots, took advantage of the overlapping photos to remove the offending section.

I read articles about astrophotography and had come across the idea of flat field calibration. It seemed like a good time to try it.

I read up on it as well as I could as articles on the web about using it to remove dust are thin with many of them referring to how to push buttons in certain astrophotography programs.

Rawpedia, a source of reference for RawTherapee, has an article on it. It talks about how to take the pictures, the flats, and how to use RawTherapee to calibrate your pictures. Unfortunately, this only works on RAW images, and so without support for my X3F files, was a non-starter.

RawPedia Flat Field

Next came Adobe. Light Room Classic, which I was compelled to get a while ago, has a flat calibration built in and it does not require that the source images be RAWs. Unfortunately, whatever it is doing, it does not remove these kinds of marks.

Export from LRC after applying Flat Field Calibration.
Export from LRC after applying Flat Field Calibration.

The Flat Frame. Shot at Inf focus and the same aperture as the image.
The Flat Frame. Shot at Inf focus and the same aperture as the image.

OK, so now what?

It was at this point that I remembered that PIPP, an astrophotography preprocessing program I use can do flat field calibration. It can do many other things, but you can turn all those things off, and it is just fine with TIFFs.

PIPP

So that worked. Sorta.

Original TIFF on Left, Calibrated on Right
Original TIFF on Left, Calibrated on Right

100% compare of the before and after. Before on Left, After on Right
100% compare of the before and after. Before on Left, After on Right

I would be curious to know if it is obvious to you as it is to me. Especially after whatever DPReview will do to the image.
Obvious on my screen, Jeffry.
I tried taking 100 flat frames and giving these to PIPP for processing, but this actually made the calibrated blemish stand out more. It became lighter. <>

He explains that you should divide the flat frame by it's maximum value prior to dividing the image by it. This made instant sense and I discarded any notions of a python script.

This method also left traces in the image of the blot I wanted to remove.

It also left an obvious color shift. I presume that the idea of taking the maximum value and dividing every value by it is naive and is not the correct thing to do for color images.

Color Shift. New test shot on right and ImageMagick calibrated on right.
Color Shift. New test shot on right and ImageMagick calibrated on right.

My calibration frames up to this point had been made by setting my computer monitor to white and setting the camera close to it, so that the whole image was of the white screen. I have no idea if the monitor is genuinely uniform or even actually white. It was a quick and dirty solution to see if flat calibration would work.

I decided to try using the blue sky instead with the idea that the brightening after calibration might be due to the monitor's supposed short comings. I needed a blue sky shot.

As soon as I thought this, the weather changed and we got our ice storm. I'm sorry.

The obscurity of the Sigma system makes flat field calibration awkward. You are forced to convert to TIFF and then use a general tool. If SPP had layers, you could use that to apply the correction along with any other adjustments you wished to make to the RAW.

(There is lens based correction in SPP for the fp and fp L.) <>

If you have read this far, thanks for indulging my nonsense.
Wow ...

Have you proved to your satisfaction that the blemish is on the dustcover, perhaps by removing the dustcover carefully and shooting again?
No. I didn't want to do something that would disturb it prior to taking the flats.

I am considering another round of calibration files. But yes, the camera, or possibly the lens, needs cleaning. I even have a spare dust cover I can simply replace the current one with.
Can the sd Q H be shot with no lens fitted?
Yes. I use it with t-Mount manual lenses for my moon shots.
As to operating on layers esp. division, the GIMP has bucket-load of blending modes, as I'm sure you know.

Would this help ...

... Remove your spot from a TIFF and save the PP3 for re-use?
I will take a look. Thanks!
http://rawpedia.rawtherapee.com/Spot_Removal

Also "Maybe check out G'Mic, they've been working a lot on the patch-based Inpaint filter and it works beautifully and is open source. See the examples here. I know some are quite old, so I suppose today's Inpainting filter would do an even better job: http://sourceforge.net/p/gmic/wiki/G'MIC Inpainting results/"

From 6 yrs ago:

https://github.com/Beep6581/RawTherapee/issues/2239

--
It's all in the numbers ...
 

Keyboard shortcuts

Back
Top