本文整理匯總了Python中ij.gui.GenericDialog.getSliders方法的典型用法代碼示例。如果您正苦於以下問題:Python GenericDialog.getSliders方法的具體用法?Python GenericDialog.getSliders怎麽用?Python GenericDialog.getSliders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ij.gui.GenericDialog
的用法示例。
在下文中一共展示了GenericDialog.getSliders方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: int
# 需要導入模塊: from ij.gui import GenericDialog [as 別名]
# 或者: from ij.gui.GenericDialog import getSliders [as 別名]
from java.awt.event import AdjustmentListener
from java.lang import Math, System
image = WindowManager.getCurrentImage()
ip = image.getProcessor()
pixelsCopy = ip.getPixelsCopy()
pixels = ip.getPixels()
width = ip.getWidth()
height = ip.getHeight()
minWidth = int(Math.sqrt(len(pixels) / 16))
maxWidth = minWidth * 16
class Listener(AdjustmentListener):
def adjustmentValueChanged(self, event):
value = event.getSource().getValue()
rowstride = min(width, value)
for j in range(0, min(height, int(width * height / value))):
System.arraycopy(pixelsCopy, j * value,
pixels, j * width, rowstride)
image.updateAndDraw()
gd = GenericDialog("Width")
gd.addSlider("width", minWidth, maxWidth, ip.getHeight())
gd.getSliders().get(0).addAdjustmentListener(Listener())
gd.showDialog()
if gd.wasCanceled():
pixels[0:width * height] = pixelsCopy
image.updateAndDraw()