<div dir="ltr">And vtkDICOMImageReader depends on the slice thickness tag it seems, that's why the imageData->GetSpacing() <br><br>give 3.0 mm, which is wrong in this case.<br><br>Jothy<br><br><div class="gmail_quote">
On Fri, Mar 9, 2012 at 9:24 PM, Jothybasu Selvaraj <span dir="ltr"><<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi David,<br><br>Some stunning revelation here!<br><br>The problem is because of the inconsistence between the DICOM tags Slice thickness and ImagePositionPatient<br><br>Slice thickness says it's 3mm, but the z difference between two slices according to their IPP is 2.5 mm.<br>
<br>If I set the extrude->SetVector(0,0,-2.5).<br><br>It works perfectly!<br><br>How can it happen in DICOM? Probably, that's the reason why other datasets worked form me with the new vtkPolydataToImageStencil.<br>
<br>Can someone shed light on this?<br><br>Many thanks again<br><br>Jothy<div><div></div><div class="h5"><br><br> <br><br><div class="gmail_quote">On Fri, Mar 9, 2012 at 8:36 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jothy,<br>
<br>
Remove the extrude filter from the pipeline.<br>
<font color="#888888"><br>
- David<br>
</font><div><div></div><div><br>
<br>
On Fri, Mar 9, 2012 at 1:29 PM, Jothybasu Selvaraj <<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>> wrote:<br>
> Hi David,<br>
><br>
> I am still not able to fix this issue.<br>
><br>
> This is how I create the polydata and other pipeline.<br>
><br>
> vtkSmartPointer<vtkPoints> points =<br>
><br>
> vtkSmartPointer<vtkPoints>::New();<br>
><br>
> vtkSmartPointer<vtkCellArray> cells =<br>
><br>
> vtkSmartPointer<vtkCellArray>::New();<br>
><br>
> points->SetNumberOfPoints(npts+1);<br>
><br>
> cells->InsertNextCell(npts+1);<br>
><br>
> for(int p=0;p<npts;p++)<br>
><br>
> {<br>
><br>
><br>
><br>
> points->SetPoint( p, Xp, Yp,Zp );<br>
><br>
> cells->InsertCellPoint( p );<br>
><br>
> }<br>
><br>
> cells->InsertCellPoint(npts);<br>
><br>
> points->SetPoint(npts,pts[0],pts[1],pts[2]);//close contour<br>
><br>
><br>
> vtkSmartPointer<vtkPolyData>polydataContour=<br>
><br>
> vtkSmartPointer<vtkPolyData>::New();<br>
><br>
> polydataContour->Initialize();<br>
><br>
> polydataContour->SetLines(cells);<br>
><br>
> polydataContour->SetPoints(points);<br>
><br>
><br>
> //Here all contours are appended to vtkAppendPolydataFilter<br>
><br>
> vtkSmartPointer<vtkPolyDataToImageStencil> sts=<br>
> vtkSmartPointer<vtkPolyDataToImageStencil>::New();<br>
> sts->SetTolerance(1e-6);//very important<br>
> sts->SetInformationInput(binary_image);<br>
> vtkSmartPointer<vtkLinearExtrusionFilter> extrude=<br>
> vtkSmartPointer<vtkLinearExtrusionFilter>::New();<br>
> extrude->SetInput(appender->GetOutput());<br>
> extrude->CappingOff();//also tried ON<br>
> extrude->SetVector(0, 0,-zSpacing);//Correct Z spacing is<br>
> important<br>
> //qDebug()<<-zSpacing<<"-ve zSpacing";<br>
> sts->SetInput(extrude->GetOutput());<br>
><br>
><br>
> //qDebug()<<t->currentTime()<<"Stencil start";<br>
> vtkSmartPointer<vtkImageStencil> stencil=<br>
> vtkSmartPointer<vtkImageStencil>::New();<br>
> stencil->SetStencil(sts->GetOutput());<br>
> stencil->SetInput(binary_image);<br>
> stencil->ReverseStencilOn();<br>
> stencil->Update();<br>
><br>
><br>
> I am able to visualize the contour by setting appendFilter->GetOutput() to a<br>
> vtkPolyDataMapper.<br>
><br>
> Is there any thing wrong.<br>
><br>
> Thanks very much!<br>
><br>
> Jothy<br>
><br>
><br>
><br>
><br>
> On Tue, Mar 6, 2012 at 3:48 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>> wrote:<br>
>><br>
>> You'd have to use SetLines() instead of SetPolys(). And for<br>
>> polylines, the final point in the polyline has to connect to the first<br>
>> line to create a closed loop, so polylines cell arrays need an extra<br>
>> entry as compared to polygon cell arrays.<br>
>><br>
>> On Tue, Mar 6, 2012 at 8:36 AM, Jothybasu Selvaraj <<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>><br>
>> wrote:<br>
>> > I ma creating the polydat per conoutr like this<br>
>> ><br>
>> > vtkSmartPointer<vtkPolyData>polydataContour=<br>
>> ><br>
>> > vtkSmartPointer<vtkPolyData>::New();<br>
>> ><br>
>> > polydataContour->Initialize();<br>
>> ><br>
>> > polydataContour->SetPolys( cells );//vtkCellArray<br>
>> ><br>
>> > polydataContour->SetPoints( points);//vtkPoints<br>
>> ><br>
>> ><br>
>> > How should I do that?<br>
>> ><br>
>> > Thanks very much<br>
>> ><br>
>> > Jothy<br>
>> ><br>
>> ><br>
>> > On Tue, Mar 6, 2012 at 3:31 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> The contours must be polylines, not polygons, or it won't work.<br>
>> >><br>
>> >> On Tue, Mar 6, 2012 at 6:29 AM, Jothybasu Selvaraj<br>
>> >> <<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>><br>
>> >> wrote:<br>
>> >> > Yes, I have one contour for each z slice as a vtkPolyData. I will try<br>
>> >> > removing that.<br>
>> >> ><br>
>> >> > Thanks<br>
>> >> ><br>
>> >> ><br>
>> >> > On Tue, Mar 6, 2012 at 1:26 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>><br>
>> >> > wrote:<br>
>> >> >><br>
>> >> >> Do you have one contour for each Z slice? If so, then try removing<br>
>> >> >> the Extrude filter from your pipeline.<br>
>> >> >><br>
>> >> >><br>
>> >> >> On Tue, Mar 6, 2012 at 2:51 AM, Jothybasu Selvaraj<br>
>> >> >> <<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>><br>
>> >> >> wrote:<br>
>> >> >> > Another point here,<br>
>> >> >> ><br>
>> >> >> > I am creating a vtkPolyData for each contour and then adding it to<br>
>> >> >> > the<br>
>> >> >> > vtkAppendPolydataFilter, then the output of vtkAppenPolydataFilter<br>
>> >> >> > is<br>
>> >> >> > set as<br>
>> >> >> > input to vtkPolydataToImageStencil.<br>
>> >> >> ><br>
>> >> >> > Could this make any difference?<br>
>> >> >> ><br>
>> >> >> > Thanks<br>
>> >> >> ><br>
>> >> >> > Jothy<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > On Mon, Mar 5, 2012 at 7:49 PM, Jothybasu Selvaraj<br>
>> >> >> > <<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>><br>
>> >> >> > wrote:<br>
>> >> >> >><br>
>> >> >> >> No, it doesn't fix the problem.<br>
>> >> >> >><br>
>> >> >> >> But it seems to work fine for contours with z-spacing in steps of<br>
>> >> >> >> 1mm.<br>
>> >> >> >><br>
>> >> >> >> It is working well for a dataset with 3mm spacing but fails for<br>
>> >> >> >> 2.5<br>
>> >> >> >> mm.<br>
>> >> >> >><br>
>> >> >> >> Maybe I need to test it thoroughly. Can I use those cxx and .h<br>
>> >> >> >> from<br>
>> >> >> >> 5.6<br>
>> >> >> >> in<br>
>> >> >> >> 5.8, that would be a easy workaround.<br>
>> >> >> >><br>
>> >> >> >> Thanks<br>
>> >> >> >><br>
>> >> >> >> Jothy<br>
>> >> >> >><br>
>> >> >> >><br>
>> >> >> >> On Mon, Mar 5, 2012 at 4:01 PM, David Gobbi<br>
>> >> >> >> <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>><br>
>> >> >> >> wrote:<br>
>> >> >> >>><br>
>> >> >> >>> Hi Jothy,<br>
>> >> >> >>><br>
>> >> >> >>> It underwent significant changes, but the only change I can<br>
>> >> >> >>> think<br>
>> >> >> >>> of that might have affected your pipeline is the way that it<br>
>> >> >> >>> does<br>
>> >> >> >>> rounding, it used to use a Floor() method that provided a small<br>
>> >> >> >>> tolerance even if you did SetTolerance(0). Try calling<br>
>> >> >> >>> SetTolerance(1e-6) on your PolyDataToImageStencil object, it<br>
>> >> >> >>> might help.<br>
>> >> >> >>><br>
>> >> >> >>> - David<br>
>> >> >> >>><br>
>> >> >> >>> On Mon, Mar 5, 2012 at 3:17 AM, Jothybasu Selvaraj<br>
>> >> >> >>> <<a href="mailto:jothybasu@gmail.com" target="_blank">jothybasu@gmail.com</a>><br>
>> >> >> >>> wrote:<br>
>> >> >> >>> > Hi all,<br>
>> >> >> >>> ><br>
>> >> >> >>> > I was able to create a mesh using the following pipeline in<br>
>> >> >> >>> > 5.6<br>
>> >> >> >>> > and<br>
>> >> >> >>> > it<br>
>> >> >> >>> > worked well<br>
>> >> >> >>> ><br>
>> >> >> >>> ><br>
>> >> >> >>> ><br>
>> >> >> >>> ><br>
>> >> >> >>> ><br>
>> >> >> >>> > vtkPolyDataToImageStencil->vtkLinearExtrusionFilter->vtkImageStencil->vtkDiscreteMarchingCubes<br>
>> >> >> >>> ><br>
>> >> >> >>> > Now, I have updated vtk to 5.8 and I am getting gaps in the<br>
>> >> >> >>> > mesh<br>
>> >> >> >>> > along<br>
>> >> >> >>> > the z<br>
>> >> >> >>> > axis. I am really puzzled, I have tried with different data<br>
>> >> >> >>> > sets<br>
>> >> >> >>> > as<br>
>> >> >> >>> > well.<br>
>> >> >> >>> ><br>
>> >> >> >>> > I have read somewhere that vtkPolyDataToImageStencil had some<br>
>> >> >> >>> > changes<br>
>> >> >> >>> > in<br>
>> >> >> >>> > 5.8, does it has anything to do with this problem, or am I<br>
>> >> >> >>> > doing<br>
>> >> >> >>> > anything wrong?<br>
>> >> >> >>> ><br>
>> >> >> >>> > I have contours of constant z-spacing.<br>
>> >> >> >>> ><br>
>> >> >> >>> > Any hints?<br>
>> >> >> >>> ><br>
>> >> >> >>> > Thanks<br>
>> >> >> >>> ><br>
>> >> >> >>> > --<br>
>> >> >> >>> > Jothy<br>
>> >> >> >><br>
>> >> >> >><br>
>> >> >> >><br>
>> >> >> >><br>
>> >> >> >> --<br>
>> >> >> >> Jothy<br>
>> >> >> >><br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > --<br>
>> >> >> > Jothy<br>
>> >> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > --<br>
>> >> > Jothy<br>
>> >> ><br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > --<br>
>> > Jothy<br>
>> ><br>
><br>
><br>
><br>
><br>
> --<br>
> Jothy<br>
><br>
</div></div></blockquote></div><br><br clear="all"><br></div></div><font color="#888888">-- <br><div dir="ltr">Jothy<br></div><br>
</font></div>
</blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Jothy<br></div><br>
</div>