本文整理汇总了Python中silx.gui.plot.PlotWidget.setActiveImage方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWidget.setActiveImage方法的具体用法?Python PlotWidget.setActiveImage怎么用?Python PlotWidget.setActiveImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silx.gui.plot.PlotWidget
的用法示例。
在下文中一共展示了PlotWidget.setActiveImage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestActiveImageAlphaSlider
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import setActiveImage [as 别名]
class TestActiveImageAlphaSlider(TestCaseQt):
def setUp(self):
super(TestActiveImageAlphaSlider, self).setUp()
self.plot = PlotWidget()
self.aslider = AlphaSlider.ActiveImageAlphaSlider(plot=self.plot)
self.aslider.setOrientation(qt.Qt.Horizontal)
toolbar = qt.QToolBar("plot", self.plot)
toolbar.addWidget(self.aslider)
self.plot.addToolBar(toolbar)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.mouseMove(self.plot) # Move to center
self.qapp.processEvents()
def tearDown(self):
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
del self.aslider
super(TestActiveImageAlphaSlider, self).tearDown()
def testWidgetEnabled(self):
# no active image initially, slider must be deactivate
self.assertFalse(self.aslider.isEnabled())
self.plot.addImage(numpy.array([[0, 1, 2], [3, 4, 5]]))
# now we have an active image
self.assertTrue(self.aslider.isEnabled())
self.plot.setActiveImage(None)
self.assertFalse(self.aslider.isEnabled())
def testGetImage(self):
self.plot.addImage(numpy.array([[0, 1, 2], [3, 4, 5]]))
self.assertEqual(self.plot.getActiveImage(),
self.aslider.getItem())
self.plot.addImage(numpy.array([[0, 1, 3], [2, 4, 6]]), legend="2")
self.plot.setActiveImage("2")
self.assertEqual(self.plot.getImage("2"),
self.aslider.getItem())
def testGetAlpha(self):
self.plot.addImage(numpy.array([[0, 1, 2], [3, 4, 5]]), legend="1")
self.aslider.setValue(137)
self.assertAlmostEqual(self.aslider.getAlpha(),
137. / 255)
示例2: SilxMaskImageWidget
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import setActiveImage [as 别名]
#.........这里部分代码省略.........
"""Show data image corresponding to index. Update slider to index.
"""
if not self._images:
return
assert index < len(self._images)
bg_index = None
if self.backgroundButton.isChecked():
for i, imageName in enumerate(self._labels):
if imageName.lower().endswith('background'):
bg_index = i
break
mf_text = ""
a = self._medianParameters['row_width']
b = self._medianParameters['column_width']
if max(a, b) > 1:
mf_text = "MF(%d,%d) " % (a, b)
imdata = self._getMedianData(self._images[index])
if bg_index is None:
self.plot.setGraphTitle(mf_text + self._labels[index])
else:
self.plot.setGraphTitle(mf_text + self._labels[index] + " Net")
imdata -= self._images[bg_index]
self.plot.addImage(imdata,
legend="current",
origin=self._origin,
scale=self._deltaXY,
replace=False,
z=0,
info=self._infos[index])
self.plot.setActiveImage("current")
self.slider.setValue(index)
def _getMedianData(self, data):
data = copy.copy(data)
if max(self._medianParameters['row_width'],
self._medianParameters['column_width']) > 1:
data = medfilt2d(data,
[self._medianParameters['row_width'],
self._medianParameters['column_width']],
conditional=self._medianParameters['conditional'])
return data
def setImages(self, images, labels=None,
origin=None, height=None, width=None,
infos=None):
"""Set the list of data images.
All images share the same origin, width and height.
:param images: List of 2D or 3D (for RGBA data) numpy arrays
of image data. All images must have the same shape.
:type images: List of ndarrays
:param labels: list of image names
:param origin: Image origin: coordinate (x, y) of sample located at
(row, column) = (0, 0). If None, use (0., 0.)
:param height: Image height in Y axis units. If None, use the
image height in number of pixels.
:param width: Image width in X axis units. If None, use the
image width in number of pixels.
:param infos: List of info dicts, one per image, or None.
"""
self._images = images
示例3: setActiveImage
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import setActiveImage [as 别名]
def setActiveImage(self, *var, **kw):
if "replot" in kw:
del kw["replot"]
return PlotWidget.setActiveImage(self, *var, **kw)