def getMIP(imageData, color):
    """
	A function that will take a volume and do a simple
				 maximum intensity projection that will be converted to a
				 wxBitmap
	"""
    maxval = imageData.GetScalarRange()[1]
    imageData.SetUpdateExtent(imageData.GetWholeExtent())

    if maxval > 255:
        shiftscale = vtk.vtkImageShiftScale()
        shiftscale.SetInputConnection(imageData.GetProducerPort())
        shiftscale.SetScale(255.0 / maxval)
        shiftscale.SetOutputScalarTypeToUnsignedChar()
        imageData = shiftscale.GetOutput()

    mip = vtkbxd.vtkImageSimpleMIP()
    mip.SetInputConnection(imageData.GetProducerPort())

    if color == None:
        output = optimize.execute_limited(mip)
        return output

    if mip.GetOutput().GetNumberOfScalarComponents() == 1:
        ctf = getColorTransferFunction(color)

        maptocolor = vtk.vtkImageMapToColors()
        maptocolor.SetInputConnection(mip.GetOutputPort())
        maptocolor.SetLookupTable(ctf)
        maptocolor.SetOutputFormatToRGB()
        imagedata = optimize.execute_limited(maptocolor)

    else:
        imagedata = output = optimize.execute_limited(mip)
    return imagedata
Example #2
0
def getMIP(imageData, color):
    """
	A function that will take a volume and do a simple
				 maximum intensity projection that will be converted to a
				 wxBitmap
	"""
    maxval = imageData.GetScalarRange()[1]
    imageData.SetUpdateExtent(imageData.GetWholeExtent())

    if maxval > 255:
        shiftscale = vtk.vtkImageShiftScale()
        shiftscale.SetInputConnection(imageData.GetProducerPort())
        shiftscale.SetScale(255.0 / maxval)
        shiftscale.SetOutputScalarTypeToUnsignedChar()
        imageData = shiftscale.GetOutput()

    mip = vtkbxd.vtkImageSimpleMIP()
    mip.SetInputConnection(imageData.GetProducerPort())

    if color == None:
        output = optimize.execute_limited(mip)
        return output

    if mip.GetOutput().GetNumberOfScalarComponents() == 1:
        ctf = getColorTransferFunction(color)

        maptocolor = vtk.vtkImageMapToColors()
        maptocolor.SetInputConnection(mip.GetOutputPort())
        maptocolor.SetLookupTable(ctf)
        maptocolor.SetOutputFormatToRGB()
        imagedata = optimize.execute_limited(maptocolor)

    else:
        imagedata = output = optimize.execute_limited(mip)
    return imagedata
	def testMIP(self):
		reader = vtkbxd.vtkLIFReader()
		reader.SetFileName(os.path.join(DATA_PATH, "512x_128y_10z_22t_2ch.lif"))
		reader.OpenFile()
		reader.Update()
		data = reader.GetOutput()
		mip = vtkbxd.vtkImageSimpleMIP()
		mip.SetInput(data)
		pngwriter  = vtk.vtkPNGWriter()
		pngwriter.SetInput(mip.GetOutput())
		mip.Update()
		pngwriter.SetFileName("lif.png")
		pngwriter.Write()
Example #4
0
 def testMIP(self):
     reader = vtkbxd.vtkLIFReader()
     reader.SetFileName(os.path.join(DATA_PATH,
                                     "512x_128y_10z_22t_2ch.lif"))
     reader.OpenFile()
     reader.Update()
     data = reader.GetOutput()
     mip = vtkbxd.vtkImageSimpleMIP()
     mip.SetInput(data)
     pngwriter = vtk.vtkPNGWriter()
     pngwriter.SetInput(mip.GetOutput())
     mip.Update()
     pngwriter.SetFileName("lif.png")
     pngwriter.Write()
