[Insight-users] itk image problem, HELP!!

davidzhao zhaoy5 at mail.nih.gov
Mon Aug 2 11:18:53 EDT 2010


im tying to modify an image enchantment program that use hessian matrix
filter. i want to use threshold before the image is send into the hessian
filter, but for now, i just want to be able to draw on the image before it
is send into the hessian filter. but it always give me an error at
holder->DisconnectPipeline();, need help. here is my code:

/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile:
itkMultiScaleHessianSmoothed3DToVesselnessMeasureImageFilterTest.cxx,v $
  Language:  C++
  Date:      $Date: 2007/04/01 21:19:46 $
  Version:   $Revision: 1.5 $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif


#include "itkMultiScaleHessianSmoothed3DToVesselnessMeasureImageFilter.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

#include "itkRescaleIntensityImageFilter.h"

int main(int argc, char* argv [] )
{
        /*argc=3;
        argv[1]="c:\\Documents and Settings\\zhaoy5\\My
Documents\\IJ-Vessel_Enhancement_Diffusion.1Build\\debug\CroppedWholeLungCTScan.mhd";
        argv[2]="result.mha";*/

  if ( argc < 3 )
    {
    std::cerr << "Missing Parameters: "
              << argv[0]
              << " Input_Image"
              << " Vessel_Enhanced_Output_Image [SigmaMin SigmaMax
NumberOfScales]" << std::endl;
    return EXIT_FAILURE;
    }
 
 
  // Define the dimension of the images
  const unsigned int Dimension = 3;
  typedef short      InputPixelType;
  typedef double     OutputVesselnessPixelType;

  // Declare the types of the images
  typedef itk::Image< InputPixelType, Dimension>            InputImageType;

  typedef itk::Image< OutputVesselnessPixelType, Dimension>
VesselnessOutputImageType;

  typedef itk::ImageFileReader< InputImageType  >      ImageReaderType;

  ImageReaderType::Pointer   reader = ImageReaderType::New();
  reader->SetFileName ( argv[1] );

  std::cout << "Reading input image : " << argv[1] << std::endl;
  try
    {
    reader->Update();
    }
  catch ( itk::ExceptionObject &err )
    {
    std::cerr << "Exception thrown: " << err << std::endl;
    return EXIT_FAILURE;
    }

    /*              -----------PROBLEM threshold here ----------             
*/
        InputImageType::Pointer holder;
        holder=reader->GetOutput();
        holder->DisconnectPipeline();
         InputImageType ::IndexType index;
        for (int x=1; x < 30; x++){
                for (int y=1; y < 30; y++){
                        for (int z=1; z < 10; z++){
                                        index[0]=x;
                                        index[1]=y;
                                        index[2]=z;
                                        holder->SetPixel(index,10);
                        }
                }
        }
       

  // Declare the type of multiscale vesselness filter
  typedef itk::MultiScaleHessianSmoothed3DToVesselnessMeasureImageFilter<
                                            InputImageType,
                                            VesselnessOutputImageType>  
                                            MultiScaleVesselnessFilterType;

  // Create a vesselness Filter
  MultiScaleVesselnessFilterType::Pointer MultiScaleVesselnessFilter =
                                      MultiScaleVesselnessFilterType::New();

  MultiScaleVesselnessFilter->SetInput( holder );

  if ( argc >= 4 )
    {
    MultiScaleVesselnessFilter->SetSigmaMin( atof(argv[3])  );
    }
 
  if ( argc >= 5 )
    {
    MultiScaleVesselnessFilter->SetSigmaMax( atof(argv[4]) );
    }

  if ( argc >= 6 )
    {
    MultiScaleVesselnessFilter->SetNumberOfSigmaSteps( atoi(argv[5]) );
    }

  try
    {
    MultiScaleVesselnessFilter->Update();
    }
  catch( itk::ExceptionObject & err )
    {
    std::cerr << "Exception caught: " << err << std::endl;
    return EXIT_FAILURE;
    }

  std::cout << "Writing out the enhanced image to " <<  argv[2] <<
std::endl;

  //Rescale the output of the vesslness image
  typedef itk::Image<unsigned char, 3>              OutputImageType;
  typedef itk::RescaleIntensityImageFilter< VesselnessOutputImageType,
                                            OutputImageType>
                                            RescaleFilterType;

  RescaleFilterType::Pointer rescale = RescaleFilterType::New();
  rescale->SetInput( MultiScaleVesselnessFilter->GetOutput() );
  rescale->SetOutputMinimum(   0 );
  rescale->SetOutputMaximum( 255 );
  rescale->Update();

  typedef itk::ImageFileWriter< OutputImageType  >      ImageWriterType;
  ImageWriterType::Pointer writer = ImageWriterType::New();

 
        //OutputImageType *holder;
        //holder=rescale->GetOutput();
        //holder->DisconnectPipeline();
        //OutputImageType ::IndexType index;
        //
        //
        //for (int x=1; x < 30; x++){
        // for (int y=1; y < 30; y++){
        // for (int z=1; z < 10; z++){
        // index[0]=x;
        // index[1]=y;
        // index[2]=z;
        // //holder->SetPixel(index,10);
        // }
        // }
        //}
        //rescale->Update();

//----
  writer->SetFileName( argv[2] );
  writer->SetInput (rescale->GetOutput());

  try
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & err )
    {
    std::cerr << "Exception caught: " << err << std::endl;
    return EXIT_FAILURE;
    }

  return EXIT_SUCCESS;

}
-- 
View this message in context: http://old.nabble.com/itk-image-problem%2C-HELP%21%21-tp29326392p29326392.html
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list