<div dir="ltr"><div><div>Hi Jan,<br><br></div>Note that you can update ITK's documentation via the web, without having to bother with setting up Git locally. Class pages have an "Edit comments" link (I'm working to make this more obvious), that allow you to suggest changes to comments / documentation. The changes can then be reviewed by the community via Gerrit [1] before being merged.<br>
<br></div>For DefaultVectorPixelAccessor, the page is at [2]. Any improvements you can make would be welcome<br><div><div><br>[1] <a href="http://review.source.kitware.com">http://review.source.kitware.com</a><br>[2] <a href="http://www.itk.org/editdoc/editcomments.php?file=itkDefaultVectorPixelAccessor.h">http://www.itk.org/editdoc/editcomments.php?file=itkDefaultVectorPixelAccessor.h</a><br>
<br></div><div>Best,<br></div><div>Brian<br><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 11, 2014 at 10:54 AM, Jan Ehrhardt <span dir="ltr"><<a href="mailto:ehrhardt@imi.uni-luebeck.de" target="_blank">ehrhardt@imi.uni-luebeck.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>Hi Brad, hi Matt,<br>
      <br>
      thanks! That is a very good solution. I did not realize that an
      operator= does the job and I assumed
      it=ImageRegionIterator(myfeatureImage2, region) will not work.
      Sorry.<br>
      <br>
      So, this is the solution for my problem. Thanks to all for your
      help.<br>
      <br>
      To come back to my initial post about the
      DefaultVectorPixelAccessor. I think, the documentation of this
      class should be improved to avoid confusion about the parameters
      of the Get() and Set() method. As far as I see, the correct way to
      access an vector at a pixel offset is <span>not intuitive</span>:<br>
      accessor.Get(*(pBuffer+offset), offset);<br>
      <br>
      Best regards,<br>
      Jan<div><div class="h5"><br>
      <br>
      <br>
      <br>
      On 03/11/2014 02:18 PM, Bradley Lowekamp wrote:<br>
    </div></div></div><div><div class="h5">
    <blockquote type="cite">
      
      OK,
      <div><br>
      </div>
      <div>Then another approach is to take advantage that the iterators
        are default constructible. Something like this:</div>
      <div><br>
      </div>
      <div>ImageRegionIterator it2;</div>
      <div>if (myfeatureImage2)</div>
      <div>{</div>
      <div><span style="white-space:pre-wrap"> </span>it
        = ImageRegionIterator(myfeatureImage2, region);</div>
      <div>}</div>
      <div><br>
      </div>
      <div>There are a lot of options.</div>
      <div><br>
      </div>
      <div>Hope one works for you,</div>
      <div>Brad</div>
      <div><br>
        <div>
          <div>On Mar 11, 2014, at 9:04 AM, Jan Ehrhardt <<a href="mailto:ehrhardt@imi.uni-luebeck.de" target="_blank">ehrhardt@imi.uni-luebeck.de</a>>
            wrote:</div>
          <br>
          <blockquote type="cite">
            
            <div text="#000000" bgcolor="#FFFFFF">
              <div>Hi Brad,<br>
                <br>
                yes this is an alternative way, but the code inside the
                loop has approx. 200 lines (is quite complicated stuff)
                and I'm still testing and in your solution, I have to
                maintain the code four times...<br>
                <br>
                Best regards,<br>
                Jan<br>
                <br>
                On 03/11/2014 01:55 PM, Bradley Lowekamp wrote:<br>
              </div>
              <blockquote type="cite"> Hello,
                <div><br>
                </div>
                <div>You are right that the GetPixel methods are slow,
                  but that's why iterators are recommended.</div>
                <div><br>
                </div>
                <div>Currently you are trying to have you "if(
                  featureImage2 )" in side the per-pixel loop. Not only
                  does this cause you iterator initialization issue it
                  also is slower of have this if statement inside the
                  loop.</div>
                <div><br>
                </div>
                <div>Here is an alternative way to construct your logic:</div>
                <div><br>
                </div>
                <div><a href="https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/ImageFilterBase/include/itkBinaryFunctorImageFilter.hxx#L224-L297" target="_blank">https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/ImageFilterBase/include/itkBinaryFunctorImageFilter.hxx#L224-L297</a></div>

                <div><br>
                </div>
                <div>Hope this help,</div>
                <div>Brad</div>
                <div><br>
                  <div>
                    <div>On Mar 11, 2014, at 8:34 AM, Jan Ehrhardt <<a href="mailto:ehrhardt@imi.uni-luebeck.de" target="_blank">ehrhardt@imi.uni-luebeck.de</a>>

                      wrote:</div>
                    <br>
                    <blockquote type="cite">
                      <div text="#000000" bgcolor="#FFFFFF">
                        <div>Hi Matt,<br>
                          <br>
                          yes, I currently use the ITK iterators, but I
                          have the following problem. <br>
                          <br>
                          Standard code looks like:<br>
                          <br>
                          itk::ImageRegionIterator<ImageType1> it(
                          radius, myImage, region );<br>
                          itk::ImageRegionIterator<ImageType2>
                          featureIt1( radius, featureImage1, region );<br>
                          itk::ImageRegionIterator<ImageType3>
                          featureIt2( radius, featureImage2, region );<br>
                          <br>
                          it.GotoBegin();<br>
                          featureIt1.GotoBegin();<br>
                          featureIt2.GotoBegin();<br>
                          <br>
                          while(!it.IsAtEnd())<br>
                          {<br>
                             // do some complicated processing stuff
                          with or without feature1 and/or feature2<br>
                          <br>
                            ++it;<br>
                            ++featureIt1;<br>
                            ++featureIt2;<br>
                          }<br>
                          <br>
                          I only know at runtime, whether featureImage1
                          and/or featureImage2 are available. If<br>
                          featureImage1 or featureImage2 is NULL, a
                          segmentation fault occurs.<br>
                          <br>
                          Therefore, I have currently implemented:<br>
                          <br>
                          itk::ConstNeighborhoodIterator<ImageType1>
                          it( radius, myImage, region );<br>
                          <br>
                          it.GotoBegin();<br>
                          <br>
                          while(!it.IsAtEnd())<br>
                          {<br>
                             currentIndex=it.GetIndex();<br>
                             if( featureImage1.IsNotNull())<br>
                             {<br>
                                  // use
                          featureImage1->GetPixel(currentIndex) to
                          process feature 1<br>
                              }<br>
                              if( featureImage2.IsNotNull())<br>
                             {<br>
                                  // use
                          featureImage2->GetPixel(currentIndex) to
                          process feature 2<br>
                             }<br>
                             <br>
                             // do some other stuff<br>
                          <br>
                            ++it;<br>
                          }<br>
                          <br>
                          The Image::GetPixel() method is quite
                          time-consuming and therefore I look for a more
                          efficient method<br>
                          to implement this code (without writing four
                          different versions).<br>
                          <br>
                          Any suggestions?<br>
                          <br>
                          Best regards,<br>
                          Jan<br>
                          <br>
                          On 03/11/2014 06:12 AM, Matt McCormick wrote:<br>
                        </div>
                        <blockquote type="cite">
                          <div dir="ltr">Hi Jan,
                            <div><br>
                            </div>
                            <div>To iterator through an Image or
                              VectorImage, use the Iterators as
                              described in the Software Guide [1]</div>
                            <div><br>
                            </div>
                            <div>HTH,</div>
                            <div>Matt</div>
                            <div><br>
                            </div>
                            <div>[1] <a href="http://itk.org/ItkSoftwareGuide.pdf" target="_blank">http://itk.org/ItkSoftwareGuide.pdf</a></div>
                          </div>
                          <div class="gmail_extra"><br>
                            <br>
                            <div class="gmail_quote">On Thu, Mar 6, 2014
                              at 8:23 AM, Jan Ehrhardt <span dir="ltr"><<a href="mailto:ehrhardt@imi.uni-luebeck.de" target="_blank">ehrhardt@imi.uni-luebeck.de</a>></span>
                              wrote:<br>
                              <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi folks,<br>
                                <br>
                                I want to iterate through a vector image
                                without an iterator. My approach was:<br>
                                <br>
                                    MultiChannelImageType::AccessorType
                                accessor =
                                pImage->GetPixelAccessor();<br>
                                   
                                MultiChannelImageType::InternalPixelType*
                                pBuffer = pImage->GetBufferPointer();<br>
                                <br>
                                    for( OffsetValueType i = from; i
                                < to; ++i )<br>
                                    {<br>
                                        vecPixel =
                                accessor.Get(*pBuffer, i);<br>
                                    }<br>
                                <br>
                                but the results are not correct (see
                                bug(?) below). If the bug(?) in
                                DefaultVectorPixelAccessor is corrected
                                ( m_OffsetMultiplier = l ) the behaviour
                                of standard itk iterators change. I
                                assume, I don't understand the
                                parameters of
                                DefaultVectorPixelAccessor::Get()
                                correctly.<br>
                                How can I use the
                                DefaultVectorPixelAccessor correctly?<br>
                                <br>
                                best,<br>
                                jan
                                <div>
                                  <div><br>
                                    <br>
                                    On 03/06/2014 12:25 PM, Jan Ehrhardt
                                    wrote:<br>
                                    <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Hi folks,<br>
                                      <br>
                                      there is a bug in
                                      DefaultVectorPixelAccessor (ITK
                                      4.4.0):<br>
                                      <br>
                                        void
                                      SetVectorLength(VectorLengthType
                                      l)<br>
                                        {<br>
                                          m_VectorLength = l;<br>
                                          m_OffsetMultiplier = ( l - 1
                                      );<br>
                                        }<br>
                                      <br>
                                       
                                      DefaultVectorPixelAccessor(VectorLengthType
                                      l)<br>
                                        {<br>
                                          m_VectorLength = l;<br>
                                          m_OffsetMultiplier = l - 1;<br>
                                        }<br>
                                      <br>
                                      OffsetMultiplier should be
                                      m_OffsetMultiplier = l;<br>
                                      <br>
                                      Best regards,<br>
                                      Jan<br>
                                      <br>
                                    </blockquote>
                                    <br>
_______________________________________________<br>
                                    Community mailing list<br>
                                    <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
                                    <a href="http://public.kitware.com/cgi-bin/mailman/listinfo/community" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/community</a><br>
                                  </div>
                                </div>
                              </blockquote>
                            </div>
                            <br>
                          </div>
                        </blockquote>
                        <br>
                      </div>
                      _______________________________________________<br>
                      Community mailing list<br>
                      <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
                      <a href="http://public.kitware.com/cgi-bin/mailman/listinfo/community" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/community</a><br>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </blockquote>
              <br>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org">Community@itk.org</a><br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/community" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/community</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Brian Helba<br>Medical Imaging<br>Kitware, Inc.<br>
</div>