本文整理汇总了Python中Image.Image.setPixelType方法的典型用法代码示例。如果您正苦于以下问题:Python Image.setPixelType方法的具体用法?Python Image.setPixelType怎么用?Python Image.setPixelType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image.Image
的用法示例。
在下文中一共展示了Image.setPixelType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compute
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import setPixelType [as 别名]
def compute(self):
im = self.get_input("Input Image")
#check for input PixelType
if self.has_input("Input PixelType"):
inPixelType = self.get_input("Input PixelType")
else:
inPixelType = im.getPixelType()
#check for dimension
if self.has_input("Dimension"):
dim = self.get_input("Dimension")
else:
dim = im.getDim()
#setup filter
inImgType = itk.Image[inPixelType._type, dim]
up = self.get_input("Upper Value")
lo = self.get_input("Lower Value")
self.filter_ = itk.ThresholdImageFilter[inImgType].New(im.getImg())
self.filter_.SetUpper(up)
self.filter_.SetLower(lo)
# self.filter_.ThresholdAbove(up)
self.filter_.Update()
#setup output image
outIm = Image()
outIm.setImg(self.filter_.GetOutput())
outIm.setPixelType(inPixelType)
outIm.setDim(dim)
self.set_output("Output Image", outIm)
示例2: compute
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import setPixelType [as 别名]
def compute(self):
im = self.get_input("Input Image")
#check for input PixelType
if self.has_input("Input PixelType"):
inPixelType = self.get_input("Input PixelType")
else:
inPixelType = im.getPixelType()
#check for output PixelType
if self.has_input("Output PixelType"):
outPixelType = self.get_input("Output PixelType")
else:
outPixelType = inPixelType
#check for dimension
if self.has_input("Dimension"):
dim = self.get_input("Dimension")
else:
dim = im.getDim()
#set up filter
inImgType = itk.Image[inPixelType._type, dim]
outImgType = itk.Image[outPixelType._type, dim]
if self.has_input("Upper Threshold"):
upper_threshold = self.get_input("Upper Threshold")
else:
upper_threshold = 255
lower_threshold = self.get_input("Lower Threshold")
if self.has_input("Outside Value"):
outside_value = self.get_input("Outside Value")
else:
outside_value = 0
if self.has_input("Inside Value"):
inside_value = self.get_input("Inside Value")
else:
inside_value = 255
self.filter_ = itk.BinaryThresholdImageFilter[inImgType, outImgType].New(im.getImg())
self.filter_.SetUpperThreshold(upper_threshold)
self.filter_.SetLowerThreshold(lower_threshold)
self.filter_.SetOutsideValue(outside_value)
self.filter_.SetInsideValue(inside_value)
self.filter_.Update()
#setup output image
outIm = Image()
outIm.setImg(self.filter_.GetOutput())
outIm.setPixelType(outPixelType)
outIm.setDim(dim)
#set results
self.set_output("Output Image", outIm)
self.set_output("Filter", self)
self.set_output("Output PixelType", outPixelType)
示例3: compute
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import setPixelType [as 别名]
def compute(self):
im = self.get_input("Input Image")
#check for input PixelType
if self.has_input("Input PixelType"):
inPixelType = self.get_input("Input PixelType")
else:
inPixelType = im.getPixelType()
#check for dimension
if self.has_input("Dimension"):
dim = self.get_input("Dimension")
else:
dim = im.getDim()
#set up filter
inImgType = itk.Image[inPixelType._type, dim]
try:
self.filter_ = itk.CurvatureAnisotropicDiffusionImageFilter[inImgType, inImgType].New(im.getImg())
except:
raise ModuleError(self, "Filter requires a decimal PixelType")
#default values are recommended
if self.has_input("Iterations"):
iterations = self.get_input("Iterations")
else:
iterations = 5
if self.has_input("TimeStep"):
timestep = self.get_input("TimeStep")
else:
if dim == 2:
timestep = 0.125
else:
timestep = 0.0625
if self.has_input("Conductance"):
conductance = self.get_input("Conductance")
else:
conductance = 3.0
self.filter_.SetNumberOfIterations(iterations)
self.filter_.SetTimeStep(timestep)
self.filter_.SetConductanceParameter(conductance)
self.filter_.Update()
#setup output image
outIm = Image()
outIm.setImg(self.filter_.GetOutput())
outIm.setPixelType(inPixelType)
outIm.setDim(dim)
self.set_output("Output Image", outIm)
self.set_output("Filter", self)
示例4: compute
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import setPixelType [as 别名]
def compute(self):
im = self.getInputFromPort("Input Image")
#check for input PixelType
if self.hasInputFromPort("Input PixelType"):
inPixelType = self.getInputFromPort("Input PixelType")
else:
inPixelType = im.getPixelType()
#check for output PixelType
if self.hasInputFromPort("Output PixelType"):
outPixelType = self.getInputFromPort("Output PixelType")
else:
outPixelType = inPixelType
#check for dimension
if self.hasInputFromPort("Input Dimension"):
dim = self.getInputFromPort("Input Dimension")
else:
dim = im.getDim()
if self.hasInputFromPort("Output Dimension"):
outDim = self.getInputFromPort("Output Dimension")
else:
outDim = dim
#set up filter
inImgType = itk.Image[inPixelType._type, dim]
outImgType = itk.Image[outPixelType._type, outDim]
self.filter_ = itk.RegionOfInterestImageFilter[inImgType, outImgType].New()
#TODO this is not correct, needs fixing
if self.hasInputFromPort("Input Region"):
self.region_ = self.getInputFromPort("Input Region").region_
else:
self.region_ = itk.ImageRegion[indim]()
self.setStart(indim)
self.region_.SetSize(self.getInputFromPort("Region Size").size_)
self.filter_.SetRegionOfInterest(self.region_)
self.filter_.SetInput(im.getImg())
self.filter_.Update()
#setup output image
outIm = Image()
outIm.setImg(self.filter_.GetOutput())
outIm.setPixelType(outPixelType)
outIm.setDim(outDim)
self.setResult("Output Image", outIm)
self.setResult("Output PixelType", outPixelType)
self.setResult("Output Dimension", outDim)
self.setResult("Filter", self)
示例5: compute
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import setPixelType [as 别名]
def compute(self):
im = self.get_input("Input Image")
#check for input PixelType
if self.has_input("Input PixelType"):
inPixelType = self.get_input("Input PixelType")
else:
inPixelType = im.getPixelType()
#check for output PixelType
if self.has_input("Output PixelType"):
outPixelType = self.get_input("Output PixelType")
else:
outPixelType = inPixelType
#check for dimension
if self.has_input("Dimension"):
dim = self.get_input("Dimension")
else:
dim = im.getDim()
if self.has_input("Seed2D"):
seed = self.get_input("Seed2D")
else:
seed = self.get_input("Seed3D")
replace = self.get_input("Replace Value")
multiplier = self.get_input("Multiplier")
iterations = self.get_input("Iterations")
radius = self.get_input("Neighborhood Radius")
#setup filter
inImgType = itk.Image[inPixelType._type,dim]
outImgType = itk.Image[outPixelType._type,dim]
self.filter_ = itk.ConfidenceConnectedImageFilter[inImgType,outImgType].New(im.getImg())
self.filter_.SetReplaceValue(replace)
self.filter_.SetMultiplier(multiplier)
self.filter_.SetNumberOfIterations(iterations)
self.filter_.SetInitialNeighborhoodRadius(radius)
self.filter_.SetSeed(seed.ind_)
self.filter_.Update()
#setup output image
outIm = Image()
outIm.setImg(self.filter_.GetOutput())
outIm.setPixelType(outPixelType)
outIm.setDim(dim)
self.set_output("Output Image", outIm)
self.set_output("Output PixelType", outPixelType)
示例6: compute
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import setPixelType [as 别名]
def compute(self):
im = self.getInputFromPort("Input Image")
#check for input PixelType
if self.hasInputFromPort("Input PixelType"):
inPixelType = self.getInputFromPort("Input PixelType")
else:
inPixelType = im.getPixelType()
#check for output PixelType
if self.hasInputFromPort("Output PixelType"):
outPixelType = self.getInputFromPort("Output PixelType")
else:
outPixelType = inPixelType
#check for dimension
if self.hasInputFromPort("Dimension"):
dim = self.getInputFromPort("Dimension")
else:
dim = im.getDim()
seed1 = self.getInputFromPort("Seed1")
seed2 = self.getInputFromPort("Seed2")
replace = self.getInputFromPort("Replace Value")
t_lower = self.getInputFromPort("Lower Value")
t_upper = self.getInputFromPort("Upper Value")
inImgType = itk.Image[inPixelType._type,dim]
outImgType = itk.Image[outPixelType._type,dim]
self.filter_ = itk.IsolatedConnectedImageFilter[inImgType,outImgType].New(im.getImg())
self.filter_.SetReplaceValue(replace)
self.filter_.SetLower(t_lower)
self.filter_.SetUpperValueLimit(t_upper)
self.filter_.SetSeed1(seed1.ind_)
self.filter_.SetSeed2(seed2.ind_)
self.filter_.Update()
#setup output image
outIm = Image()
outIm.setImg(self.filter_.GetOutput())
outIm.setPixelType(outPixelType)
outIm.setDim(dim)
self.setResult("Output Image", outIm)
self.setResult("Output PixelType", outPixelType)
示例7: compute
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import setPixelType [as 别名]
def compute(self):
dim = self.getInputFromPort("Dimension")
outPixelType = self.getInputFromPort("Pixel Type")
fn = self.getInputFromPort("Filename")
self.reader = itk.ImageFileReader[itk.Image[outPixelType._type, dim]].New()
self.reader.SetFileName(fn)
self.reader.Update()
#setup output image
outIm = Image()
outIm.setImg(self.reader.GetOutput())
outIm.setPixelType(outPixelType)
outIm.setDim(dim)
self.setResult("Image", outIm)
self.setResult("Reader", self)
示例8: compute
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import setPixelType [as 别名]
def compute(self):
print "comput"
im = self.get_input("Input Image")
#check for input PixelType
if self.has_input("Input PixelType"):
inPixelType = self.get_input("Input PixelType")
else:
inPixelType = im.getPixelType()
#check for output PixelType
if self.has_input("Output PixelType"):
outPixelType = self.get_input("Output PixelType")
else:
outPixelType = inPixelType
#check for dimension
if self.has_input("Dimension"):
dim = self.get_input("Dimension")
else:
dim = im.getDim()
kernel = self.get_input("Kernel")
#set up filter
inImgType = itk.Image[inPixelType._type, dim]
outImgType = itk.Image[outPixelType._type, dim]
erode_value = self.get_input("Erode Value")
self.filter_ = itk.BinaryErodeImageFilter[inImgType, outImgType, kernel].New(im.getImg())
self.filter_.SetKernel(kernel)
self.filter_.SetErodeValue(erode_value)
self.filter_.Update()
#setup output image
outIm = Image()
outIm.setImg(self.filter_.GetOutput())
outIm.setPixelType(outPixelType)
outIm.setDim(dim)
#set results
self.set_output("Output Image", outIm)
self.set_output("Filter", self)
self.set_output("Output PixelType", outPixelType)
示例9: compute
# 需要导入模块: from Image import Image [as 别名]
# 或者: from Image.Image import setPixelType [as 别名]
def compute(self):
im = self.getInputFromPort("Input Image")
#check for input PixelType
if self.hasInputFromPort("Input PixelType"):
inPixelType = self.getInputFromPort("Input PixelType")
else:
inPixelType = im.getPixelType()
#check for output PixelType
if self.hasInputFromPort("Output PixelType"):
outPixelType = self.getInputFromPort("Output PixelType")
else:
outPixelType = inPixelType
#check for dimension
if self.hasInputFromPort("Dimension"):
dim = self.getInputFromPort("Dimension")
else:
dim = im.getDim()
#set up filter
inImgType = itk.Image[inPixelType._type, dim]
outImgType = itk.Image[outPixelType._type, dim]
squared_distance = self.getInputFromPort("Squared Distance")
image_spaceing = self.getInputFromPort("Image Spaceing")
self.filter_ = itk.DanielssonDistanceMapImageFilter[inImgType, outImgType].New(im.getImg())
self.filter_.SetSquaredDistance(squared_distance)
self.filter_.SetUseImageSpacing(image_spaceing)
self.filter_.Update()
#setup output image
outIm = Image()
outIm.setImg(self.filter_.GetOutput())
outIm.setPixelType(outPixelType)
outIm.setDim(dim)
#set results
self.setResult("Output Image", outIm)
self.setResult("Filter", self)
self.setResult("Output PixelType", outPixelType)