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

Brightness normalisation #25

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Conversation

IgorTatarnikov
Copy link
Member

@IgorTatarnikov IgorTatarnikov commented Jan 10, 2025

Before submitting a pull request (PR), please read the contributing guide.

Please fill out as much of this template as you can, but if you have any problems or questions, just leave a comment and we will help out :)

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
There can be large intensity differences between each tile. This PR introduces a method to normalise the intensities between each tile.

What does this PR do?

This is done by assuming that the overlapping area should have equal intensity between each tile. This is used to calculate a scaling factor between two tiles. This scaling factor is applied and the comparison is done for the subsequent tiles. For example say an image contains 4 tiles and each tile overlaps with all other tiles:

The first round of comparisons will calculate scaling factors for tile 1 + 2, 1 + 3, 1 + 4. The scaling factors will be applied lazily to the tiles. The second round of comparisons will calculate scaling factors based on tile 2 + 3, 2 + 4.

The final result will be a num_tiles by num_tiles matrix that contains a scaling factor for each tile comparison.

tile_1 tile_2 tile_3 tile_4 final_factor
tile_1 1 1 1 1 1
tile_2 0.8 1 1 1 0.8
tile_3 0.9 0.95 1 1 0.855
tile_4 0.6 0.98 0.96 1 0.565

The final factor is calculated as the product of all scaling factors calculated for that tile. This final scaling factor is then applied to the full resolution image prior to fusing/saving to disk.

How has this PR been tested?

Tests added for new functionality.

Is this a breaking change?

No

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The code has been formatted with pre-commit

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

Attention: Patch coverage is 98.92473% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.95%. Comparing base (7e5f173) to head (87b9b12).

Files with missing lines Patch % Lines
brainglobe_stitch/stitching_widget.py 98.14% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
+ Coverage   95.54%   96.95%   +1.41%     
==========================================
  Files           6        6              
  Lines         673      756      +83     
==========================================
+ Hits          643      733      +90     
+ Misses         30       23       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@IgorTatarnikov IgorTatarnikov marked this pull request as ready for review January 16, 2025 12:56
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.

2 participants