[Insight-users] save .mhd file in .vtk format Keeping RGB values

alex Dowson alexdowson at hotmail.com
Wed Sep 19 01:33:51 EDT 2012


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/8d3cf9f1/attachment.htm>


More information about the Insight-users mailing list