<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
        {mso-style-link:"E-mail Signature Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.E-mailSignatureChar
        {mso-style-name:"E-mail Signature Char";
        mso-style-link:"E-mail Signature";
        font-family:"Times New Roman","serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal>Hello everyone,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I have a vtkImageData that I want to extract a Region of
Interest from using a polygon’s points, vtkImplicitSelectionLoop and
vtkClipDataset. Basically, this operation seems slow to me so I’m
trying to speed it up by first using vtkExtractVOI to get ONLY the image data
within the bounds of the polygon, and then Clip only that. (if there’s
a better way to speed this up please let me know!) When I run the image
through vtkExtractVOI I find that the output has a bounds that is different
from the VOI (xmin,xmax,ymin,ymax,zmin,zmax) that I gave the filter. Why
is this happening? Here is my code:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> //Get
the world points of the polygon<o:p></o:p></p>
<p class=MsoNormal> vtkPoints
* Points = GetPoints();<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> //get
the current image<o:p></o:p></p>
<p class=MsoNormal> vtkImageData
* Image = GetImage()<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> //get
the bounding box of the polygon<o:p></o:p></p>
<p class=MsoNormal> double
* b = Points->GetBounds();<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> Extract->SetInput(Image);<o:p></o:p></p>
<p class=MsoNormal> Extract->SetVOI(b[0],b[1],b[2],b[3],b[4],b[5]);<o:p></o:p></p>
<p class=MsoNormal> Extract->Modified();<o:p></o:p></p>
<p class=MsoNormal> Extract->UpdateInformation();<o:p></o:p></p>
<p class=MsoNormal> Extract->UpdateWholeExtent();<o:p></o:p></p>
<p class=MsoNormal> Extract->Update();<o:p></o:p></p>
<p class=MsoNormal> <o:p></o:p></p>
<p class=MsoNormal> //get
the output<o:p></o:p></p>
<p class=MsoNormal> vtkImageData
* voi = Extract->GetOutput();<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> //check
the output bounds – Here’s where the vb[0]-vb[5] differs from the
initial values given (b[0]-b[5])<o:p></o:p></p>
<p class=MsoNormal> //there
is a difference of at least 20 in all the values<o:p></o:p></p>
<p class=MsoNormal> double
* vb = voi->GetBounds();<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> //get
the current data<o:p></o:p></p>
<p class=MsoNormal> vtkUnstructuredGrid
* Data = GetData();<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal> //extract
using the ‘loop’ defined by the polygon’s world points<o:p></o:p></p>
<p class=MsoNormal> Loop->SetLoop(Points);<o:p></o:p></p>
<p class=MsoNormal> Clip->SetClipFunction(Loop);<o:p></o:p></p>
<p class=MsoNormal> Clip->SetInput(Extract->GetOutput());<o:p></o:p></p>
<p class=MsoNormal> Clip->SetOutput(Data);<o:p></o:p></p>
<p class=MsoNormal> Clip->InsideOutOn();<o:p></o:p></p>
<p class=MsoNormal> Clip->Modified();<o:p></o:p></p>
<p class=MsoNormal> Clip->Update();<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Any help would be appreciated. Alternatively, if
anyone out there knows and would like to share a good method of determining
whether a point is within a polygon or not, that would also be useful.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Beau<o:p></o:p></p>
</div>
</body>
</html>