Example #5
0
    def processOutputData(self, data):
        """
		Process the data before it's send to the preview
		"""
        data.UpdateInformation()
        if self.mode == 0:  # MIP mode
            if not self.mip:
                self.mip = vtkbxd.vtkImageSimpleMIP()
            else:
                self.mip.RemoveAllInputs()
            self.mip.SetInput(data)
            data = self.mip.GetOutput()
        else:  # AIP mode
            scalarType = data.GetScalarType()
            imgType = "IUC"
            if scalarType == 5:
                imgType = "IUS"
            elif scalarType == 9:
                imgType = "IUL"
            elif scalarType == 10:
                imgType = "IF"

            self.convVTKtoITK = eval("itk.VTKImageToImageFilter.%s3.New()" %
                                     imgType)
            if data.GetNumberOfScalarComponents() > 1:
                imageLuminance = vtk.vtkImageLuminance()
                imageLuminance.SetInput(data)
                data = imageLuminance.GetOutput()
            self.convVTKtoITK.SetInput(data)
            self.convVTKtoITK.Update()
            itkImg = self.convVTKtoITK.GetOutput()

            self.pif = eval("itk.MeanProjectionImageFilter.%s3%s2.New()" %
                            (imgType, imgType))
            self.pif.SetInput(itkImg)
            output = self.pif.GetOutput()

            self.convITKtoVTK = itk.ImageToVTKImageFilter[output].New()
            self.convITKtoVTK.SetInput(output)
            self.convITKtoVTK.Update()
            data = self.convITKtoVTK.GetOutput()

        return PreviewFrame.PreviewFrame.processOutputData(self, data)
	def processOutputData(self, data):
		"""
		Process the data before it's send to the preview
		"""
		data.UpdateInformation()
		if self.mode == 0: # MIP mode
			if not self.mip:
				self.mip = vtkbxd.vtkImageSimpleMIP()
			else:
				self.mip.RemoveAllInputs()
			self.mip.SetInput(data)
			data = self.mip.GetOutput()
		else: # AIP mode
			scalarType = data.GetScalarType()
			imgType = "IUC"
			if scalarType == 5:
				imgType = "IUS"
			elif scalarType == 9:
				imgType = "IUL"
			elif scalarType == 10:
				imgType = "IF"
			
			self.convVTKtoITK = eval("itk.VTKImageToImageFilter.%s3.New()"%imgType)
			if data.GetNumberOfScalarComponents() > 1:
				imageLuminance = vtk.vtkImageLuminance()
				imageLuminance.SetInput(data)
				data = imageLuminance.GetOutput()
			self.convVTKtoITK.SetInput(data)
			self.convVTKtoITK.Update()
			itkImg = self.convVTKtoITK.GetOutput()
			
			self.pif = eval("itk.MeanProjectionImageFilter.%s3%s2.New()"%(imgType,imgType))
			self.pif.SetInput(itkImg)
			output = self.pif.GetOutput()
			
			self.convITKtoVTK = itk.ImageToVTKImageFilter[output].New()
			self.convITKtoVTK.SetInput(output)
			self.convITKtoVTK.Update()
			data = self.convITKtoVTK.GetOutput()

		return PreviewFrame.PreviewFrame.processOutputData(self, data)
Example #7
0
merge = vtkbxd.vtkImageColorMerge()
#merge.SetNumberOfThreads(5)
merge.AddInput(d1)
merge.AddLookupTable(ctf1)
merge.AddIntensityTransferFunction(itf1)

itfmap = vtkbxd.vtkImageMapToIntensities()
itfmap.SetInput(d1)
itfmap.SetIntensityTransferFunction(itf1)

maptocolor = vtk.vtkImageMapToColors()
maptocolor.SetOutputFormatToRGB()
maptocolor.SetInput(itfmap.GetOutput())
maptocolor.SetLookupTable(ctf1)

mip = vtkbxd.vtkImageSimpleMIP()

print "Feeding merge to MIP", elapsed()
mip.SetInput(merge.GetOutput())

#flip =vtk.vtkImageFlip()
#flip.SetFilteredAxis(1)

#flip.SetInput(mip.GetOutput())
writer = vtk.vtkPNGWriter()
writer.SetFileName("ITFmapped.png")
writer.SetInput(mip.GetOutput())
print "Feeding MIP to writer ", elapsed()
writer.Update()
writer.Write()
print "Wrote PNG ", elapsed()
#merge.SetNumberOfThreads(5)
merge.AddInput(d1)
merge.AddLookupTable(ctf1)
merge.AddIntensityTransferFunction(itf1)

itfmap = vtkbxd.vtkImageMapToIntensities()
itfmap.SetInput(d1)
itfmap.SetIntensityTransferFunction(itf1)

maptocolor=vtk.vtkImageMapToColors()
maptocolor.SetOutputFormatToRGB()
maptocolor.SetInput(itfmap.GetOutput())
maptocolor.SetLookupTable(ctf1)


mip=vtkbxd.vtkImageSimpleMIP()

print "Feeding merge to MIP",elapsed()
mip.SetInput(merge.GetOutput())

#flip =vtk.vtkImageFlip()
#flip.SetFilteredAxis(1)

#flip.SetInput(mip.GetOutput())
writer=vtk.vtkPNGWriter()
writer.SetFileName("ITFmapped.png")
writer.SetInput(mip.GetOutput())
print "Feeding MIP to writer ",elapsed()
writer.Update()
writer.Write()
print "Wrote PNG ",elapsed()