def setImageNumpy(self, img):
     vtkImg = vnp.numpyToImageData(img)
     self.setImage(vtkImg)
 def setImageNumpy(self, img):
     vtkImg = vnp.numpyToImageData(img)
     self.setImage(vtkImg)
Example #3
0
from director import imageview
from director import consoleapp
import director.vtkAll as vtk
import director.vtkNumpy as vnp

# create a vtkImageData object
s = vtk.vtkRTAnalyticSource()
s.SetWholeExtent(-100, 100, -100, 100, 0, 0)
s.Update()
image = s.GetOutput()

# get image data as a numpy array
w, h, _ = image.GetDimensions()
img = vnp.getNumpyFromVtk(image, 'RTData').reshape(h, w, -1)

# show numpy image data
view = imageview.ImageView()
view.showNumpyImage(img)
view.show()

# convert back to vtkImageData and show
view2 = imageview.ImageView()
view2.setImage(vnp.numpyToImageData(img))
view2.show()

consoleapp.ConsoleApp.start()
from director import imageview
from director import consoleapp
import director.vtkAll as vtk
import director.vtkNumpy as vnp


# create a vtkImageData object
s = vtk.vtkRTAnalyticSource()
s.SetWholeExtent(-100, 100, -100, 100, 0, 0)
s.Update()
image = s.GetOutput()

# get image data as a numpy array
w,h,_ = image.GetDimensions()
img = vnp.getNumpyFromVtk(image, 'RTData').reshape(h,w,-1)

# show numpy image data
view = imageview.ImageView()
view.showNumpyImage(img)
view.show()

# convert back to vtkImageData and show
view2 = imageview.ImageView()
view2.setImage(vnp.numpyToImageData(img))
view2.show()

consoleapp.ConsoleApp.start()
Example #5
0
        #simulate depth image
        model_path = "../models/net_depth_seg_v1.hdf5"
        model = network.load_trained_model(weights_path=model_path)
        threshold = .5
        img_height, img_width = (480, 640)
        stack = np.zeros((1, img_height, img_width, 1))
        vtk_array = scale.GetOutput().GetPointData().GetScalars()
        im = np.flip(numpy_support.vtk_to_numpy(vtk_array).reshape(
            img_height, 2 * img_width)[:, :640] / 3500.,
                     axis=0)
        stack[0, :, :, 0] = im
        predicted_prob_map = model.predict_on_batch(stack)
        network.apply_mask(predicted_prob_map, depthsim_source, threshold)
        im_depth_sim_vtk = vnp.numpyToImageData(np.reshape(
            depthsim_source, (480, 640, 1)),
                                                vtktype=vtk.VTK_FLOAT)

        #simulate real
        real_depth = misc.imread(depthFile)
        source_real[real_depth == 0] = 0
        real_depth_vtk = vnp.numpyToImageData(np.reshape(
            source_real, (480, 640, 1)),
                                              vtktype=vtk.VTK_FLOAT)

        #simulate kunis
        normals = util.ratio_from_normal(
            util.convert_rgb_normal(misc.imread(normalFile)))
        source_kuni[normals < .3] = 0
        kuni_depth_vtk = vnp.numpyToImageData(np.reshape(
            source_kuni, (480, 640, 1)),