[Insight-users] save .mhd file in .vtk format Keeping RGB values
alex Dowson
alexdowson at hotmail.com
Wed Sep 19 05:13:56 EDT 2012
Hi
You can view vtk file in Paraview or MITK application that is built on top of vtk,itk. Google for it you will get binaries.
Alex
From: shirani kannangara
Sent: Wednesday, September 19, 2012 2:18 PM
To: alexdowson at hotmail.com
Subject: Re: save .mhd file in .vtk format Keeping RGB values
Dear Alex
Thank you very much for your kind attention.VTk file is generated in my project folder(ie. in Debug folder).I can't open it.Can i?Can you explain me how it works.I would like to keep in touch with you for my future work.
regards
Shirani
On Wed, Sep 19, 2012 at 1:39 PM, alex Dowson <alexdowson at hotmail.com> wrote:
Hi
You donot need ImageSeriesRead. it used for only when you have image in form of slices.
Is it gives any error ? if not then vtk file will generated in your project folder.
alex
From: shirani kannangara
Sent: Wednesday, September 19, 2012 1:25 PM
To: alexdowson at hotmail.com
Subject: Re: save .mhd file in .vtk format Keeping RGB values
Dear Alex
I made it like this.
reader->SetFileName( "D:\\To_SMK\\VHPAbdomen.mhd" );
Now the command window show nothing other than the .exe path.
(D:\rgbabdomen\Debug>)
Do I have to use ImageSeriesRead WRite class?It is a suggestion only.
Bye
On Wed, Sep 19, 2012 at 12:58 PM, alex Dowson <alexdowson at hotmail.com> wrote:
Hi
Make one change
reader->SetFileName( "D:\\To_SMK\\VHPAbdomen%o3d.mhd" );
to
reader->SetFileName( "D:\\To_SMK\\VHPAbdomen.mhd" ); <= this is your input image name
Let me know the result then
From: shirani kannangara
Sent: Wednesday, September 19, 2012 12:53 PM
To: alex Dowson
Cc: insight-users at itk.org
Subject: Re: save .mhd file in .vtk format Keeping RGB values
Dear Aloex
Thanis a lot for your help. I prepared my codes as you direct me.I could build the programe with zero errors(but one warning).The output displayed in the comand window as follows.My codes are also given bellow.Can you help to correct this problem.
D:\rgbabdomen\Debug>RGBPixel.exe
Error reading the series
itk::ImageFileReaderException (01ACE970)
Location: "void __thiscall itk::ImageFileReader<class itk::Image<class itk::RGBP
ixel<unsigned char>,3>,class itk::DefaultConvertPixelTraits<class itk::RGBPixel<
unsigned char> > >::GenerateOutputInformation(void)"
File: d:\new2\insighttoolkit-4.2.0\insighttoolkit-4.2.0\modules\io\imagebase\inc
lude\itkImageFileReader.hxx
Line: 143
Description: Could not create IO object for file D:\To_SMK\VHPAbdomen%o3d.mhd
The file doesn't exist.
Filename = D:\To_SMK\VHPAbdomen%o3d.mhd
#include "itkImage.h"
#include "itkRGBPixel.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include <string>
using namespace std;
// Software Guide : EndCodeSnippet
int main( int argc, char argv[])
{
typedef unsigned char PixelType;
const unsigned int Dimension = 3;
typedef itk::RGBPixel<PixelType> RGBPixelType;
typedef itk::Image< RGBPixelType, Dimension> ImageType;
typedef itk::ImageFileReader<ImageType > ReaderType;
typedef itk::ImageFileWriter< ImageType > WriterType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( "D:\\To_SMK\\VHPAbdomen%o3d.mhd" );
typedef itk::ImageFileWriter< ImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput( reader->GetOutput() );
writer->SetFileName( "output.vtk");
try
{
writer->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Error reading the series " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return 0;
}
regards
Shirani
On Wed, Sep 19, 2012 at 11:03 AM, alex Dowson <alexdowson at hotmail.com> wrote:
Then this is what you want
#include "itkImage.h"
#include "itkRGBPixel.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
typedef unsigned char PixelType;
const unsigned int Dimension = 3;
typedef itk::RGBPixel<PixelType> RGBPixelType;
typedef itk::Image< RGBPixelType, Dimension> ImageType;
typedef itk::ImageFileReader<ImageType > ReaderType;
typedef itk::ImageFileWriter< ImageType > WriterType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( "D:\\To_SMK\\VHPAbdomen%03d.mhd" );
typedef itk::ImageFileWriter< ImageType, ImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput( reader->GetOutput() );
writer->SetFileName( "output.vtk");
try
{
writer->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Error reading the series " << std::endl;
std::cerr << excp << std::endl;
}
From: shirani kannangara
Sent: Wednesday, September 19, 2012 11:00 AM
To: alexdowson at hotmail.com
Cc: insight-users at itk.org
Subject: save .mhd file in .vtk format Keeping RGB values
Date: Tue, 18 Sep 2012 16:14:44 +0530
From: alex Dowson <alexdowson at hotmail.com>
Subject: Re: [Insight-users] (no subject)
To: "shirani kannangara" <mangalika673 at gmail.com>
Cc: itk <Insight-users at itk.org>
Message-ID: <SNT138-ds207ADF7393F47F289A3B7BD1940 at phx.gbl>
Content-Type: text/plain; charset="iso-8859-1"
Dear Alex
Thanks for you reply.First I would like to answer your questions.
This is what you asked from me.
Hi
1) I mean to say where is files from a_vm1455.raw to a_vm1905.raw ? Is it same directory where you load VHPabdomen.mhd ?
2) Your input image VHPabdomen.mhd is color or gray scale ?
3) After loading VHPabdomen.mhd do you want to produce slices or want to do any conversion ?
Your code is not complete . If you can tell exactly what you want to do then we can help.
1 Files a_vm1455.raw to a_vm1905.raw is the same directory (ie VHPabdomen.mhd)
2 Human Visible Dataset (ie VHPabdomen.mhd) is colour scale
3 My ultimate gall is to save this .mhd file in .vtk format keeping RGB values .
If you can direct me I can write codes again for that conversion.
regards
Shirani
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120919/61d96412/attachment-0001.htm>
More information about the Insight-users
mailing list