Skip to content

fix(flatfield): keep a carrier edge in the reference out of the gain - #1315

Merged
marcinz606 merged 1 commit into
marcinz606:mainfrom
thetalkingdrum:fix/flatfield-carrier-border
Oct 9, 2026
Merged

marcinz606 merged 1 commit into
marcinz606:mainfrom
thetalkingdrum:fix/flatfield-carrier-border

Conversation

@thetalkingdrum

@thetalkingdrum thetalkingdrum commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

A flat-field reference that shows part of the dark carrier fed that black band into the gain blur. The blur then read too dark near the band, so the gain overcorrected the frame next to it. With the reference from discussion #1298 corrected by itself, the bottom ~15% of the frame came out up to 12.6% too bright, which prints as a dark band.

compute_gain now masks out pixels below 0.2 of the 95th-percentile luminance, blurs only the lit area (a normalized blur), and takes the mean over the lit area. The mask erosion treats outside the image as dark, so a partly lit carrier strip on the outermost row or column is masked too. Pixels too far from the lit area take the nearest valid value, so the gain stays bounded over a wide carrier. Both of the reporter's flats now self-correct to within about 2%. A reference with no carrier edge gives a gain within 1% of the old one. Profiles already baked keep their stored gain, so existing edits render the same until the profile is baked again.

Tested against the reporter's flats from #1298; confirmation from @oCorvus welcome.

A flat-field reference that shows the dark carrier edge (an empty carrier
shot as the flat) fed that black band into the gain blur. The blur read too
dark next to the edge, so the gain overcorrected there: correcting the
reference with itself left the source up to 12.6% bright over the bottom
~15% of the frame, which prints as a dark band (discussion marcinz606#1298).

compute_gain now masks pixels below 0.2 of the 95th-percentile luminance
out of a normalized convolution and takes the mean over the lit area only.
The mask erosion treats outside the image as dark, so a partly lit carrier
lip on the outermost row or column is masked too. Pixels too far from the
lit area take the nearest valid blur value, so the gain stays bounded over
a wide carrier. Both of the reporter's flats now self-correct to within
about 2%. A reference with no dark border gives a gain within 1% of the
previous one; profiles already baked keep their stored gain until they are
baked again.
@thetalkingdrum
thetalkingdrum marked this pull request as ready for review October 9, 2026 08:50
@marcinz606
marcinz606 merged commit 68f0bb1 into marcinz606:main Oct 9, 2026
1 check passed
@oCorvus

oCorvus commented Oct 9, 2026

Copy link
Copy Markdown

Sorry I'm late. I can confirm that it works perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants