[vtkusers] vtkDICOMImageReader -> vtkCutter -> vtkMarchingCubes
Jinyoung Hwang
hwangjinyoung at gmail.com
Thu Dec 24 21:31:58 EST 2009
Hello superZZ,
Actually I have no 3D DICOM file, I cannot test my code.
But I tested 2D DICOM file (single slice) as below.
--------------------------------------------------
// data load
vtkSmartPointer<vtkDICOMImageReader> reader =
vtkSmartPointer<vtkDICOMImageReader>::New();
reader->SetFileName("CT-MONO2-12-lomb-an2"); // this is a single slice data
reader->Update();
vtkSmartPointer<vtkImageCast> img = vtkSmartPointer<vtkImageCast>::New();
img->SetInputConnection(reader->GetOutputPort());
img->SetOutputScalarTypeToUnsignedChar();
// MC is used to display in 3D
vtkSmartPointer<vtkMarchingCubes> cubes =
vtkSmartPointer<vtkMarchingCubes>::New();
cubes->SetInputConnection(img->GetOutputPort());
cubes->ComputeNormalsOn();
cubes->ComputeGradientsOn();
cubes->SetValue(0, 20);
cubes->Update();
vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();
plane->SetOrigin(10,10,0);
plane->SetNormal(1,1,0);
vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();
cutter->SetInputConnection(cubes->GetOutputPort());
cutter->SetCutFunction(plane);
cutter->GenerateCutScalarsOff();
cutter->SetValue(0, 0.5);
cutter->Update();
// create a mapper
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(cutter->GetOutputPort());
mapper->ScalarVisibilityOn();
mapper->Update();
// create an actor
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
----------------
Something's wrong?
Jinyoung
2009/12/25 Jinyoung Hwang <hwangjinyoung at gmail.com>
> Hi vtkers,
>
> I uploaded a method to read a .vtk file in
> http://www.vtk.org/Wiki/Read_a_.vtk_file.
> Besides, I linked "test.vtk" and raw data on my ftp, so you can freely
> access to download.
> It's my first time to post my code in wiki, some mistakes might be
> happened. :)
>
> Happy new year.
>
> Jinyoung
>
> 2009/12/24 Jinyoung Hwang <hwangjinyoung at gmail.com>
>
> To David,
>>
>> How can I send my codes and data?
>>
>> Jinyoung
>>
>>
>>
>> 2009/12/24 KS Jothybasu <jothybasu at gmail.com>
>>
>> Thanks Jinyoung!
>>>
>>> I wish all the vtkusers list members a Merry Christmas and a very happy
>>> New Year!
>>>
>>> Best regards
>>>
>>> Jothy
>>>
>>>
>>> On Thu, Dec 24, 2009 at 10:09 AM, KS Jothybasu <jothybasu at gmail.com>wrote:
>>>
>>>> Thanks!
>>>>
>>>> Does the SetOrigin(100,0,0) mean a sagitall cut or cut in the X-plane at
>>>> 100th pixel and what does SetValue(0, 0.5) mean?
>>>>
>>>> Many thanks again
>>>>
>>>> Jothy
>>>>
>>>> On Thu, Dec 24, 2009 at 3:50 AM, Jinyoung Hwang <
>>>> hwangjinyoung at gmail.com> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I made an example you want, but it may not be.
>>>>> If not, repost again, then other will help you.
>>>>>
>>>>> Jinyoung
>>>>>
>>>>>
>>>>> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>>>>> // data load
>>>>> vtkSmartPointer<vtkStructuredPointsReader> reader =
>>>>> vtkSmartPointer<vtkStructuredPointsReader>::New();
>>>>> reader->SetFileName("test.vtk");
>>>>> reader->Update();
>>>>> // MC is used to display in 3D
>>>>> vtkSmartPointer<vtkMarchingCubes> cubes =
>>>>> vtkSmartPointer<vtkMarchingCubes>::New();
>>>>> cubes->SetInputConnection(reader->GetOutputPort());
>>>>> cubes->ComputeNormalsOn();
>>>>> cubes->ComputeGradientsOn();
>>>>> cubes->SetValue(0, 20);
>>>>> cubes->Update();
>>>>> // create a plane, and specify it
>>>>> vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();
>>>>> plane->SetOrigin(100,0,0);
>>>>> plane->SetNormal(1,0,0);
>>>>> // create a cutter
>>>>> vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();
>>>>> cutter->SetInputConnection(cubes->GetOutputPort());
>>>>> cutter->SetCutFunction(plane);
>>>>> cutter->GenerateCutScalarsOn();
>>>>> cutter->SetValue(0, 0.5);
>>>>> // create a mapper
>>>>> vtkSmartPointer<vtkPolyDataMapper> mapper =
>>>>> vtkSmartPointer<vtkPolyDataMapper>::New();
>>>>> mapper->SetInputConnection(cutter->GetOutputPort());
>>>>> mapper->ScalarVisibilityOn();
>>>>> mapper->Update();
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091225/082cf31b/attachment.htm>
More information about the vtkusers
mailing list