~ubuntu-branches/ubuntu/precise/insighttoolkit/precise

« back to all changes in this revision

Viewing changes to Code/BasicFilters/itkCannyEdgeDetectionImageFilter.txx

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-12-19 20:16:49 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081219201649-drt97guwl2ryt0cn

* New upstream version.
  - patches/nifti-versioning.patch: Remove.  Applied upstream.
  - control:
  - rules: Update version numbers, package names.

* control: Build-depend on uuid-dev (gdcm uses it).

* copyright: Update download URL.

* rules: Adhere to parallel=N in DEB_BUILD_OPTIONS by setting MAKEFLAGS.

* compat: Set to 7.
* control: Update build-dep on debhelper to version >= 7.

* CMakeCache.txt.debian: Set CMAKE_BUILD_TYPE to "RELEASE" so that we
  build with -O3 (not -O2), necessary to optimize the templated code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
  Program:   Insight Segmentation & Registration Toolkit
4
4
  Module:    $RCSfile: itkCannyEdgeDetectionImageFilter.txx,v $
5
5
  Language:  C++
6
 
  Date:      $Date: 2005-11-16 19:31:39 $
7
 
  Version:   $Revision: 1.52 $
 
6
  Date:      $Date: 2008-10-13 18:54:26 $
 
7
  Version:   $Revision: 1.53 $
8
8
 
9
9
  Copyright (c) Insight Software Consortium. All rights reserved.
10
10
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
14
14
     PURPOSE.  See the above copyright notices for more information.
15
15
 
16
16
=========================================================================*/
17
 
#ifndef _itkCannyEdgeDetectionImageFilter_txx
18
 
#define _itkCannyEdgeDetectionImageFilter_txx
 
17
#ifndef __itkCannyEdgeDetectionImageFilter_txx
 
18
#define __itkCannyEdgeDetectionImageFilter_txx
19
19
#include "itkCannyEdgeDetectionImageFilter.h"
20
20
 
21
21
#include "itkZeroCrossingImageFilter.h"
238
238
  //Calculate the 2nd derivative
239
239
  for(i = 0; i < ImageDimension-1; i++)
240
240
    {
241
 
    for(j = i+1; j < ImageDimension ; j++)
 
241
    for(j = i+1; j < ImageDimension; j++)
242
242
      {
243
243
      dxy[k] = 0.25 * it.GetPixel(m_Center - m_Stride[i] - m_Stride[j])
244
244
        - 0.25 * it.GetPixel(m_Center - m_Stride[i]+ m_Stride[j])
340
340
  // derivative.
341
341
  this->Compute2ndDerivative();
342
342
 
343
 
  this->Compute2ndDerivativePos();      
 
343
  this->Compute2ndDerivativePos();
344
344
  
345
345
  // 3. Non-maximum suppression----------
346
346
  
469
469
    }
470
470
}
471
471
 
472
 
/*  
473
 
template< class TInputImage, class TOutputImage >
474
 
void
475
 
CannyEdgeDetectionImageFilter< TInputImage, TOutputImage >
476
 
::FollowEdge(IndexType index)
477
 
{
478
 
 
479
 
  typename OutputImageType::Pointer output = this->GetOutput();
480
 
  float value;
481
 
  IndexType nIndex;
482
 
 
483
 
  
484
 
  //assign iterator radius
485
 
  Size<ImageDimension> radius; radius.Fill(1);
486
 
  
487
 
  ConstNeighborhoodIterator<TOutputImage> oit(radius, output, output->GetRequestedRegion());
488
 
  
489
 
  ImageRegionIteratorWithIndex<TOutputImage> uit(m_UpdateBuffer,
490
 
                                                 m_UpdateBuffer->GetRequestedRegion());
491
 
  
492
 
  uit.SetIndex(index);
493
 
  
494
 
  if(uit.Get() ==1) return;
495
 
  
496
 
  uit.Value() = 1;
497
 
  
498
 
  int nSize = m_Center * 2 +1;
499
 
  
500
 
  oit.SetLocation(index);
501
 
  
502
 
  for(int i = 0; i < nSize; i++)
503
 
    {
504
 
    nIndex = oit.GetIndex(i);
505
 
    uit.SetIndex(nIndex);
506
 
    if(InBounds(nIndex))
507
 
      if(oit.GetPixel(i) > m_LowerThreshold && uit.Value() != 1  )
508
 
        {
509
 
        uit.Value() = 1;
510
 
        oit.SetLocation(nIndex);
511
 
        i = -1;
512
 
        }
513
 
    }
514
 
  
515
 
}
516
 
*/
517
 
 
518
472
template< class TInputImage, class TOutputImage >
519
473
bool
520
474
CannyEdgeDetectionImageFilter< TInputImage, TOutputImage >
615
569
                    m_ComputeCannyEdge1stDerivativeOper);
616
570
        }
617
571
      
618
 
      gradMag = vcl_sqrt((double)gradMag);          
 
572
      gradMag = vcl_sqrt((double)gradMag);
619
573
      derivPos = zero;
620
574
      for ( unsigned int i = 0; i < ImageDimension; i++)
621
575
        {
629
583
        derivPos += dx1[i] * directional[i];
630
584
        }
631
585
          
632
 
      it.Value() = ((derivPos <= zero)) ;
 
586
      it.Value() = ((derivPos <= zero));
633
587
      it.Value() = it.Get() * gradMag;
634
588
      ++bit;
635
589
      ++bit1;
695
649
  os << "Variance: " << m_Variance << std::endl;
696
650
  os << "MaximumError: " << m_MaximumError << std::endl;
697
651
  os << indent << "Threshold: "
698
 
     << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>
699
 
    (m_Threshold)
 
652
     << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>(m_Threshold)
700
653
     << std::endl;
701
654
  os << indent << "UpperThreshold: "
702
 
     << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>
703
 
    (m_UpperThreshold)
 
655
     << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>(m_UpperThreshold)
704
656
     << std::endl;
705
657
  os << indent << "LowerThreshold: "
706
 
     << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>
707
 
    (m_LowerThreshold)
 
658
     << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>(m_LowerThreshold)
708
659
     << std::endl;
709
660
  os << indent << "OutsideValue: "
710
661
     << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>(m_OutsideValue)