[Insight-users] Help writing RGB 3D file
nicest guy
cedric.ubiq at gmail.com
Sun Jan 17 21:58:11 EST 2010
Hello,
I'm trying to develop 3D program.
I read CT data. and use ITK to save it as ".vtk" file.
and I use VTk to display it as 3D.
it works fine, VTK shows gray color 3D(of cource, original source(CT) is
gray image)
But if i try to make RGB 3D image. VTK never drawed colorfully. it just
drawed gray garbage data.
So i'm wondering whether following ITK source code is wrong or not to write
RGB 3D data.
==============[main source]==================
typedef itk::RGBPixel<unsigned char> RGBPixelType;
typedef itk::Image<unsigned short, 3> ImageNDType;
typedef itk::Image<RGBPixelType, 3> ImageColorNDType;
typedef itk::ImageSeriesReader<ImageNDType> ReaderType;
typedef itk::RGBConvertingFilter< ImageNDType, ImageColorNDType >
RGBConvertingType;
itk::DICOMImageIO2::Pointer io = itk::DICOMImageIO2::New();
// Get the DICOM filenames from the directory
itk::DICOMSeriesFileNames::Pointer names = itk::DICOMSeriesFileNames::New();
names->SetDirectory("C:\\CT\\test6");
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileNames(names->GetFileNames());
reader->SetImageIO(io);
reader->Update();
reader->GetOutput()->Print(std::cout);
RGBConvertingType::Pointer converting = RGBConvertingType::New();
converting->SetInput(reader->GetOutput());
typedef itk::ImageFileWriter<ImageColorNDType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("c:\\Image.vtk");
writer->SetInput( converting->GetOutput() );
==============[RGB converting filter source]==================
inputIt.GoToBegin();
outputIt.GoToBegin();
while( !inputIt.IsAtEnd() )
{
while( !inputIt.IsAtEndOfLine() )
{
RGBPixelType p;
unsigned char r = inputIt.Get();
p.SetRed(r);
p.SetGreen(0);
p.SetBlue(0);
outputIt.Set(p); //make it red image
++inputIt;
++outputIt;
progress.CompletedPixel();
}
inputIt.NextLine();
outputIt.GoToEndOfLine(); // NextLine() assumes that the
outputIt.NextLine(); // iterator is at the end of line.
}
--
View this message in context: http://old.nabble.com/Help-writing-RGB-3D-file-tp27205635p27205635.html
Sent from the ITK - Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list