Skip to content

Commit

Permalink
cleanup debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
HastingsGreer committed Feb 4, 2019
1 parent 9d70a5d commit de1d18c
Showing 1 changed file with 29 additions and 33 deletions.
62 changes: 29 additions & 33 deletions server/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Protocol(helper.ObjectProtocol):
@rpc('median_filter')
@helper.objdir_wrap
def median_filter(self, image, radius):
print (itk.__path__)
itk_image = helper.vtkjs_to_itk_image(image)

median_filter = itk.MedianImageFilter[type(itk_image), type(itk_image)].New()
Expand All @@ -23,46 +22,43 @@ def median_filter(self, image, radius):
@rpc('otsu_segment_filter')
@helper.objdir_wrap
def otsu_segment_filter(self, image):
try:
print ("otsu_segment")

itk_image = helper.vtkjs_to_itk_image(image)

otsu_filter = itk.TubeTK.SegmentUsingOtsuThreshold[helper.itk_pixel_type(itk_image),
helper.itk_image_dimension(itk_image),
helper.itk_pixel_type(itk_image)].New()
otsu_filter.SetInput(itk_image)
otsu_filter.Update()
print ("otsu_segment")

itk_image = helper.vtkjs_to_itk_image(image)

otsu_filter = itk.TubeTK.SegmentUsingOtsuThreshold[helper.itk_pixel_type(itk_image),
helper.itk_image_dimension(itk_image),
helper.itk_pixel_type(itk_image)].New()
otsu_filter.SetInput(itk_image)
otsu_filter.Update()

result = otsu_filter.GetOutput()

result = otsu_filter.GetOutput()
# TODO auto-serialize in objdir_wrap?
return helper.itk_to_vtkjs_image(result)

# TODO auto-serialize in objdir_wrap?
return helper.itk_to_vtkjs_image(result)
except Exception as e:
print(e)

@rpc('segment')
@helper.objdir_wrap
def segment(self, image, point):
try:
itk_image = helper.vtkjs_to_itk_image(image)

itk_image = helper.vtkjs_to_itk_image(image)

itk_image = itk.CastImageFilter[type(itk_image), itk.Image[itk.F, 3]].New()(itk_image)
itk_image = itk.CastImageFilter[type(itk_image), itk.Image[itk.F, 3]].New()(itk_image)

print('segment at:', point)
print('segment at:', point)

tuber = itk.TubeTK.SegmentTubes[type(itk_image)].New()
tuber = itk.TubeTK.SegmentTubes[type(itk_image)].New()

tuber.SetInputImage(itk_image)
atube = tuber.ExtractTube(point, 0, True)
tube_py = []
for j in range(atube.GetNumberOfPoints()):
pt = atube.GetPoint(j)
pos = helper.itk_pos_to_array(pt.GetPosition())
radius = helper.spatial_object_pt_to_radius(pt)
tube_py.append({'point': pos, 'radius': radius},)
tuber.SetInputImage(itk_image)
atube = tuber.ExtractTube(point, 0, True)

tube_py = []
for j in range(atube.GetNumberOfPoints()):
pt = atube.GetPoint(j)
pos = helper.itk_pos_to_array(pt.GetPosition())
radius = helper.spatial_object_pt_to_radius(pt)
tube_py.append({'point': pos, 'radius': radius},)

return tube_py
except Exception as e:
print(e)
return tube_py

0 comments on commit de1d18c

Please sign in to comment.