[Insight-users] Help with Shaped Neighborhood Iterators: Setting and Retrieving Offsets - mismatches

Neal R. Harvey harve at lanl.gov
Tue Aug 4 15:26:50 EDT 2009


I am having a little problem with setting offsets and retrieving these 
values accurately, when
trying to use a shaped neighborhood iterator. If anyone has any ideas as 
to what I am doing wrong
then I would very  much appreciate your insights.

The following is the output I get from a piece of code that I have tried 
to write, in order
to create a shaped neighborhood iterator. However, after setting the 
offsets I then print out
what I thought I had set as the offsets and the values that are reported 
as having been set
do not match the values I thought I set:

   Processing Face # 0
      miss_SE_radius = 3

< These are the offsets that I am setting >

 MissOffset[0] = -3: MissOffset[1] = -3: MissSEPixelValue = 1
 MissOffset[0] = -2: MissOffset[1] = -3: MissSEPixelValue = 2
 MissOffset[0] = -1: MissOffset[1] = -3: MissSEPixelValue = 3
 MissOffset[0] = 0: MissOffset[1] = -3: MissSEPixelValue = 4
 MissOffset[0] = 1: MissOffset[1] = -3: MissSEPixelValue = 5
 MissOffset[0] = 2: MissOffset[1] = -3: MissSEPixelValue = 6
 MissOffset[0] = 3: MissOffset[1] = -3: MissSEPixelValue = 7
 MissOffset[0] = -3: MissOffset[1] = -2: MissSEPixelValue = 8
 MissOffset[0] = 3: MissOffset[1] = -2: MissSEPixelValue = 14
 MissOffset[0] = -3: MissOffset[1] = -1: MissSEPixelValue = 15
 MissOffset[0] = 3: MissOffset[1] = -1: MissSEPixelValue = 21
 MissOffset[0] = -3: MissOffset[1] = 0: MissSEPixelValue = 22
 MissOffset[0] = 3: MissOffset[1] = 0: MissSEPixelValue = 28
 MissOffset[0] = -3: MissOffset[1] = 1: MissSEPixelValue = 29
 MissOffset[0] = 3: MissOffset[1] = 1: MissSEPixelValue = 35
 MissOffset[0] = -3: MissOffset[1] = 2: MissSEPixelValue = 36
 MissOffset[0] = 3: MissOffset[1] = 2: MissSEPixelValue = 42
 MissOffset[0] = -3: MissOffset[1] = 3: MissSEPixelValue = 43
 MissOffset[0] = -2: MissOffset[1] = 3: MissSEPixelValue = 44
 MissOffset[0] = -1: MissOffset[1] = 3: MissSEPixelValue = 45
 MissOffset[0] = 0: MissOffset[1] = 3: MissSEPixelValue = 46
 MissOffset[0] = 1: MissOffset[1] = 3: MissSEPixelValue = 47
 MissOffset[0] = 2: MissOffset[1] = 3: MissSEPixelValue = 48
 MissOffset[0] = 3: MissOffset[1] = 3: MissSEPixelValue = 49

< These are the offsets that I then print out - but they do not match 
those above! >

      Neighborhood Size = 24
      Iteration # 0
        Offset[0] = -3; OffSet[1] = -3; PixelValue = 1
        Offset[0] = -2; OffSet[1] = -3; PixelValue = 2
        Offset[0] = -1; OffSet[1] = -3; PixelValue = 3
        Offset[0] = 0; OffSet[1] = -3; PixelValue = 4
        Offset[0] = 1; OffSet[1] = -3; PixelValue = 5
        Offset[0] = 2; OffSet[1] = -3; PixelValue = 6
        Offset[0] = 3; OffSet[1] = -3; PixelValue = 7
        Offset[0] = -3; OffSet[1] = -2; PixelValue = 8
        Offset[0] = -2; OffSet[1] = -2; PixelValue = 14
        Offset[0] = -1; OffSet[1] = -2; PixelValue = 15
        Offset[0] = 0; OffSet[1] = -2; PixelValue = 21
        Offset[0] = 1; OffSet[1] = -2; PixelValue = 22
        Offset[0] = 2; OffSet[1] = -2; PixelValue = 28
        Offset[0] = 3; OffSet[1] = -2; PixelValue = 29
        Offset[0] = -3; OffSet[1] = -1; PixelValue = 35
        Offset[0] = -2; OffSet[1] = -1; PixelValue = 36
        Offset[0] = -1; OffSet[1] = -1; PixelValue = 42
        Offset[0] = 0; OffSet[1] = -1; PixelValue = 43
        Offset[0] = 1; OffSet[1] = -1; PixelValue = 44
        Offset[0] = 2; OffSet[1] = -1; PixelValue = 45
        Offset[0] = 3; OffSet[1] = -1; PixelValue = 46
        Offset[0] = -3; OffSet[1] = 0; PixelValue = 47
        Offset[0] = -2; OffSet[1] = 0; PixelValue = 48
        Offset[0] = -1; OffSet[1] = 0; PixelValue = 49

