From 9e6e2b60849cc23faa6fec135ab36b97af686474 Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Fri, 19 Feb 2010 12:43:10 +0000 Subject: [PATCH] FIX: Enhace quality of surface on an edited region #141 --- invesalius/data/imagedata_utils.py | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/invesalius/data/imagedata_utils.py b/invesalius/data/imagedata_utils.py index 7a7dbcc..5e718d3 100644 --- a/invesalius/data/imagedata_utils.py +++ b/invesalius/data/imagedata_utils.py @@ -151,19 +151,55 @@ def BuildEditedImage(imagedata, points): points in the editor, it is necessary to generate the vtkPolyData via vtkContourFilter """ + init_values = None for point in points: x, y, z = point colour = points[point] imagedata.SetScalarComponentFromDouble(x, y, z, 0, colour) imagedata.Update() + if not(init_values): + xi = x + xf = x + yi = y + yf = y + zi = z + zf = z + init_values = 1 + + if (xi > x): + xi = x + elif(xf < x): + xf = x + + if (yi > y): + yi = y + elif(yf < y): + yf = y + + if (zi > z): + zi = z + elif(zf < z): + zf = z + + clip = vtk.vtkImageClip() + clip.SetInput(imagedata) + clip.SetOutputWholeExtent(xi, xf, yi, yf, zi, zf) + clip.Update() + gauss = vtk.vtkImageGaussianSmooth() - gauss.SetInput(imagedata) + gauss.SetInput(clip.GetOutput()) gauss.SetRadiusFactor(0.6) gauss.Update() - return gauss.GetOutput() - #return imagedata + app = vtk.vtkImageAppend() + app.PreserveExtentsOn() + app.SetAppendAxis(2) + app.SetInput(0, imagedata) + app.SetInput(1, gauss.GetOutput()) + app.Update() + + return app.GetOutput() def Export(imagedata, filename, bin=False): -- libgit2 0.21.2