[Insight-users] to compare binary images

David Llanos gva02 at elai.upm.es
Wed Jul 7 12:00:49 EDT 2004


Hi, can you help me with the code? I have some errors...
----------------
////////////////////////////////
#include "itkAndImageFilter.h"
#include <itkImageRegionIteratorWithIndex.h>
//////////////////////////////////
#include "itkImageMomentsCalculator.h"

///////////////// CREACION DE ITERATORS //////////////////////////////
//lectura de la imagen
typedef unsigned char PixelType;
const unsigned int dimension = 2;
typedef itk::Image<PixelType,dimension>  ImageType;
typedef itk::ImageFileReader< ImageType >  ReaderType;

//Escritura
typedef itk::ImageFileWriter< ImageType> WriterType;

//filtro AND
typedef itk::AndImageFilter<ImageType,ImageType,ImageType> FiltroAND;
typedef FiltroAND::Pointer   PunteroFiltroAND;

///////////////////////////////////////////////////////////////////////
////////////////// PROGRAMA PRINCIPAL ///////////////////////////////
int main( int argc, char * argv[] )
{
  if( argc < 3 )
    {
    std::cerr << "Modo de uso: " << std::endl;
    std::cerr << argv[0] << " ImagenDeEntrada1" << std::endl;
    return -1;
    }
const char * ImagenDeEntrada1  = argv[1];
const char * ImagenDeEntrada2  = argv[2];

//Lectura de la imagen
std::cerr << "*Leyendo imagenes... " << std::endl;
ReaderType::Pointer im1 = ReaderType::New();
im1->SetFileName( ImagenDeEntrada1  );
im1->Update();
ReaderType::Pointer im2 = ReaderType::New();
im2->SetFileName( ImagenDeEntrada2  );
im2->Update();

PunteroFiltroAND and = FiltroAND::New();

  and->SetInput1( im1 );
  and->SetInput2( im2 );

//Escritura de imagen
 WriterType::Pointer imgCoreBWsin = WriterType::New();
 imgCoreBWsin->SetFileName( "imgCoreBWsin.PNG" );
    //WriterType::Pointer imgCoreBWsin = and->GetOutput();
    imgCoreBWsin = and->GetOutput();
    and->Update();


 std::cout << "  Imagen imgCoreBWsin.PNG creada" << std::endl;
 std::cout << std::endl;

////////////////////////////////////////////////////////////////////////////
 std::cout << "...Fin de la ejecucion" << std::endl;
 return(0);

}
////////////////////////////////////////////////////////////////////////////
//
-------------
E:\FiltroAND\Espermas.cpp(102) : error C2664: 'SetInput1' : cannot convert
parameter 1 from 'class itk::SmartPointer<class itk::ImageFileReader<class
itk::Image<unsigned char,2>,class itk::DefaultConvertPixelTraits<unsigned
char> > >' to 'const clas
s itk::Image<unsigned char,2> *'
        No user-defined-conversion operator available that can perform this
conversion, or the operator cannot be called
E:\FiltroAND\Espermas.cpp(103) : error C2664: 'SetInput2' : cannot convert
parameter 1 from 'class itk::SmartPointer<class itk::ImageFileReader<class
itk::Image<unsigned char,2>,class itk::DefaultConvertPixelTraits<unsigned
char> > >' to 'const clas
s itk::Image<unsigned char,2> *'
        No user-defined-conversion operator available that can perform this
conversion, or the operator cannot be called
E:\FiltroAND\Espermas.cpp(109) : error C2679: binary '=' : no operator
defined which takes a right-hand operand of type 'class itk::Image<unsigned
char,2> *' (or there is no acceptable conversion)
Error executing cl.exe.

Espermas.exe - 3 error(s), 0 warning(s)
-------------------------------------------------------

Thanks in advange and regards,

David.


----- Original Message ----- 
From: "Zachary Pincus" <zpincus at stanford.edu>
To: "David Llanos" <gva02 at elai.upm.es>
Sent: Tuesday, July 06, 2004 7:55 PM
Subject: Re: [Insight-users] to compare binary images


> You appear to be trying to do a boolean AND operation on two image. Try
> using the AndImageFilter.
>
> (Note that boolean AND outputs 1 and 0... so 255 && 255 returns "true"
> or 1. So the outputs of the image filter will be 1's and 0's, not 255's
> and 0's, as in the images you provide. To get that, you'd need to do
> some rescaling or other operation.)
>
>
> Zach Pincus
>
> Department of Biochemistry and Program in Biomedical Informatics
> Stanford University School of Medicine
>
>
> On Jul 6, 2004, at 9:25 AM, David Llanos wrote:
>
> > Hi all,
> >
> > I am trying to compare two binary images pixel to pixel to obtain a
> > third image that contains common pixels. To explain to it better
> > assistant three images: the main ones, a.png and b.png, with those
> > that I want to obtain the image, c.png. This way, c.png has to have
> > the pixels of the image b.png that are in the image a.png.
> >
> > Thanks in advange and regards.
> > <a.png><b.png><c.png>_______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
>
>



More information about the Insight-users mailing list