-
Sep 9th, 2014, 01:14 AM
#1
Thread Starter
Frenzied Member
Dark frame subtraction not working quite right.
Ok so I did an experiment. I recorded an AVI file from my webcam with my hand covering it. I then did the same with it pointed at a periodic-table poster I have on my wall.
I wrote a VB program that read out the frames from each AVI file, and for each AVI file added up all the pixel values and stored these large values in arrays of Longs. Because the frame count for the dark frame AVI wasn't the same as the frame count of the main image AVI, I had to scale the sum of dark frames to be of equivalent exposure to the sum of image frames. I did that with this below equations.
ScalingFactor = ImageFrameCount / DarkFrameCount * ExtraScaleFactor
NewImageSumPixel = OldImageSumPixel - DarkSumPixel * ScalingFactor
This is done with each of the 3 color channels.
ExtraScaleFactor is included to allow for additional scaling as I will explain in the next paragraph. After that, to make sure I didn't clip the image, I found the maximum pixel value (the brightest color channel value in the brightest pixel in the image) and the minimum pixel value (the darkest color channel value in the darkest pixel in the image), and used that to normalize the final pixel values to between 0 and 255 like this:
NewPixelValue = (OldPixelValue - MinValue) / (MaxValue - MinValue) * 255
This is done with each of the 3 color channels.
The image is then saved to a BMP file.
As I stated in the previous paragraph, there was an ExtraScaleFactor. This could be either 0, 0.5, or 1. At 0, no dark frame subtraction was used. At 1, it was applied at the fullest extent possible. At 0.5 it was applied only halfway. I used this extra factor, because of the problem I was having, which is the problem that this thread is about, where in the title it says "not working quite right". Of course with nothing being subtracted, the summed image has hot-pixels and recurring vertical bands of non-random electronic noise (the random electronic noise was already removed by the summing process which averages out the randomness). At full dark frame subtraction, the hot-pixels are completely turned black. But this is where the problems start. Rather than completely black, subtracting a hot-pixel is SUPPOSED TO reveal the image pixel that was obscured by the hot-pixel. Even worse is it inverted the vertical bands of non-random noise (where they were brighter than the surrounding image, they are now darker than the surrounding image, and where they were darker than the surrounding image, they are now brighter than the surrounding image), rather than removing the bands. Then I decided to see what would happen if I set the strength of the dark frame subtraction to half-way. It turns out this completely removes the non-random electronic noise (though the hot pixels are not removed, but rather are simply decreased in intensity). This is strange, because I've read books on astronomical image processing, including the techniques of summing (stacking) images and dark frame subtraction, and nowhere is there anything that states that the algorithm for dark frame subtraction should use an a subtraction strength of half of what it would normally be.
This is in the general developer section rather than in the VB section because this is a question about an image processing technique, rather than something specific to VB programming.
Below are the resulting images from the 3 levels of dark-frame subtraction I tried (none, half-way, and full).
No dark-frame subtraction
Full dark-frame subtraction
Half-strength dark-frame subtraction
Is there something fundamentally wrong with the above algorithms I used? If someone knows why this is doing what it's doing, please let me know.
Last edited by Ben321; Sep 9th, 2014 at 01:18 AM.
-
Sep 16th, 2014, 07:33 AM
#2
Re: Dark frame subtraction not working quite right.
Ok this is a little beyond me so help me a bit here. What is the ultimate purpose of this program ? I mean what is it something like this usually used for ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|