Producing flat frames

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Producing flat frames

Post by fmw42 »

geoland wrote:Apologies. The value of the light frame pixels is reduced when dividing the lights by the auto-leveled master flat. I am then normalizing the lights to increase the pixel values.

I will try the other operators - so far median and auto-level produce flat frames that divide correctly and don't over or under compensate.
It is really hard to try to understand without examples. So perhaps I misunderstood.

But have you tried dividing by the median without the auto-level. Then after dividing, you might try using -auto-level, if it is still dark.
geoland wrote:There must be a repository with the latest deb package.
Not likely. Linux distributions for most if not all flavors of Linux are way behind. You would probably need to install yourself from source.
geoland
Posts: 74
Joined: 2015-05-14T05:11:38-07:00
Authentication code: 6789

Re: Producing flat frames

Post by geoland »

That's no problem. Thanks again. Appreciate the assistance.

Still working on the master_flat/mode method which is a bit of challenge. In the meantime I need a work around that produces clean light frames with reasonable pixel values.

This works quite well - keep the processing linear. I found including -colorspace sRGB wouldn't divide cleanly, but noise estimates were better.

median combine the flats

Code: Select all

convert flats -evaluate-sequence median master_flat.tiff
light/master_flat and normalize the lights.

Code: Select all

convert lights master_flat -compose Divide_Src -composite -normalize
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
geoland
Posts: 74
Joined: 2015-05-14T05:11:38-07:00
Authentication code: 6789

Re: Producing flat frames

Post by geoland »

This writes the histogram to /tmp/mode.txt and cuts the mode value, as well as removing the leading whitespace to write mode as a variable $MODE

Code: Select all

convert *.tiff -evaluate-sequence median combined_flat.tiff >/dev/null 2>&1

	convert combined_flat.tiff -format "%c" histogram:info:  | sort -r -k1 | head -n 1 > /tmp/mode.txt
	
	mode=$(cut -d':' -f1 /tmp/mode.txt)	
	
	MODE=${mode//[[:space:]]/}
The next step is - pseudo code

Code: Select all

combined_flat.tiff/$MODE = master_flat.tiff
This does not work as well as hoped

Code: Select all

  convert combined_flat.tiff -evaluate divide $MODE master_flat.tiff
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Producing flat frames

Post by snibgo »

From mode.txt, you are extracting into $MODE the number of pixels that have the most common colour. I don't know what significance this number has. Depending on your images, the number might be low (eg 2) or high (eg thousands or millions).

So dividing the image by $MODE will darken it, perhaps to almost or entirely black.
snibgo's IM pages: im.snibgo.com
geoland
Posts: 74
Joined: 2015-05-14T05:11:38-07:00
Authentication code: 6789

Re: Producing flat frames

Post by geoland »

From what I read, the idea of dividing the flats by mode is to correct the multiplicative errors in the flat frames, before combining them. My application, above, is not correct because I am dividing the master flat (all the combined flats) by the mode. I realise now that the individual flats should be corrected prior to combination. Dividing the flats by mode should produce pixel values closer to 1. However, IM does a very good job of flat calibration of the light/image frames without complicating things with mode division. Which is not working.

I will keep working at this and report back, if things improve. Many thanks fwm42 and snibgo for your help.
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
geoland
Posts: 74
Joined: 2015-05-14T05:11:38-07:00
Authentication code: 6789

Re: Producing flat frames

Post by geoland »

I think this is solved. The order of the operators is important. This is an effective method of creating a master flat that does not over correct or under correct the light frame pixel values during division.

Code: Select all

convert flat.tiff -auto-level -evaluate-sequence median master_flat.tiff
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
Post Reply