Skip to content

Commit f94ccf0

Browse files
committed
Don't read full cube into mem for histogramming
1 parent 18f760d commit f94ccf0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/napari_matplotlib/histogram.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def draw(self) -> None:
3333
Clear the axes and histogram the currently selected layer/slice.
3434
"""
3535
layer = self.layers[0]
36-
bins = np.linspace(np.min(layer.data), np.max(layer.data), 100)
3736

3837
if layer.data.ndim - layer.rgb == 3:
3938
# 3D data, can be single channel or RGB
@@ -42,6 +41,10 @@ def draw(self) -> None:
4241
else:
4342
data = layer.data
4443

44+
# Important to calculate bins after slicing 3D data, to avoid reading
45+
# whole cube into memory.
46+
bins = np.linspace(np.min(layer.data), np.max(layer.data), 100)
47+
4548
if layer.rgb:
4649
# Histogram RGB channels independently
4750
for i, c in enumerate("rgb"):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy