[Insight-users] Boundary Pixel Access
Luis Ibanez
luis . ibanez at kitware . com
Thu, 22 Aug 2002 21:42:12 -0400
Hi Zhao,
Probably the best way of dealing with boundary
problems is to use the Neighborhood iterator.
This iterator will prepare first a list of the
regions in the image in which a particular
neighborhood will not fit entirely.
The iterator walk fast through the region
that is free of boundary conflicts and slowly
(doing more testing) through the boundary regions.
The typical code is as follows: (extracted from
itkMorphologyImageFilter.txx)
================================================
// Find the boundary "faces"
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType
faceList;
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType> fC;
faceList = fC(this->GetInput(), outputRegionForThread,
m_Kernel.GetRadius());
typename
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType::iterator
fit;
fit = faceList.begin();
// Process the non-boundary face
n_iter = NeighborhoodIteratorType(m_Kernel.GetRadius(),
this->GetInput(), *fit);
ImageRegionIterator<TOutputImage> o_iter(this->GetOutput(), *fit);
n_iter.GoToBegin();
o_iter.GoToBegin() ;
while ( ! n_iter.IsAtEnd() )
{
o_iter.Set ( this->Evaluate(n_iter, m_Kernel) );
++n_iter ;
++o_iter ;
}
// Process the boundary faces, these are N-d regions which border the
// edge of the buffer
for (++fit; fit != faceList.end(); ++fit)
{
b_iter = SmartNeighborhoodIteratorType(
m_Kernel.GetRadius(),this->GetInput(), *fit);
o_iter = ImageRegionIterator<OutputImageType>(
this->GetOutput(), *fit);
b_iter.OverrideBoundaryCondition(&BC);
b_iter.GoToBegin();
while ( ! b_iter.IsAtEnd() )
{
o_iter.Set( this->Evaluate(b_iter, m_Kernel) );
++b_iter;
++o_iter;
}
}
---
Luis
==================================================
zhao wrote:
> Hi all,
> How to verify whether a pixels (accessed using an ImageRegionIterator or NeighborhoodIterator) is on the boundary of an image or not? Thanks!
>
> Zhao ChenGuang
> P.O.Box:010,
> Dept. BME,
> Shanghai Jiao Tong University,
> 1954# Hua Shan Road,
> Shanghai,P.R.China,
> 200030
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>
>