[Insight-users] Segmentation of 3D image (itk)

Luis Ibanez luis.ibanez at kitware.com
Sat Mar 24 18:23:47 EDT 2012


Hi Abder,

Here is below the content that you
need to put in the CMakeLists.txt file.

Also attached for your convenience.

    Luis

--

cmake_minimum_required(VERSION 2.8)
if(COMMAND CMAKE_POLICY)
  cmake_policy(SET CMP0003 NEW)
endif(COMMAND CMAKE_POLICY)

project(ConnectedThreshold)

find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

add_executable(ConnectedThreshold ConnectedThresholdImageFilter.cxx )
target_link_libraries(ConnectedThreshold ${ITK_LIBRARIES})



=================================================================
On Sat, Mar 24, 2012 at 6:13 PM, Abder-Rahman Ali
<abder.rahman.ali at gmail.com> wrote:
> Thanks so much Luis. That really helps.
>
> I'm a bit new to this, and now trying to run a filter, say for example, the
> "Examples/Segmentation/ConnectedThresholdImageFilter.cxx". I tried to use
> CMake after copying this file along with the CMakeLists.txt to a new
> directory. I made the new directory (i.e; NewDir) as "source" and the
> "build" as (i.e; NewDirBin).
>
> When I try to "generate", I get the following message: Error in generation
> process, project files may be invalid
>
> So, the bottom line is, how can I test this filter?
>
> Thanks a lot.
>
> Abder-Rahman
>
>
> On Sat, Mar 24, 2012 at 9:58 PM, Luis Ibanez <luis.ibanez at kitware.com>
> wrote:
>>
>> On Sat, Mar 24, 2012 at 2:19 PM, Abder-Rahman Ali
>> <abder.rahman.ali at gmail.com> wrote:
>> >
>> > So, in your modifications, I should REMOVE what has "-" and ADD what has
>> > "+".
>> >
>>
>> Yes.
>>
>> This is the typical format that you will
>> see when you do a diff between two files.
>>
>>
>> > * For, the following:
>> >
>> > smoothing->SetTimeStep( 0.025 );
>> >
>> > Why did you add ( 0.025 ) and not ( 0.125 )
>> >
>>
>> Because when you go from 2D to 3D the computation
>> of the time step in the smoothing filter needs to be
>> adjusted. Otherwise you will get a warning about the
>> time step at 0.125 being unstable in 3D.
>>
>>
>> > * For the following:
>> >
>> >
>> > -  const InternalPixelType lowerThreshold = atof( argv[5] );
>> > -  const InternalPixelType upperThreshold = atof( argv[6] );
>> > +  const InternalPixelType lowerThreshold = atof( argv[6] );
>> > +  const InternalPixelType upperThreshold = atof( argv[7] );
>> >
>> > Why had you to remove the first two lines and add [6] & [7]?
>> >
>>
>> Because the insertion of the seedZ argument
>> in the command line displaces the two last
>> arguments by one.
>>
>>
>> > Thanks a lot, and appreciate your kind efforts.
>> >
>> > Abder-Rahman
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Sat, Mar 24, 2012 at 4:56 PM, Luis Ibanez <luis.ibanez at kitware.com>
>> > wrote:
>> >>
>> >> Hi Abder-Rahman,
>> >>
>> >> Please find below the diffs that you have to apply to
>> >> this example in order to make it work for 3D images.
>> >>
>> >>
>> >>   Thanks
>> >>
>> >>
>> >>       Luis
>> >>
>> >>
>> >> diff --git a/Examples/Segmentation/ConnectedThresholdImageFilter.cxx
>> >> b/Examples/Segmentation/ConnectedThresholdImageFilter.cxx
>> >> index 5fdfb24..38ef54c 100644
>> >> --- a/Examples/Segmentation/ConnectedThresholdImageFilter.cxx
>> >> +++ b/Examples/Segmentation/ConnectedThresholdImageFilter.cxx
>> >> @@ -95,11 +95,11 @@
>> >>
>> >>  int main( int argc, char *argv[])
>> >>  {
>> >> -  if( argc < 7 )
>> >> +  if( argc < 8 )
>> >>     {
>> >>     std::cerr << "Missing Parameters " << std::endl;
>> >>     std::cerr << "Usage: " << argv[0];
>> >> -    std::cerr << " inputImage  outputImage seedX seedY lowerThreshold
>> >> upperThreshold" << std::endl;
>> >> +    std::cerr << " inputImage  outputImage seedX seedY seedZ
>> >> lowerThreshold upperThreshold" << std::endl;
>> >>     return 1;
>> >>     }
>> >>
>> >> @@ -114,7 +114,7 @@ int main( int argc, char *argv[])
>> >>
>> >>   // Software Guide : BeginCodeSnippet
>> >>   typedef   float           InternalPixelType;
>> >> -  const     unsigned int    Dimension = 2;
>> >> +  const     unsigned int    Dimension = 3;
>> >>   typedef itk::Image< InternalPixelType, Dimension >
>> >>  InternalImageType;
>> >>   // Software Guide : EndCodeSnippet
>> >>
>> >> @@ -217,7 +217,7 @@ int main( int argc, char *argv[])
>> >>
>> >>   // Software Guide : BeginCodeSnippet
>> >>   smoothing->SetNumberOfIterations( 5 );
>> >> -  smoothing->SetTimeStep( 0.125 );
>> >> +  smoothing->SetTimeStep( 0.025 );
>> >>   // Software Guide : EndCodeSnippet
>> >>
>> >>
>> >> @@ -235,8 +235,8 @@ int main( int argc, char *argv[])
>> >>   //
>> >>   //  Software Guide : EndLatex
>> >>
>> >> -  const InternalPixelType lowerThreshold = atof( argv[5] );
>> >> -  const InternalPixelType upperThreshold = atof( argv[6] );
>> >> +  const InternalPixelType lowerThreshold = atof( argv[6] );
>> >> +  const InternalPixelType upperThreshold = atof( argv[7] );
>> >>
>> >>   // Software Guide : BeginCodeSnippet
>> >>   connectedThreshold->SetLower(  lowerThreshold  );
>> >> @@ -275,6 +275,7 @@ int main( int argc, char *argv[])
>> >>
>> >>   index[0] = atoi( argv[3] );
>> >>   index[1] = atoi( argv[4] );
>> >> +  index[2] = atoi( argv[5] );
>> >>
>> >>
>> >>   // Software Guide : BeginCodeSnippet
>> >>
>> >>
>> >>
>> >> ---------------------------------
>> >> On Sat, Mar 24, 2012 at 11:14 AM, Abder-Rahman Ali
>> >> <abder.rahman.ali at gmail.com> wrote:
>> >> > Hello,
>> >> >
>> >> > I just have a question and thought you may have an idea on it.
>> >> >
>> >> > Inside the `InsightToolkit` directory there is the
>> >> > `Examples/Segmentation/ConnectedThresholdImageFilter.xx` file.
>> >> >
>> >> > Now, I want to make it operate on a three dimensional image. In this
>> >> > case,
>> >> > will the changes that I have to do bee applied to those lines of code
>> >> > (lines
>> >> > 102-110):
>> >> >
>> >> >     int main( int argc, char *argv[])
>> >> >     {
>> >> >       if( argc < 7 )
>> >> >         {
>> >> >         std::cerr << "Missing Parameters " << std::endl;
>> >> >         std::cerr << "Usage: " << argv[0];
>> >> >         std::cerr << " inputImage  outputImage seedX seedY
>> >> > lowerThreshold
>> >> > upperThreshold" << std::endl;
>> >> >         return 1;
>> >> >         }
>> >> >
>> >> > And, in order to do that, should I add the following `seedZ` to:
>> >> >
>> >> >     std::cerr << " inputImage  outputImage seedX seedY lowerThreshold
>> >> > upperThreshold" << std::endl;
>> >> >
>> >> > And, what change should I perform to the arguments in this case?
>> >> >
>> >> > Thanks a lot and apologize for my disturbance.
>> >> >
>> >> > Abder-Rahman
>> >> >
>> >
>> >
>
>
-------------- next part --------------
cmake_minimum_required(VERSION 2.8)
if(COMMAND CMAKE_POLICY)
  cmake_policy(SET CMP0003 NEW)
endif(COMMAND CMAKE_POLICY)

project(ConnectedThreshold)

find_package(ITK REQUIRED)
include(${ITK_USE_FILE})

add_executable(ConnectedThreshold ConnectedThresholdImageFilter.cxx )
target_link_libraries(ConnectedThreshold ${ITK_LIBRARIES})


More information about the Insight-users mailing list