[Insight-users] RelabelComponentImageFilter nothing at rendered window..,
yasser salman
yass71@yahoo.com
Sun May 16 12:57:02 EDT 2004
hi luis ,
thanks Luis it works!i rescale the vlaues and it
works, but when i trying to display the segmented
region (tumor) and the whole object ( head) both have
the same gray level :( so i try to use
vtkImageMapToColors , vtkImageBlend , to blend two
objects, As i know the output image of the
vtkImageMapToColor is VTK_UNSIGNED_CHAR so should i
convert it to VTK_UNSIGNED_Short to be displayed?
(how?), also if there are any other method to Map the
segmented region into color region in ITK plz help
me.., thanks luis,,
regard's
yasser..,
--- Luis Ibanez <luis.ibanez@kitware.com> wrote:
>
> Hi Yasser,
>
> The Relabel image filter assigns values like :
> 1,2,3....
>
> to the pixels in the image. Those values will
> appear very dark in any viewer unless you rescale
> them before attempting to visualize them.
>
>
http://www.itk.org/Insight/Doxygen/html/classitk_1_1RelabelComponentImageFilter.html
>
>
> Since you are using VTK for visualization, you
> simply
> need to adjust the parameters of intensity windowing
> in your viewer.
>
>
>
> Regards,
>
>
> Luis
>
>
> ----------------------
> yasser salman wrote:
> > Hi All..,
> >
> > when i'm using itkRelabelComponentImageFilter as
> the
> > input to the writer the file saved and i can
> display
> > it clearly also GetSizeOfObjectsInPixels() works
> good,
> > but when i'm using it as the input of of
> > itk2vtkconnector nothing displayed in the render
> > window can u find out why?
> >
> >
typedef unsigned short InputPixelType;
typedef float InternalPixelType;
typedef unsigned short SegmentedPixelType;
typedef itk::Image< InputPixelType, 3 >
InputImageType;
typedef itk::Image< InternalPixelType, 3>
InternalImageType;
typedef itk::Image< SegmentedPixelType, 3 >
SegmentedImageType;
typedef itk::CastImageFilter<
InputImageType,
InternalImageType >
CastImageFilterType;
typedef itk::CurvatureFlowImageFilter<
InternalImageType,
InternalImageType >
CurvatureFlowImageFilterType;
typedef itk::ConfidenceConnectedImageFilter<
InternalImageType,
SegmentedImageType >
ConfidenceConnectedImageFilterType;
typedef itk::ConnectedThresholdImageFilter<
InternalImageType, SegmentedImageType >
ConnectedFilterType;
typedef itk::ImageToVTKImageFilter<
SegmentedImageType >
ITK2VTKConnectorFilterType;
typedef itk::VTKImageToImageFilter< InputImageType
>
VTK2ITKConnectorFilterType;
typedef itk::ImageSeriesReader< InputImageType >
ReaderType;
typedef std::vector<std::string> seriesIdContainer;
typedef std::vector<std::string> fileNamesContainer;
typedef ConnectedFilterType::IndexType IndexType;
typedef
itk::ImageMomentsCalculator<SegmentedImageType>
ImageMomentsType;
typedef itk::ImageSeriesReader< InputImageType >
ReaderType;
itk::DICOMImageIO2::Pointer dicomIO =
itk::DICOMImageIO2::New();
// Get the DICOM filenames from the directory
itk::DICOMSeriesFileNames::Pointer nameGenerator =
itk::DICOMSeriesFileNames::New();
CString directoryname(VolData_FName);
std::string stringdirectory =
directoryname.GetBuffer(200);
// nameGenerator->SetDirectory( stringdirectory );
it works!!!!!
nameGenerator->SetDirectory(
"d:/imagedata/Dicom/shy4" );
typedef std::vector<std::string> seriesIdContainer;
const seriesIdContainer & seriesUID =
nameGenerator->GetSeriesUIDs();
seriesIdContainer::const_iterator seriesItr =
seriesUID.begin();
seriesIdContainer::const_iterator seriesEnd =
seriesUID.end();
while( seriesItr != seriesEnd )
{
std::cout << seriesItr->c_str() << std::endl;
seriesItr++;
}
typedef std::vector<std::string>
fileNamesContainer;
fileNamesContainer fileNames;
fileNames = nameGenerator->GetFileNames();
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileNames( fileNames );
reader->SetImageIO( dicomIO );
reader->Update();
CastImageFilterType::Pointer cast =
CastImageFilterType::New();
CurvatureFlowImageFilterType::Pointer smoothing =
CurvatureFlowImageFilterType::New();
ConfidenceConnectedImageFilterType::Pointer
confidence =
ConfidenceConnectedImageFilterType::New();
ConnectedFilterType::Pointer connectedThreshold =
ConnectedFilterType::New();
RelabelImageFilter::Pointer rcfilter=
RelabelImageFilter::New();
VTK2ITKConnectorFilterType::Pointer VTK2ITKconnector
=
VTK2ITKConnectorFilterType::New();
RescaleType:: Pointer rescale= RescaleType::New();
cast->SetInput( reader->GetOutput() );
smoothing->SetInput( cast->GetOutput() );
confidence->SetInput( smoothing->GetOutput());
smoothing->SetTimeStep( 0.0625 );
smoothing->SetNumberOfIterations( 2 );
connectedThreshold->SetInput(
smoothing->GetOutput() );
connectedThreshold->SetLower( L_threshold );
connectedThreshold->SetUpper( H_threshold);
connectedThreshold->SetReplaceValue(
SegmentedRegionColor );
typedef ConnectedFilterType::IndexType IndexType;
IndexType seed;
seed[0] = axi;
seed[1] = cron;
seed[2] = sag;
connectedThreshold->SetSeed( seed );
ImageMomentsType::Pointer
calculator=ImageMomentsType::New();
connectedThreshold->Update();
calculator->SetImage(
connectedThreshold->GetOutput());
calculator->Compute();
area = calculator->GetTotalMass()/255;
char b[10];
sprintf(b,"%f",area);
AfxMessageBox(b);
SegmentedImageType::ConstPointer image =
connectedThreshold->GetOutput();
SegmentedImageType::RegionType region =
connectedThreshold->GetBufferedRegion();
SegmentedImageType::SizeType size =
region.GetSize();
ITK2VTKConnectorFilterType::Pointer ITK2VTKconnector
=
ITK2VTKConnectorFilterType::New();
rcfilter->SetInput(connectedThreshold->GetOutput());
rcfilter->Update();
unsigned long nObjects =
rcfilter->GetNumberOfObjects();
const std::vector<unsigned long> sizeOfObjects =
rcfilter->GetSizeOfObjectsInPixels();
std::vector<unsigned long>::const_iterator it;
int i;
it = sizeOfObjects.begin();
rescale->SetInput(rcfilter->GetOutput());
rescale->SetOutputMinimum(0);
rescale->SetOutputMaximum(255);
rescale->Update();
typedef itk::ImageFileWriter<SegmentedImageType>
itkWriterType;
typedef itk::DICOMImageIO2
itkMetaImageIOType;
itkMetaImageIOType::Pointer labellerMetaWriterIO =
itkMetaImageIOType::New();
itkWriterType::Pointer relabellerWriter =
itkWriterType::New();
itkMetaImageIOType::Pointer relabellerMetaWriterIO
= itkMetaImageIOType::New();
relabellerWriter->SetInput( rcfilter->GetOutput() );
relabellerWriter->SetFileName(
"c:/Shapes_relabelled.vtk" );
relabellerWriter->SetImageIO( relabellerMetaWriterIO
);
relabellerWriter->Write();
rcfilter->Update();
ITK2VTKconnector->SetInput(rescale->GetOutput());
ITK2VTKconnector->GetImporter()->SetDataScalarTypeToUnsignedChar();
//----------------------------------
// VTK Pipeline
//----------------------------------
GaussianRegion->SetStandardDeviations (5, 2, 1);
GaussianRegion-> SetRadiusFactors (1.0, 1.0,
1.0);
GaussianRegion
->SetInput(ITK2VTKconnector->GetOutput());
vtkLookupTable *hueLut0 = vtkLookupTable::New();
hueLut0->SetTableRange (0,2000);
hueLut0->SetAlphaRange(0,1);
hueLut0->SetSaturationRange (0,0);
hueLut0->SetValueRange (0, 5);
hueLut0->Build();
hueLut0->SetHueRange (0, 0);
vtkLookupTable *hueLut1 = vtkLookupTable::New();
hueLut1->SetTableRange (0,2000);
hueLut1->SetAlphaRange(0,1);
hueLut1->SetSaturationRange (1,1);
hueLut1->SetValueRange (1, 1);
hueLut1->Build();
hueLut1->SetHueRange (0, 1);
vtkImageMapToColors *alpha0 =
vtkImageMapToColors::New();
alpha0->SetInput(gaussian->GetOutput());
alpha0->SetLookupTable(hueLut0);
vtkImageMapToColors *alpha1 =
vtkImageMapToColors::New();
alpha1->SetInput(GaussianRegion->GetOutput());
alpha1->SetLookupTable(hueLut1);
vtkImageBlend *blend=vtkImageBlend::New();
blend-> SetInput(0,alpha0->GetOutput());
blend-> SetInput(1,alpha1->GetOutput());// end of
1
blend->SetOpacity(1,.7);
mcTumor->SetInput(GaussianRegion->GetOutput()); // to
display Tumor only it works!!
mc->SetInput( blend->GetOutput()); // to display
Both tumor and head but nosiy displayed..,
.... to visualiztion pipes..,
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/
More information about the Insight-users
mailing list