Here is the code that produces the above output:

  // Let's determine the largest dimension of the SE.

  long int max_miss_SE_dimension = ((MissSEValuesImageCols > 
MissSEValuesImageRows) ? MissSEValuesImageCols : MissSEValuesImageRows);

  // Then, based on this dimension, calculate the "radius" of the SE

  int miss_SE_radius = static_cast<int>((max_miss_SE_dimension / 2));

  ShapedNeighborhoodIteratorType::RadiusType MissSERadius;

  MissSERadius.Fill(miss_SE_radius);

  FaceCalculatorType MissFaceCalculator;
  FaceCalculatorType::FaceListType MissFaceList;
  FaceCalculatorType::FaceListType::iterator MissFaceIterator;

  MissFaceList = MissFaceCalculator( InputImage, 
DilatedImage->GetRequestedRegion(), MissSERadius );

  ImageRegionIteratorType MissImageIterator;

  InputSEValuesPixelType MissSEPixelValue;

  InputPixelType MissSumPixelValue;

  std::cout << "Implementing Grayscale Dilation Functionality ..." << 
std::endl;

  // Loop through all regions in the face list

  tempCount = 0;

  for ( MissFaceIterator = MissFaceList.begin(); MissFaceIterator != 
MissFaceList.end(); ++MissFaceIterator ) {

    std::cout << "   Processing Face # " << tempCount << std::endl;

    ShapedNeighborhoodIteratorType MissNeighborhoodIterator( 
MissSERadius, InputImage, *MissFaceIterator );
    MissImageIterator = ImageRegionIteratorType( DilatedImage, 
*MissFaceIterator );

    std::cout << "      miss_SE_radius = " << miss_SE_radius << std::endl;

    MissNeighborhoodIterator.ClearActiveList();

    unsigned int z = 0;
    for (int y = -miss_SE_radius; y <= miss_SE_radius; y++) {

      for (int x = -miss_SE_radius; x <= miss_SE_radius; x++) {

    ShapedNeighborhoodIteratorType::OffsetType MissOffset;

    if ((((x + miss_SE_radius) >= 0) && ((x + miss_SE_radius) < 
MissSEValuesImageCols)) &&
        (((y + miss_SE_radius) >= 0) && ((y + miss_SE_radius) < 
MissSEValuesImageRows))) {

      pixelIndex[0] = (x + miss_SE_radius); // Set the pixelIndex 
x/column position
      pixelIndex[1] = (y + miss_SE_radius); // Set the pixelIndex y/row 
position
     
      MissSEPixelValue = MissSEValuesImage->GetPixel( pixelIndex );
     
      if (MissSEPixelValue > 0) {

        MissOffset[0] = static_cast<int>(x);
        MissOffset[1] = static_cast<int>(y);
        MissNeighborhoodIterator.ActivateOffset(MissOffset);
        MissNeighborhoodIterator.SetPixelWeight(z, 
static_cast<InputPixelType>((MissSEPixelValue)));

        std::cout << " MissOffset[0] = " << MissOffset[0] << ": 
MissOffset[1] = " << MissOffset[1] << ": MissSEPixelValue = " << 
static_cast<int>(MissSEPixelValue) << std::endl;
       
        //std::cout << " ActiveIndexListSize = " << 
MissNeighborhoodIterator.GetActiveIndexListSize() << std::endl;
       
        z = MissNeighborhoodIterator.GetActiveIndexListSize();
      }

    }

      }
     
    }

    // Implements GreyScale Dilation

    //neighborhoodIterator.OverrideBoundaryCondition(&nbc);

    unsigned int MissNeighborhoodSize = MissNeighborhoodIterator.Size();

    std::cout << "      Neighborhood Size = " << MissNeighborhoodSize << 
std::endl;

    unsigned int tempCount2 = 0;

    MissNeighborhoodIterator.GoToBegin();

    while ( !MissNeighborhoodIterator.IsAtEnd() ) {

      std::cout << "      Iteration # " << tempCount2 << std::endl;

      for (unsigned int i = 0; i < MissNeighborhoodSize; ++i) {

    ShapedNeighborhoodIteratorType::OffsetType MissOffset;

    MissOffset = MissNeighborhoodIterator.GetOffset(i);

    std::cout << "        Offset[0] = " << MissOffset[0] << "; OffSet[1] 
= " << MissOffset[1] << "; PixelValue = " << 
MissNeighborhoodIterator.GetPixelWeight(i) << std::endl;

      }

      ++MissNeighborhoodIterator;
    }

insight-users-request at itk.org wrote:
> Send Insight-users mailing list submissions to
> 	insight-users at itk.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://www.itk.org/mailman/listinfo/insight-users
> or, via email, send a message with subject or body 'help' to
> 	insight-users-request at itk.org
>
> You can reach the person managing the list at
> 	insight-users-owner at itk.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Insight-users digest..."
>
>
> Today's Topics:
>
>    1. Insight Journal search reviews? (David Doria)
>    2. Re: Insight Journal search reviews? (Julien Jomier)
>    3. 4-Connectivity of itkMesh (load a PTX file)? (David Doria)
>    4. problem at building helloworld app with ITK: no exe	is
>       generated (Joaquin Panduro Civico)
>    5. Re: Re : Need to correct this example (Ram?n Casero Ca?as)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 4 Aug 2009 12:16:52 -0400
> From: David Doria <daviddoria+itk at gmail.com>
> Subject: [Insight-users] Insight Journal search reviews?
> To: ITK <insight-users at itk.org>
> Message-ID:
> 	<c19fcadc0908040916p715d7dcfi67a6c9408df2ce55 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> When I go to http://www.insight-journal.org/ and search for "Half-Edge" I
> get no results even though I see "Half-Edge" appear in the reviews of
> http://www.insight-journal.org/browse/publication/122 . I'm assuming this is
> not found because it is in a review? Is there a way to make the search also
> search the reviews at the same time as the abstracts and whatever it
> currently searches?
>
> Thanks,
>
> David
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://www.itk.org/pipermail/insight-users/attachments/20090804/b83a94c7/attachment-0001.htm>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 04 Aug 2009 12:20:15 -0400
> From: Julien Jomier <julien.jomier at kitware.com>
> Subject: Re: [Insight-users] Insight Journal search reviews?
> To: David Doria <daviddoria+itk at gmail.com>
> Cc: ITK <insight-users at itk.org>
> Message-ID: <4A785FBF.5030202 at kitware.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hi David,
>
> You are correct, the Insight Journal currently doesn't search in 
> reviews. It's definitely doable, could you log a feature request at
>
>    http://public.kitware.com/Bug
>
> Thanks,
> Julien
>
> David Doria wrote:
>   
>> When I go to http://www.insight-journal.org/ and search for "Half-Edge" 
>> I get no results even though I see "Half-Edge" appear in the reviews of 
>> http://www.insight-journal.org/browse/publication/122 . I'm assuming 
>> this is not found because it is in a review? Is there a way to make the 
>> search also search the reviews at the same time as the abstracts and 
>> whatever it currently searches?
>>
>> Thanks,
>>
>> David
>>
>>
>> ------------------------------------------------------------------------
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.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
>>     
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 4 Aug 2009 12:30:01 -0400
> From: David Doria <daviddoria+itk at gmail.com>
> Subject: [Insight-users] 4-Connectivity of itkMesh (load a PTX file)?
> To: ITK <insight-users at itk.org>
> Message-ID:
> 	<c19fcadc0908040930m7fcfd17cyc5fa20f01a6c239d at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> A typical LiDAR scanner will provide points acquired on a uniform spherical
> grid. The result is a point cloud with known 4-connectivity (i.e. we know
> which point is above, below, left, and right of the current point). Is it
> reasonable to store this data in a 2D Vector Image where the values in each
> pixel are the 3D point coordinates? It seems more intuitive to store it in
> an actual mesh data structure (itkMesh and possibly use itkQuadEdge?) but
> then it doesn't seem possible to traverse it in rows/columns like the Vector
> Image method as well as use existing methods of searching a 3d radius, etc.
>
> Can anyone comment on this trade off? Or maybe someone has already written
> code to load a ptx file into some an ITK data structure?
>
> Thanks,
>
> David
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://www.itk.org/pipermail/insight-users/attachments/20090804/b704791b/attachment-0001.htm>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 4 Aug 2009 19:08:49 +0200
> From: Joaquin Panduro Civico <joaquin.pnd at gmail.com>
> Subject: [Insight-users] problem at building helloworld app with ITK:
> 	no exe	is generated
> To: insight-users at itk.org
> Message-ID:
> 	<7742366e0908041008t4e502494udfc3cce04388fb6c at mail.gmail.com>
> Content-Type: text/plain; charset="windows-1252"
>
> Dear ITK support team:
>
>
>
> I am a starter to ITK, and I am writing regarding a problem during
> installation. I have successfully followed the steps in the itk software
> guide until ?Hello World? step (page 17, section 2.2 of ITK software guide).
>
>
>
> In particular, the executable will not generate, although no error, nor
> warning is launched.
>
> Taking a look at the logs generated by Visual Studio, I have found 2 events
> that may be the source of the problems, but I am not sure whether this is
> correct or not, and anyway I can not guess the solution, and here is why I
> would highly appreciate your help. Here you are the two events that I have
> detected as "interesting":
>
>
>
> 1.       The following lines are generated  (in subprojects 2,3 and 33)
> during ITK building process in Visual Studio:
>
> 2>LINK : no se encontr? C:\pfc\ITKbinarydir\bin\Debug\itksysProcessFwd9x.exe
> o no lo gener? el ?ltimo v?nculo
>
> 3>LINK : no se encontr?
> C:\pfc\ITKbinarydir\bin\Debug\itksysEncodeExecutable.exe
>
> 33>LINK : no se encontr? C:\pfc\ITKbinarydir\bin\Debug\itkTestDriver.exe
>
>  In English, these lines would be:
>
> LINK:  the file C:\pfc\ITKbinarydir\bin\Debug\XXXXXXXX.exe was not found, or
> either the last link did not generate it)
>
>
>
> 2.       During the build of ITK in Visual Studio, the following line is
> generated 21 times:
>
> 31>cl : L?nea de comandos warning D9002 : se omite la opci?n desconocida
> '-library=stlport4' (in English, Command line warning D9002: unknown option
> omitted ?library=stlport4?)
>
> This message appears also on the log result of building the helloworld
> application.
>
>
>
>  ..................
>
>
> Below is a summary of the software I am using (I have followed the
> recommendations of the software guide), and the steps I followed correctly
> before I  encountered the problem described above:
>
>
>
> Operating System used:              windows XP Home Edition Version 2002,
> SP3;
>
> Compiler:                                           Microsoft Visual C++
> 2008 Express Edition.
>
> I have been able to compile, link and execute properly a helloworld
> application written in C (unconnected to ITK ?i.e. prior to ITK
> installation)
>
> ITK:                                                       I have downloaded
> ITK version 3.14;
>
> CMAKE:                                              I have downloaded cmake
> version 2.6;
>
>
>
> I have  successfully generated the build file for ITK through cmake, as
> indicated in the ITK software guide;
>
> Afterwards, I have successfully opened in Visual C++ the file "ITK.sln" that
> cmake generated;
>
>  ....................
>
>
> In case you would need the complete build-logs for a more accurate problem
> diagnosis, please do not hesitate to ask me for it.
>
>
>
>
>
> Any help will be truly appreciated,
>
> Thanks in advance,
>
> Best regards
>
> Joaquin
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://www.itk.org/pipermail/insight-users/attachments/20090804/d359b89d/attachment-0001.htm>
>
> ------------------------------
>
> Message: 5
> Date: Tue, 04 Aug 2009 19:44:35 +0100
> From: Ram?n Casero Ca?as <ramon.casero at comlab.ox.ac.uk>
> Subject: Re: [Insight-users] Re : Need to correct this example
> To: Syrine Sahmim <syrine.sahmim at yahoo.fr>
> Cc: insight-users at itk.org
> Message-ID: <4A788193.3070404 at comlab.ox.ac.uk>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Syrine Sahmim wrote:
>   
>> Hi,
>> I'm really ashamed. i know i disturb you from your work.i have buy a book of c++ and i use internet but in  vain i still don't know 
>> many things and i still learning at the same time. i will try and try to command better c++ and itk.the begining is still difficult.Really thank you for your help but want to konw others things if itis possible:
>>     
>
> Hi Syrine,
>
> Nothing to be ashamed of, but yes, it seems that you need to get 
> yourself familiar with programming.
>
> What's your background? Are you taking a course in programming, are you 
> in college...? Do you have access to lectures or a technical library?
>
>
>   
>> you have said :
>>     
>>>> Do not do that. Pass the arguments in at the command line properly.
>>>> Also if argc =2 then only argv[0] and argv[1] are valid. C starts
>>>> counting at 0.
>>>>         
>> please explain more to me what i must do step by step:
>> how do  i  pass the arguments at the command line properly . it's one of my problem? what i must do exactly
>> all i know that i debogue from c++ and after that i'll have the ms dos screen and i haven't the posibility to write the arguments in this screen because it's mentioned that i should clik to any key in the key board.
>>     
>
>
> I don't know what you mean with "debogue from c++". Do you mean "debug"? 
> What are you doing? Are you typing something? Are you clicking with the 
> mouse on an icon?
>
>
> The command line, or command prompt in Windows [1][4], is typically a 
> black window with silver letters. You can type commands there (you don't 
> use the mouse). A command will usually run a program.
>
> For example, if you have a program called "RegistrationExample.exe", 
> then you can run it by typing
>
>   C:\> RegistrationExample.exe
>
> Now suppose that your program needs some input arguments, for example 2 
> DICOM files with the data you are trying to register.
>
> Suppose also that this program in particular expects the first input 
> argument to be the file name of the fixed image, and the second argument 
> to be the file name of the moving image. This is known as the "syntax". 
> When you try to run the program without arguments, it will usually show 
> you the expected syntax:
>
> Syntax:
>
>   RegistrationExample.exe fixed.dcm moving.dcm
>
>
> So now you want to run something like this, using the command line
>
>   C:\> RegistrationExample.exe heart1.dcm heart2.dcm
>
>
> OK, so this is all from the point of view of the user and the command 
> line. Now we are going to look at this from the point of view of the 
> person writting the C++ program.
>
> When you are writing a program in C++ yourself, or using one of the 
> Examples in ITK, what you get is a source code file with extension .cpp, 
> that contains several things.
>
> One of these things is the "entry point", that is, the main() function [2].
>
> A common way of working with main() is the following
>
> <CODE>
> int main( int argc, char *argv[] )
> {
>
>   // your program code here
> }
> </CODE>
>
> argc is a numerical variable, and it contains the _number_ of input 
> arguments.
>
> argv is an array of strings that contains the _input argments_.
>
> For example, if you call your program with
>
>   C:\> RegistrationExample.exe heart1.dcm heart2.dcm
>
> then you will have
>
>   argc --------> 3
>   argv[0] -----> "RegistrationExample.exe"
>   argv[1] -----> "heart1.dcm"
>   argv[2] -----> "heart2.dcm"
>
> You can read more about this with a Google search, for example [3]
>
>
> [1] http://en.wikipedia.org/wiki/Command_Prompt_(Windows)
> [2] http://en.wikipedia.org/wiki/Main_function_(programming)
> [3] 
> http://publications.gbdirect.co.uk/c_book/chapter10/arguments_to_main.html
> [4] http://www.bleepingcomputer.com/tutorials/tutorial76.html
>
> Cheers,
>
> Ramon.
>
>   



More information about the Insight-users mailing list