[Insight-users] save .mhd file in .vtk format Keeping RGB values
shirani kannangara
mangalika673 at gmail.com
Wed Sep 19 03:23:40 EDT 2012
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 <mangalika673 at gmail.com>
> *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/8315786e/attachment.htm>
More information about the Insight-users
mailing list