[Insight-users] Connected Threshold Image Filter and RAW images

Miller, James V (GE, Research) millerjv at crd.ge.com
Wed Feb 8 12:02:22 EST 2006


You say the image is all "black". Based on how you configured the ConnectedThresholdImageFilter, it will have zeros and ones. Make sure that viewer allows you to see a difference of one intensity value (in your unsigned short image which has a very large dynamic range).
 
Jim
 

-----Original Message-----
From: insight-users-bounces+millerjv=crd.ge.com at itk.org [mailto:insight-users-bounces+millerjv=crd.ge.com at itk.org]On Behalf Of Diego R. Medaglia
Sent: Wednesday, February 08, 2006 10:35 AM
To: insight-users at itk.org
Subject: [Insight-users] Connected Threshold Image Filter and RAW images


Hi!
    I am trying to segment 2D numbered (.1, .2, .3 ,...) raw medical images with ConnectedThresholdImageFilter, but for whatever upper and lower threshold values I use, the resulting image is a tottaly BLACK one...  I'm using unsigned short for the pixel type, don't know if that's correct. The images are 64x64 pixels in dimension, and all index adjustments, file names and threshold values seem to be just right. Any ideas on this one?
 
Here's the code:
//(mscVolumeProperties is a class for storing height, width, file names, etc... through the entire app)
 
// rgSeg.h

#include "itkImageFileReader.h"

#include "itkImageFileWriter.h"

#include "itkRawImageIO.h"

#include "itkVTKImageExport.h"

#include "itkVTKImageExportBase.h"

#include "itkImage.h"

#include "itkConnectedThresholdImageFilter.h"

#include <string>

using std::string;

 
class mscVolumeProperties;

 
class RegionGrowingSeg
{

private:
    typedef unsigned short PixelType;
    typedef itk::Image< PixelType > ImageType;
    typedef itk::RawImageIO<PixelType > IOType;
    typedef itk::ImageFileReader< ImageType > ReaderType;
    typedef itk::ImageFileWriter< ImageType > WriterType;
    typedef itk::ConnectedThresholdImageFilter< ImageType, ImageType > ConnectedFilterType;
 
    string inputFile;
    string outputFile;
    mscVolumeProperties* vp;
    ReaderType::Pointer reader;
    WriterType::Pointer writer;
    IOType::Pointer io;
    ConnectedFilterType::Pointer connectedThreshold ;
    PixelType lowerThreshold;
    PixelType upperThreshold;
    ImageType::IndexType index;

 
public:
    RegionGrowingSeg(mscVolumeProperties* v){vp = v;}
    RegionGrowingSeg(){ vp = NULL;}
    static RegionGrowingSeg* New(mscVolumeProperties* v){return new RegionGrowingSeg(v);}
    static RegionGrowingSeg* New(){return new RegionGrowingSeg();}
    void setVP(mscVolumeProperties* v) {vp = v;}
    void setInputFileName(const char* ifn){inputFile.assign(ifn);}
    void setOutputFileName(const char* ofn){outputFile.assign(ofn);}
    void setLowerThreshold(unsigned short lt){lowerThreshold = lt;}
    void setUpperThreshold(unsigned short ut){upperThreshold = ut;}
 
    void setIndex(int* in)
    {
        index[0]=in[0];
        index[1]=in[1];
    }
 
    void segment();
    const char* getInputFileName() const {return inputFile.c_str();}
    const char* getOutputFileName() const {return outputFile.c_str();}
    unsigned short getLowerThreshold(){return lowerThreshold;}
    unsigned short getUpperThreshold(){return upperThreshold;}
    int* getIndex()
    {
        int ri[2];
        ri[0] = index[0];
        ri[1] = index[1];
        return ri;
    }
};
 
 
// rgSeg.cpp:

#include "rgSeg.h"

void RegionGrowingSeg::segment()
{
    reader = ReaderType::New();
    writer = WriterType::New();
    io = IOType::New();
    //Sets para as dimensões da imagem raw:

 
    io->SetDimensions(0,vp->GetHeight());
    io->SetDimensions(1,vp->GetWidth() );
    reader->SetImageIO( io );
    writer->SetImageIO( io );
 
    reader->SetFileName( inputFile.c_str() );
    connectedThreshold = ConnectedFilterType::New();
    connectedThreshold->SetInput( reader->GetOutput() );
 
    connectedThreshold->SetReplaceValue( 1 );
    connectedThreshold->SetSeed( index );
    connectedThreshold->SetLower( lowerThreshold );
    connectedThreshold->SetUpper( upperThreshold );
 
    writer->SetInput( connectedThreshold->GetOutput() );
    writer->SetFileName( outputFile.c_str() );
    try{
        writer->Update();
        }
    catch( itk::ExceptionObject & err ){
    std::cerr<<"Excecao capturada!";
    std::cout << err << std::endl;
    }
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060208/fdb56f18/attachment.html


More information about the Insight-users mailing list