Hot to .mhd file for 3d reconstruction images

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Hot to .mhd file for 3d reconstruction images

blue
Hello;
I have a dataset for 3d reconstructions and I have this code:
*
import vtk


def main():
    colors = vtk.vtkNamedColors()

    fileName = get_program_parameters()

    colors.SetColor("BkgColor", [51, 77, 102, 255])

    ren = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)

    reader = vtk.vtkMetaImageReader()
    reader.SetFileName(fileName)

    volumeMapper = vtk.vtkFixedPointVolumeRayCastMapper()
    volumeMapper.SetInputConnection(reader.GetOutputPort())

    volumeColor = vtk.vtkColorTransferFunction()
    volumeColor.AddRGBPoint(0, 0.0, 0.0, 0.0)
    volumeColor.AddRGBPoint(500, 1.0, 0.5, 0.3)
    volumeColor.AddRGBPoint(1000, 1.0, 0.5, 0.3)
    volumeColor.AddRGBPoint(1150, 1.0, 1.0, 0.9)

   
    volumeScalarOpacity = vtk.vtkPiecewiseFunction()
    volumeScalarOpacity.AddPoint(0, 0.00)
    volumeScalarOpacity.AddPoint(500, 0.15)
    volumeScalarOpacity.AddPoint(1000, 0.15)
    volumeScalarOpacity.AddPoint(1150, 0.85)

 
    volumeGradientOpacity = vtk.vtkPiecewiseFunction()
    volumeGradientOpacity.AddPoint(0, 0.0)
    volumeGradientOpacity.AddPoint(90, 0.5)
    volumeGradientOpacity.AddPoint(100, 1.0)

 
    volumeProperty = vtk.vtkVolumeProperty()
    volumeProperty.SetColor(volumeColor)
    volumeProperty.SetScalarOpacity(volumeScalarOpacity)
    volumeProperty.SetGradientOpacity(volumeGradientOpacity)
    volumeProperty.SetInterpolationTypeToLinear()
    volumeProperty.ShadeOn()
    volumeProperty.SetAmbient(0.4)
    volumeProperty.SetDiffuse(0.6)
    volumeProperty.SetSpecular(0.2)


    volume = vtk.vtkVolume()
    volume.SetMapper(volumeMapper)
    volume.SetProperty(volumeProperty)

    ren.AddViewProp(volume)

    camera = ren.GetActiveCamera()
    c = volume.GetCenter()
    camera.SetViewUp(0, 0, -1)
    camera.SetPosition(c[0], c[1] - 400, c[2])
    camera.SetFocalPoint(c[0], c[1], c[2])
    camera.Azimuth(30.0)
    camera.Elevation(30.0)

    ren.SetBackground(colors.GetColor3d("BkgColor"))

    renWin.SetSize(640, 480)

    iren.Start()


def get_program_parameters():
    import argparse
    description = 'Read a volume dataset and displays it via volume
