def __init__(self, module_manager): SimpleVTKClassModuleBase.__init__( self, module_manager, vtk.vtkImageRGBToHSV(), 'Processing.', ('vtkImageData',), ('vtkImageData',), replaceDoc=True, inputFunctions=None, outputFunctions=None)
def __init__(self, module_manager): SimpleVTKClassModuleBase.__init__(self, module_manager, vtk.vtkImageRGBToHSV(), 'Processing.', ('vtkImageData', ), ('vtkImageData', ), replaceDoc=True, inputFunctions=None, outputFunctions=None)
imageCanvas.SetDrawColor(255, 255, 255) imageCanvas.FillBox(250, 300, 110, 210) # saturation scale imageCanvas.SetDrawColor(245, 0, 0) imageCanvas.FillBox(0, 50, 220, 320) imageCanvas.SetDrawColor(213, 16, 16) imageCanvas.FillBox(50, 100, 220, 320) imageCanvas.SetDrawColor(181, 32, 32) imageCanvas.FillBox(100, 150, 220, 320) imageCanvas.SetDrawColor(149, 48, 48) imageCanvas.FillBox(150, 200, 220, 320) imageCanvas.SetDrawColor(117, 64, 64) imageCanvas.FillBox(200, 250, 220, 320) imageCanvas.SetDrawColor(85, 80, 80) imageCanvas.FillBox(250, 300, 220, 320) convert = vtk.vtkImageRGBToHSV() convert.SetInputConnection(imageCanvas.GetOutputPort()) convertBack = vtk.vtkImageHSVToRGB() convertBack.SetInputConnection(convert.GetOutputPort()) cast = vtk.vtkImageCast() cast.SetInputConnection(convertBack.GetOutputPort()) cast.SetOutputScalarTypeToFloat() cast.ReleaseDataFlagOff() viewer = vtk.vtkImageViewer() viewer.SetInputConnection(convertBack.GetOutputPort()) #viewer SetInputConnection [imageCanvas GetOutputPort] viewer.SetColorWindow(256) viewer.SetColorLevel(127.5) viewer.Render() # --- end of script --
imageCanvas.SetDrawColor(255,255,255) imageCanvas.FillBox(250,300,110,210) # saturation scale imageCanvas.SetDrawColor(245,0,0) imageCanvas.FillBox(0,50,220,320) imageCanvas.SetDrawColor(213,16,16) imageCanvas.FillBox(50,100,220,320) imageCanvas.SetDrawColor(181,32,32) imageCanvas.FillBox(100,150,220,320) imageCanvas.SetDrawColor(149,48,48) imageCanvas.FillBox(150,200,220,320) imageCanvas.SetDrawColor(117,64,64) imageCanvas.FillBox(200,250,220,320) imageCanvas.SetDrawColor(85,80,80) imageCanvas.FillBox(250,300,220,320) convert = vtk.vtkImageRGBToHSV() convert.SetInputConnection(imageCanvas.GetOutputPort()) convertBack = vtk.vtkImageHSVToRGB() convertBack.SetInputConnection(convert.GetOutputPort()) cast = vtk.vtkImageCast() cast.SetInputConnection(convertBack.GetOutputPort()) cast.SetOutputScalarTypeToFloat() cast.ReleaseDataFlagOff() viewer = vtk.vtkImageViewer() viewer.SetInputConnection(convertBack.GetOutputPort()) #viewer SetInputConnection [imageCanvas GetOutputPort] viewer.SetColorWindow(256) viewer.SetColorLevel(127.5) viewer.Render() # --- end of script --
orgX = imageIn.GetExecutive().GetWholeExtent( imageIn.GetOutputInformation(0))[1]\ - imageIn.GetExecutive().GetWholeExtent( imageIn.GetOutputInformation(0))[0] + 1 orgY = imageIn.GetExecutive().GetWholeExtent( imageIn.GetOutputInformation(0))[3]\ - imageIn.GetExecutive().GetWholeExtent( imageIn.GetOutputInformation(0))[2] + 1 padX = PowerOfTwo(orgX) padY = PowerOfTwo(orgY) imagePowerOf2 = vtk.vtkImageConstantPad() imagePowerOf2.SetInputConnection(imageIn.GetOutputPort()) imagePowerOf2.SetOutputWholeExtent(0, padX - 1, 0, padY - 1, 0, 0) toHSV = vtk.vtkImageRGBToHSV() toHSV.SetInputConnection(imageIn.GetOutputPort()) toHSV.GetExecutive().SetReleaseDataFlag(0, 0) extractImage = vtk.vtkImageExtractComponents() extractImage.SetInputConnection(toHSV.GetOutputPort()) extractImage.SetComponents(2) extractImage.GetExecutive().SetReleaseDataFlag(0, 0) threshold1 = vtk.vtkImageThreshold() threshold1.SetInputConnection(extractImage.GetOutputPort()) threshold1.ThresholdByUpper(230) threshold1.SetInValue(255) threshold1.SetOutValue(0) threshold1.Update()
amt = expr.expr(globals(), locals(),["amt",">>","1"]) pow = pow + 1 if (amt <= 0): return expr.expr(globals(), locals(),["1","<<","pow"]) pass pass orgX = expr.expr(globals(), locals(),["lindex(imageIn.GetExecutive().GetWholeExtent(imageIn.GetOutputInformation(0)),1)","-","lindex(imageIn.GetExecutive().GetWholeExtent(imageIn.GetOutputInformation(0)),0)","+","1"]) orgY = expr.expr(globals(), locals(),["lindex(imageIn.GetExecutive().GetWholeExtent(imageIn.GetOutputInformation(0)),3)","-","lindex(imageIn.GetExecutive().GetWholeExtent(imageIn.GetOutputInformation(0)),2)","+","1"]) padX = PowerOfTwo(orgX) padY = PowerOfTwo(orgY) imagePowerOf2 = vtk.vtkImageConstantPad() imagePowerOf2.SetInputConnection(imageIn.GetOutputPort()) imagePowerOf2.SetOutputWholeExtent(0,expr.expr(globals(), locals(),["padX","-","1"]),0,expr.expr(globals(), locals(),["padY","-","1"]),0,0) toHSV = vtk.vtkImageRGBToHSV() toHSV.SetInputConnection(imageIn.GetOutputPort()) toHSV.GetExecutive().SetReleaseDataFlag(0,0) extractImage = vtk.vtkImageExtractComponents() extractImage.SetInputConnection(toHSV.GetOutputPort()) extractImage.SetComponents(2) extractImage.GetExecutive().SetReleaseDataFlag(0,0) threshold1 = vtk.vtkImageThreshold() threshold1.SetInputConnection(extractImage.GetOutputPort()) threshold1.ThresholdByUpper(230) threshold1.SetInValue(255) threshold1.SetOutValue(0) threshold1.Update() extent = threshold1.GetExecutive().GetWholeExtent(threshold1.GetOutputInformation(0)) connect = vtk.vtkImageSeedConnectivity() connect.SetInputConnection(threshold1.GetOutputPort())