[vtkusers] how to visualise a RAW volume dataset using C++ in Visual Studio

Gururajan.R gururajan.r at raster.in
Mon Sep 7 06:25:44 EDT 2009


If am not wrong with your question, then you can use the following to
read raw file into vtk file set like(vtk file)

Guru

    vtkDICOMImageReader dicomreader = new vtkDICOMImageReader();
        dicomreader    .SetDirectoryName("/home/guru/Desktop/3D/DCM");
        dicomreader.Update();
       
        vtkImageWriter writer = new vtkImageWriter();//
vtkImageWriter::New()
        writer.SetInput(dicomreader.GetOutput());
        writer.SetFilePrefix("/home/guru/workspace/ThreeD/Raw/");
        writer.SetFilePattern("%s%3d.dcm.raw");
        writer.Write();
        writer.Update();

        vtkVolume16Reader v16 = new vtkVolume16Reader();
        v16.SetDataByteOrderToLittleEndian();
        v16    .SetFilePrefix("/home/guru/workspace/ThreeD/Raw/");
        v16.SetFilePattern("%s%3d.dcm.raw");
       
        v16.SetImageRange(0,100);
        v16.GetOutput().ReleaseDataFlagOn();
        v16.SetDataSpacing(dicomreader.GetDataSpacing());
        v16.SetDataDimensions(dicomreader.GetOutput().GetDimensions());
        v16.Update();
       
        vtkMarchingCubes surfaceExtractor = new vtkMarchingCubes();
        surfaceExtractor.SetInput(v16.GetOutput());
        surfaceExtractor.ComputeNormalsOn();
        surfaceExtractor.ComputeGradientsOn();
        surfaceExtractor.SetValue(0, 500);
   
       
        vtkDecimatePro deci = new vtkDecimatePro();
        deci.SetInput(surfaceExtractor.GetOutput());
        deci.SetTargetReduction(100);
        deci.PreserveTopologyOff();
       
        /*
         vtkImageGaussianSmooth GauSmooth = new vtkImageGaussianSmooth();
         GauSmooth.SetInput(surfaceExtractor.GetOutput());
         GauSmooth.SetDimensionality(3);
         GauSmooth.SetStandardDeviation(0.0, 4.0);
         GauSmooth.SetNumberOfThreads(100);
        */
        vtkSmoothPolyDataFilter smoother = new vtkSmoothPolyDataFilter();
        smoother.SetInput(surfaceExtractor.GetOutput());
        smoother.Update();
        smoother.SetNumberOfIterations(700);
       

        vtkPolyDataNormals normals = new vtkPolyDataNormals();
        normals.SetInput(smoother.GetOutput());
        normals.FlipNormalsOn();

        vtkPolyDataWriter pdw = new vtkPolyDataWriter();
        pdw.SetInput(normals.GetOutput());
        pdw    .SetFileName("/home/guru/workspace/ThreeD/Raw/Dicom.vtk");
        pdw.Write();


Micha Feigin wrote:
> On Mon, 7 Sep 2009 02:36:45 +0530
> prasannjit ------------ <prasannjit at hotmail.com> wrote:
>
>   
>> Hello,
>>
>> I have to visualize a RAW volume data set, but I don't know how this can be done. I am working in C++ in Visual Studio 2008. I have earlier done the same for a vtk based volume. Is there a way to convert a RAW volume data set into VTK data set. Are there any VTK functions for reading such files?
>>     
>
> Raw as in just a bunch of voxels?
>
> If so, I'm not sure if it's the best way, but I just loaded the data into an
> array, created a vtkFloatArray and attached the data to it and then used that
> for whatever
>
> 	float *dataBuffer = ...
>
>         vtkFloatArray *data = vtkFloatArray::New();
>         data->SetArray(dataBuffer, width*height, 1);
>
>   
>>
>>
>> _________________________________________________________________
>> Sports, news, fashion and entertainment. Pick it all up in a package called MSN India
>> http://in.msn.com
>>     
> _______________________________________________
> 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
>   




More information about the vtkusers mailing list