rendering.'
    epilogue = '''
    Derived from VTK/Examples/Cxx/Medical4.cxx
    '''
    parser = argparse.ArgumentParser(description=description,
epilog=epilogue,
                                   
formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('filename', help='FullHead.mhd.')
    args = parser.parse_args()
    return args.filename


if __name__ == '__main__':
    main()
*

This code including .mhd file How to convert my dataset .mhd file with vtk
for this code



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Hot to .mhd file for 3d reconstruction images

kenichiro yoshimi
Hello,

You have only to specify a file name in executing the program:
> python program.py file-name

Best,

2018-06-24 9:13 GMT+09:00 blue <[hidden email]>:

> Hello;
> I have a dataset for 3d reconstructions and I have this code:
> *
> import vtk
>
>
> def main():
>     colors = vtk.vtkNamedColors()
>
>     fileName = get_program_parameters()
>
>     colors.SetColor("BkgColor", [51, 77, 102, 255])
>
>     ren = vtk.vtkRenderer()
>     renWin = vtk.vtkRenderWindow()
>     renWin.AddRenderer(ren)
>     iren = vtk.vtkRenderWindowInteractor()
>     iren.SetRenderWindow(renWin)
>
>     reader = vtk.vtkMetaImageReader()
>     reader.SetFileName(fileName)
>
>     volumeMapper = vtk.vtkFixedPointVolumeRayCastMapper()
>     volumeMapper.SetInputConnection(reader.GetOutputPort())
>
>     volumeColor = vtk.vtkColorTransferFunction()
>     volumeColor.AddRGBPoint(0, 0.0, 0.0, 0.0)
>     volumeColor.AddRGBPoint(500, 1.0, 0.5, 0.3)
>     volumeColor.AddRGBPoint(1000, 1.0, 0.5, 0.3)
>     volumeColor.AddRGBPoint(1150, 1.0, 1.0, 0.9)
>
>
>     volumeScalarOpacity = vtk.vtkPiecewiseFunction()
>     volumeScalarOpacity.AddPoint(0, 0.00)
>     volumeScalarOpacity.AddPoint(500, 0.15)
>     volumeScalarOpacity.AddPoint(1000, 0.15)
>     volumeScalarOpacity.AddPoint(1150, 0.85)
>
>
>     volumeGradientOpacity = vtk.vtkPiecewiseFunction()
>     volumeGradientOpacity.AddPoint(0, 0.0)
>     volumeGradientOpacity.AddPoint(90, 0.5)
>     volumeGradientOpacity.AddPoint(100, 1.0)
>
>
>     volumeProperty = vtk.vtkVolumeProperty()
>     volumeProperty.SetColor(volumeColor)
>     volumeProperty.SetScalarOpacity(volumeScalarOpacity)
>     volumeProperty.SetGradientOpacity(volumeGradientOpacity)
>     volumeProperty.SetInterpolationTypeToLinear()
>     volumeProperty.ShadeOn()
>     volumeProperty.SetAmbient(0.4)
>     volumeProperty.SetDiffuse(0.6)
>     volumeProperty.SetSpecular(0.2)
>
>
>     volume = vtk.vtkVolume()
>     volume.SetMapper(volumeMapper)
>     volume.SetProperty(volumeProperty)
>
>     ren.AddViewProp(volume)
>
>     camera = ren.GetActiveCamera()
>     c = volume.GetCenter()
>     camera.SetViewUp(0, 0, -1)
>     camera.SetPosition(c[0], c[1] - 400, c[2])
>     camera.SetFocalPoint(c[0], c[1], c[2])
>     camera.Azimuth(30.0)
>     camera.Elevation(30.0)
>
>     ren.SetBackground(colors.GetColor3d("BkgColor"))
>
>     renWin.SetSize(640, 480)
>
>     iren.Start()
>
>
> def get_program_parameters():
>     import argparse
>     description = 'Read a volume dataset and displays it via volume
> rendering.'
>     epilogue = '''
>     Derived from VTK/Examples/Cxx/Medical4.cxx
>     '''
>     parser = argparse.ArgumentParser(description=description,
> epilog=epilogue,
>
> formatter_class=argparse.RawDescriptionHelpFormatter)
>     parser.add_argument('filename', help='FullHead.mhd.')
>     args = parser.parse_args()
>     return args.filename
>
>
> if __name__ == '__main__':
>     main()
> *
>
> This code including .mhd file How to convert my dataset .mhd file with vtk
> for this code
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Hot to .mhd file for 3d reconstruction images

blue
Thank you so much I will try and I will back to you



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Hot to .mhd file for 3d reconstruction images

blue
In reply to this post by kenichiro yoshimi
Hello ;
I tried code but I have this error:
<http://vtk.1045678.n5.nabble.com/file/t342420/vtkmedikalerror.png>

I cannot understand why?
Any advice



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Hot to .mhd file for 3d reconstruction images

kenichiro yoshimi
Hi,

Your mhd file might be invalid as shown in the error message. Would
you confirm if it is visualized correctly with ParaView or 3D Slicer?

Thanks
2018年6月26日(火) 7:39 blue <[hidden email]>:

>
> Hello ;
> I tried code but I have this error:
> <http://vtk.1045678.n5.nabble.com/file/t342420/vtkmedikalerror.png>
>
> I cannot understand why?
> Any advice
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Hot to .mhd file for 3d reconstruction images

blue
This post was updated on .
Hi;
I have images but not .mhd file I only give images folder to code How can
Iconvert .mhd file my image dataset(images) with vtk in python?

On the other hand you say that
  "Hello,

You have only to specify a file name in executing the program:
> python program.py file-name"
What I mean is that  I should give  only my imageset path to code should not it? But I have this error  Why?



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
kenichiro yoshimi wrote
Hi,

Your mhd file might be invalid as shown in the error message. Would
you confirm if it is visualized correctly with ParaView or 3D Slicer?

Thanks
2018年6月26日(火) 7:39 blue <[hidden email]>:
>
> Hello ;
> I tried code but I have this error:
> <http://vtk.1045678.n5.nabble.com/file/t342420/vtkmedikalerror.png>
>
> I cannot understand why?
> Any advice
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Hello,

You have only to specify a file name in executing the program:
> python program.py file-name
kenichiro yoshimi wrote
Hi,

Your mhd file might be invalid as shown in the error message. Would
you confirm if it is visualized correctly with ParaView or 3D Slicer?

Thanks
2018年6月26日(火) 7:39 blue <[hidden email]>:
>
> Hello ;
> I tried code but I have this error:
> <http://vtk.1045678.n5.nabble.com/file/t342420/vtkmedikalerror.png>
>
> I cannot understand why?
> Any advice
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers