Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible error in the flat field algorithm #5848

Open
dimonoid opened this issue Jul 14, 2020 · 6 comments
Open

Possible error in the flat field algorithm #5848

dimonoid opened this issue Jul 14, 2020 · 6 comments
Labels
missing info Needs more information

Comments

@dimonoid
Copy link

dimonoid commented Jul 14, 2020

Unfortunately I couldn't find that part of the code with this particular algorithm, so writing in here.
I am suspecting that dark frame might be not subtracted from the the flat field, so flat field might remain "dirty".

Also as I understood correctly, this should be the algorithm, assuming each variable is vector, as in matlab:

  1. Take raw image img before doing anything
  2. cleanImage=img.-darkframe;
  3. cleanFlatfield=blur(flatfield.-darkframe); //it looks like right now is subtracted bias instead of darkframe
  4. cleanFlatfield=cleanFlatfield/(99th(or 95th) percentile max brightness of cleanFlatfield); // get range roughly from 0.0 to 1.1
  5. If (cleanFlatfield>1){cleanFlatfield=1} // get range from 0.0 to 1.0
  6. cleanImage=cleanImage.*cleanFlatfield;
  7. Then de mosaic etc...

The response might include just a link to the file so I could check myself.
Otherwise I get somewhy too much noise and too bright image with low contrast when applying flatfield to very dark photos,

btw auto clip control looks broken in flat fields tab, it doesn't normalize definitely clipped photos.

@dimonoid
Copy link
Author

dimonoid commented Jul 14, 2020

I believe this part of code is approximately in here:

/* Copy original pixel data and

@heckflosse
Copy link
Collaborator

btw auto clip control looks broken in flat fields tab, it doesn't normalize definitely clipped photos.

From RawPedia:

Applying a flat-field image can cause nearly-overexposed areas in the image to become overexposed due to the correction. Activating the Clip Control option will keep the flat-field image from clipping the actual image. Areas in the actual image which were already clipped before the application of the flat-field image may acquire a color cast, therefore as a rule of thumb, if your photo contains overexposed areas it is better to not use Clip Control.

@heckflosse
Copy link
Collaborator

The response might include just a link to the file so I could check myself.

https://github.com/Beep6581/RawTherapee/blob/dev/rtengine/rawflatfield.cc#L266

@heckflosse
Copy link
Collaborator

  1. cleanImage=cleanImage.*cleanFlatfield;

Wouldn't that be an inverse flatfield correction (brightening the already bright regions even more and vice versa for the darker regions) ?

@dimonoid
Copy link
Author

dimonoid commented Jul 14, 2020

btw auto clip control looks broken in flat fields tab, it doesn't normalize definitely clipped photos.

From RawPedia:

Applying a flat-field image can cause nearly-overexposed areas in the image to become overexposed due to the correction. Activating the Clip Control option will keep the flat-field image from clipping the actual image. Areas in the actual image which were already clipped before the application of the flat-field image may acquire a color cast, therefore as a rule of thumb, if your photo contains overexposed areas it is better to not use Clip Control.

I wonder why would it cause color cast? Maybe use another color space and adjust only brightness? In addition, this algorithm I provided should only decrease brightness, not increase, so clipping will be impossible (I think). I am assuming that flat field is always grey and has no color(r=g=b).

@Lawrence37
Copy link
Collaborator

I am suspecting that dark frame might be not subtracted from the the flat field, so flat field might remain "dirty".

This is the correct behavior. Dark frames work best when they are shot under similar conditions as the image. Usually, the image and the flat-field are shot under different conditions, so it doesn't make sense to apply the same dark frame to both. Maybe what you want is a new feature which allows you to apply a different dark frame to the flat-field.

I wonder why would it cause color cast?

I believe this is because clip control darkens the image without adjusting the white level. It's like setting the white level too high. When there are clipped highlights and the white level is too high, you get a color cast (often magenta). Please note that this is also expected behavior.

@Thanatomanic Thanatomanic added the missing info Needs more information label Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing info Needs more information
Projects
None yet
Development

No branches or pull requests

4 participants