Merge pull request #1311 from campagnola/acq4-merge
performance fix for histogramlutitem
This commit is contained in:
commit
4562c06576
@ -165,7 +165,7 @@ class HistogramLUTItem(GraphicsWidget):
|
|||||||
"""
|
"""
|
||||||
self.imageItem = weakref.ref(img)
|
self.imageItem = weakref.ref(img)
|
||||||
img.sigImageChanged.connect(self.imageChanged)
|
img.sigImageChanged.connect(self.imageChanged)
|
||||||
img.setLookupTable(self.getLookupTable) ## send function pointer, not the result
|
self._setImageLookupTable()
|
||||||
self.regionChanged()
|
self.regionChanged()
|
||||||
self.imageChanged(autoLevel=True)
|
self.imageChanged(autoLevel=True)
|
||||||
|
|
||||||
@ -174,14 +174,17 @@ class HistogramLUTItem(GraphicsWidget):
|
|||||||
|
|
||||||
def gradientChanged(self):
|
def gradientChanged(self):
|
||||||
if self.imageItem() is not None:
|
if self.imageItem() is not None:
|
||||||
|
self._setImageLookupTable()
|
||||||
|
|
||||||
|
self.lut = None
|
||||||
|
self.sigLookupTableChanged.emit(self)
|
||||||
|
|
||||||
|
def _setImageLookupTable(self):
|
||||||
if self.gradient.isLookupTrivial():
|
if self.gradient.isLookupTrivial():
|
||||||
self.imageItem().setLookupTable(None) #lambda x: x.astype(np.uint8))
|
self.imageItem().setLookupTable(None) #lambda x: x.astype(np.uint8))
|
||||||
else:
|
else:
|
||||||
self.imageItem().setLookupTable(self.getLookupTable) ## send function pointer, not the result
|
self.imageItem().setLookupTable(self.getLookupTable) ## send function pointer, not the result
|
||||||
|
|
||||||
self.lut = None
|
|
||||||
self.sigLookupTableChanged.emit(self)
|
|
||||||
|
|
||||||
def getLookupTable(self, img=None, n=None, alpha=None):
|
def getLookupTable(self, img=None, n=None, alpha=None):
|
||||||
"""Return a lookup table from the color gradient defined by this
|
"""Return a lookup table from the color gradient defined by this
|
||||||
HistogramLUTItem.
|
HistogramLUTItem.
|
||||||
@ -341,6 +344,7 @@ class HistogramLUTItem(GraphicsWidget):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def restoreState(self, state):
|
def restoreState(self, state):
|
||||||
|
if 'mode' in state:
|
||||||
self.setLevelMode(state['mode'])
|
self.setLevelMode(state['mode'])
|
||||||
self.gradient.restoreState(state['gradient'])
|
self.gradient.restoreState(state['gradient'])
|
||||||
self.setLevels(*state['levels'])
|
self.setLevels(*state['levels'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user