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 percentiles set in live viewer images #1973

Merged
merged 2 commits into from
Nov 7, 2023

Conversation

MikeSullivan7
Copy link
Collaborator

Issue

Closes #1964

Description

In the Live Viewer, the brightness of the image is now set using the 5th and 95th percentiles rather than min/max. This removes outliers and makes the brightness of the images consistent and easier to compare as data is read in.
Percentiles can be changed via self.image.use_brightness_percentiles(image, low, high) in mantidimaging/gui/windows/live_viewer/live_view_widget.py where low and high are the lower and higher percentiles respectively. The brightness levels are then passed though self.image.setImage(image, levels=self.image.brightLevels) in the Live Viewer only put are left as min/max elsewhere.

No slowdown has been noticed due to the percentile calculations.

Testing

Data was fed through the Live Viewer to verify the outliers where left out and the image brightness was consistent. This auto levelling is not done in normal operations outside of the Live Viewer.

Acceptance Criteria

Check standard tests and check brightness levels are correct in the Live Viewer.

@coveralls
Copy link

coveralls commented Nov 3, 2023

Coverage Status

coverage: 75.447% (+0.02%) from 75.43%
when pulling 8e9ee8f on 1964-live-viewer-brightness-percentiles
into 725b442 on main.

Copy link
Collaborator

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. A couple of comments.

  • Could you add a test

@@ -166,3 +170,8 @@ def update_sibling_histograms(self):
for img_view in self.histogram_siblings:
with BlockQtSignals(img_view.hist):
img_view.hist.setLevels(*hist_range)

def use_brightness_percentiles(self, image: np.ndarray, percent_low: int, percent_high: int, *args, **kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the *args, **kwargs part here, as its not being passed through in the this method.

@@ -35,7 +35,8 @@ def show_image(self, image: np.ndarray) -> None:
Show the image in the image view.
@param image: The image to show
"""
self.image.setImage(image)
self.image.use_brightness_percentiles(image, 5, 95)
self.image.setImage(image, levels=self.image.brightLevels)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can MIMiniImageView.setImage() do a check to see if the percentiles are being used, so that levels does not need to be passed in from outside. So this part would be

self.image.use_brightness_percentiles(image, 5, 95)
self.image.setImage(image)

Copy link
Collaborator

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Looks good.

@samtygier-stfc samtygier-stfc added this pull request to the merge queue Nov 7, 2023
Merged via the queue into main with commit 7e39d81 Nov 7, 2023
8 checks passed
@samtygier-stfc samtygier-stfc deleted the 1964-live-viewer-brightness-percentiles branch November 7, 2023 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Use percentiles rather than min max for auto brightness levels in live viewer
3 participants