[Insight-users] Matlab bwlabeln in itk

Daniela Sacchetto danysunflower at hotmail.it
Thu Aug 26 06:11:27 EDT 2010


I have to put
  int main(...)
at the beginning and then it runs perfectly... I don't know how, but the first time that I tried that way it doesn't work...maybe I did something different...

But now I'm trying to run only a part of code... I would like to use only itk::ConnectedComponentImageFilter, but I have Segmentation fault...;-(

This is my code:
------------------------------------------------------------------------------------------------------------------------------

#include "itkConnectedComponentImageFilter.h"

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

int main(int argc, char* argv[] )
{
  if( argc < 3 )
    {
    std::cerr << "Missing Parameters " << std::endl;
    std::cerr << "Usage: " << argv[0];
    std::cerr << " inputImage  outputImage" << std::endl;
    return EXIT_FAILURE;
    }

  typedef   unsigned short  InternalPixelType;
  const     unsigned int    Dimension = 3;
  
  typedef itk::Image< InternalPixelType, Dimension >  InternalImageType;
 
  typedef itk::ImageFileReader< InternalImageType > ReaderType;
  typedef itk::ImageFileWriter<  InternalImageType > WriterType; 

  typedef itk::ConnectedComponentImageFilter< InternalImageType, InternalImageType > FilterType;

  ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();
  
  FilterType::Pointer filter = FilterType::New();

  reader->SetFileName( argv[1] );


  filter->SetInput (reader->GetOutput()); 
  filter->Update();
  

   try
      {
      writer->SetInput (filter->GetOutput()); 
      writer->SetFileName( argv[2] );
      writer->Update();
      }
   catch( itk::ExceptionObject & excep )
    {
    std::cerr << "Exception caught !" << std::endl;
    std::cerr << excep << std::endl;
    }


  return EXIT_SUCCESS;

}

-----------------------------------------------------------------------
I thing there is some stupid error but I don't find it....

From: arpit392 at gmail.com
Date: Thu, 26 Aug 2010 14:47:23 +0530
Subject: Re: [Insight-users] Matlab bwlabeln in itk
To: danysunflower at hotmail.it

what was it??

On Thu, Aug 26, 2010 at 2:45 PM, Daniela Sacchetto <danysunflower at hotmail.it> wrote:







Ok, I find my error!!! It was a little stupid... 
Thanks all for your help

Regards
Daniela

From: arpit392 at gmail.com


Date: Thu, 26 Aug 2010 14:22:18 +0530
Subject: Re: [Insight-users] Matlab bwlabeln in itk
To: danysunflower at hotmail.it



I guess you didnt change "int itkConnectedComponentImageFilterTest(int argc, char* argv[] )" to "int main( int argc, char* argv[])".....
thats a testing codes...you need to make a few changes before u run them....





On Thu, Aug 26, 2010 at 1:41 PM, Daniela Sacchetto <danysunflower at hotmail.it> wrote:









Hi, firstly, thank you for your reply.

I'm trying to run the code you suggested me to understand how it works but I find a problem that I've never had and that it a little strange in my opinion.
This is the error that I have:





/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o: In function `_start':
/build/buildd/eglibc-2.10.1/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main'
collect2: ld returned 1 exit status





What does it mean?
Could you help me?
Thanks
Daniela



From: arpit392 at gmail.com
Date: Thu, 26 Aug 2010 13:23:16 +0530




Subject: Re: [Insight-users] Matlab bwlabeln in itk
To: danysunflower at hotmail.it

u can use itkConnectedComponentImageFilterTest.cxx, it performs a similar task...except it associates each label with a different colour, to help visualize the different parts using itkRelabelComponentImageFilter, you can comment this part to get your desired results...






Cheers,Arpit

On Thu, Aug 26, 2010 at 1:15 PM, Daniela Sacchetto <danysunflower at hotmail.it> wrote:











Hi everyone,
I need your help.

I have to implement a code with similar function to Matlab bwlabeln; Matlab's routine L = bwlabeln(BW) returns a label matrix L containing labels for the connected components in BW; the elements of L are integer values greater than or equal to 0. The pixels labeled 0 are the background.







I looked for similar itk method in itk User's Guide but I didn't find anything... could anyone help me?

Thanks of all,
Daniela
 		 	   		  

_____________________________________

Powered by www.kitware.com



Visit other Kitware open-source projects at

http://www.kitware.com/opensource/opensource.html



Kitware offers ITK Training Courses, for more information visit:

http://www.kitware.com/products/protraining.html



Please keep messages on-topic and check the ITK FAQ at:

http://www.itk.org/Wiki/ITK_FAQ



Follow this link to subscribe/unsubscribe:

http://www.itk.org/mailman/listinfo/insight-users




-- 
Arpit Agrawal
Junior Undergraduate, 
Dual Degree Communication and Signal Processing ,
Dept. of Electrical Engg, IITB.

 		 	   		  


-- 
Arpit Agrawal
Junior Undergraduate, 
Dual Degree Communication and Signal Processing ,
Dept. of Electrical Engg, IITB.

 		 	   		  


-- 
Arpit Agrawal
Junior Undergraduate, 
Dual Degree Communication and Signal Processing ,
Dept. of Electrical Engg, IITB.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100826/6b8741ff/attachment-0001.htm>


More information about the Insight-users mailing list