[Insight-users] creating my first finding max value in neighborhood

john smith mkitkinsightuser at gmail.com
Mon Feb 28 11:05:22 EST 2011


I get these failures when I build my project.In the following lines I write
again my code and I highlight all the failures under the line on which they
have occured. Can you explain some of these mistakes as I am still
influenced in C?


---------------------------
max_value_neighborhood.cxx-----------------------------
--------------------------------------------------------------------------------------------------
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

#include "max_value_filter.h"

int main(int, char*[])
{
  // Setup types
  typedef itk::Image<unsigned char, 2>   ImageType;
  typedef itk::max_value_filter<ImageType>  FilterType;

  typedef itk::ImageFileReader<ImageType> ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName("test.png");
  reader->Update();

  // Create and the filter
  FilterType::Pointer filter = FilterType::New();
 see reference to class template instantiation
'itk::max_value_filter<TImage>' being compiled
  filter->SetInput(reader->GetOutput());
  filter->Update();

  typedef  itk::ImageFileWriter< ImageType  > WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetFileName("result.png");
  writer->SetInput(filter->GetOutput());
  writer->Update();

  return EXIT_SUCCESS;
}



----------------------------
max_value_filter.txx--------------------------------
-------------------------------------------------------------------------------------
#ifndef __itkmax_value_filter_txx
#define __itkmax_value_filter_txx

#include "max_value_filter.h"
#include "itkObjectFactory.h"
#include "itkImageRegionIterator.h"
#include "itkConstNeighborhoodIterator.h"

namespace itk
{

template< class TImage>
void max_value_filter< TImage>
::GenerateData()
{
 while compiling class template member function 'void
itk::max_value_filter<TImage>::GenerateData(void)'
  typename TImage::ConstPointer input = this->GetInput();

  typename TImage::Pointer output = this->GetOutput();
  output->SetRegions(input->GetLargestPossibleRegion());
  output->Allocate();

  itk::ImageRegionIterator<TImage> outputIterator(output,
output->GetLargestPossibleRegion());
  itk::ImageRegionConstIterator<TImage> inputIterator(input,
input->GetLargestPossibleRegion());




  while(!inputIterator.IsAtEnd())
    {

TImage::IndexType max = inputIterator.GetIndex(0);
 'itk::ImageConstIterator<TImage>::GetIndex' : function does not take 1
arguments

    for(unsigned int i = 1; i < 9; i++)
      {
      TImage::IndexType index = inputIterator.GetIndex(i);


        if (max<index)
error C2676: binary '<' : 'itk::Index<VIndexDimension>' does not define this
operator or a conversion to a type acceptable to the predefined operator
                      {
                        max = inputIterator.GetIndex(i);
error C2660: 'itk::ImageConstIterator<TImage>::GetIndex' : function does not
take 1 arguments
                      }


      bool IsInBounds;
      inputIterator.GetPixel(i, IsInBounds);
 'GetPixel' : is not a member of 'itk::ImageRegionConstIterator<TImage>'

      }

    outputIterator.Set(inputIterator.Get(max));
error C2660: 'itk::ImageConstIterator<TImage>::Get' : function does not take
1 arguments

    ++inputIterator;
    ++outputIterator;
    }


}

}// end namespace


#endif





2011/2/28 David Doria <daviddoria at gmail.com>

> On Mon, Feb 28, 2011 at 10:22 AM, john smith <mkitkinsightuser at gmail.com>wrote:
>
>> Hi to all,
>>
>>  I am trying to develop my first filter in itk using visualstudio2010 and
>> cmake. This filter devides my input image into neighborhoods of nine pixels
>> and finds their maximum value. Then, this value is transfered to one pixel
>> of my output image. I have written the following code, but I have some
>> failures that I cannot understand. Could someone help me to overide my
>> problems? Furthermore, I would like to know if it is possible to write my
>> own filter only with .cxx and .txt files, like*
>> http://www.itk.org/Wiki/ITK/Examples/Iterators/ConstNeighborhoodIterator*.
>>
>>
>> Thanks
>>
>>
> Can you describe the failures? Are they compiler errors? Crashes? Incorrect
> results?
>
> David
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110228/79011acb/attachment.htm>


More information about the Insight-users mailing list