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

Abder-Rahman Ali abder.rahman.ali at gmail.com
Sat Mar 24 19:07:49 EDT 2012


ÌÌÌÌHi Luis,

In the CMakeLists.txt you sent me, I just changed the name of the files to
"threshold" since I have "threshold.cxx" as my file name, and added the
following lines similar to those in th CMakeLists.txt of the
"/Examples/Segmentation" directory instead of the last two lines originally
written:

ADD_EXECUTABLE(threshold threshold.cxx )
TARGET_LINK_LIBRARIES(threshold ITKNumerics ITKIO)

As in the original case, I got the following message when I tried to
"configure" and also written in CMake was an error relating line12.

*Error in configuration process, project files may be invalid

*Now, I have made a "configure" and "generate" successfully.

In this file, I'm trying to replace the "CurvatureImageFlowFilter" with the
"Anisotropic diffusion" filter from the "itkSoftwareGuide" (under section
6.7.3) and followed the steps on how to include it in the program.

The step left now is, how can test this filter on an .mha image?

I have attached the two files just to confirm if I have inserted the filter
correct.

I know my questions may be basic but since I'm totally new seems a bit
confusing at the beginning.

I really appreciate your kind patience and efforts.

Thanks a lot.

Abder-Rahman


On Sat, Mar 24, 2012 at 10:23 PM, Luis Ibanez <luis.ibanez at kitware.com>wrote:

> 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 --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120324/fc1902c6/attachment-0001.htm>
-------------- next part --------------
cmake_minimum_required(VERSION 2.8)
if(COMMAND CMAKE_POLICY)
  cmake_policy(SET CMP0003 NEW)
endif(COMMAND CMAKE_POLICY)

project(Threshold)

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

ADD_EXECUTABLE(threshold threshold.cxx )
TARGET_LINK_LIBRARIES(threshold ITKNumerics ITKIO)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: threshold.cxx
Type: application/octet-stream
Size: 13240 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120324/fc1902c6/attachment-0001.obj>


More information about the Insight-users mailing list