From a57b7396791f92abe26212ef805b228968982cd4 Mon Sep 17 00:00:00 2001 From: Caroline Ruffel <caroline.ruffel@c-s.fr> Date: Wed, 22 Mar 2006 09:02:29 +0000 Subject: [PATCH] nomsg --- Code/FeatureExtraction/otbLineRatioDetector.h | 22 ++++++++++------ .../otbLineRatioDetector.txx | 16 ++++++------ Code/FeatureExtraction/otbTouziEdgeDetector.h | 25 ++++++++++++------- .../otbTouziEdgeDetector.txx | 22 ++++++++-------- 4 files changed, 49 insertions(+), 36 deletions(-) diff --git a/Code/FeatureExtraction/otbLineRatioDetector.h b/Code/FeatureExtraction/otbLineRatioDetector.h index 24e77b1317..a4bed9bb2a 100755 --- a/Code/FeatureExtraction/otbLineRatioDetector.h +++ b/Code/FeatureExtraction/otbLineRatioDetector.h @@ -29,26 +29,32 @@ namespace otb /** \class LineRatioDetector * \brief Application of the filter of detection of linear features * - * This class implements the detector D1 of Tupin used to detect + * This class implements the Tupin's detector D1 used to detect * two parallel lines. This detector is derived from the coupling of two * ratio edge detectors (Touzi detector) on both side of a region. * - * The region is devided in three zones. + * The region is devided in three zones to delimite two parallel lines. * The size of one zone is defined by the product of the width * of the linear feature by its length. * - * For each vertical edge, we calculate the intensity of linear feature - * R_{12}(\theta_{0}) between zone 1 and 2 and R_{13}(\theta_{0}) between - * zone 1 and 3 according to the principle of the Touzi's filter. + * For each vertical line, we calculate the intensity of detection + * R_{12}(\theta_{0}) between zones 1 and 2 and R_{13}(\theta_{0}) between + * zones 1 and 3 according to the principle of the Touzi's filter. + * + * The response of the edge detector between two zones i and j is: + * \[R_{ij}=1-\min (\fract{\mu_{i}}{\mu_{j}};\fract{\mu_{j}}{\mu_{i}}) \] * * The intensity of detection in the three other directions R(\theta_{i}) - * is obtained by rotation of the pixels of each zone around the + * is determined by rotation of the pixels of each zone around the * pixel central of the region considered. By default, the pixel location after * rotation is determined by the Spline interpolator. * * Finally, the intensity of detection formed by the two parallel lines - * is determined by: - * \[R = min(R_{12};R_{13}) \] + * is determined by the minimum response of a ration edge detector on both sides + * of the linear structure: + * \[R = \min (R_{12};R_{13}) \] + * where R_{12} and R_{13} are the maximum response of the ratio edge + * detector of R(\theta_{i}). * * The exit is an image of intensity of detection. * diff --git a/Code/FeatureExtraction/otbLineRatioDetector.txx b/Code/FeatureExtraction/otbLineRatioDetector.txx index bc9fa9a94b..6f578ae870 100755 --- a/Code/FeatureExtraction/otbLineRatioDetector.txx +++ b/Code/FeatureExtraction/otbLineRatioDetector.txx @@ -152,7 +152,7 @@ void LineRatioDetector< TInputImage, TOutputImage, InterpolatorType> // Number of the zone unsigned int zone; - // Pixel numbers in each zone + // Pixel number in each zone const int NbPixelZone = (2*m_WidthLine+1)*(2*m_LengthLine+1); // Contains for the 4 directions the sum of the pixels belonging to each zone @@ -210,16 +210,16 @@ void LineRatioDetector< TInputImage, TOutputImage, InterpolatorType> } - // Location of the central pixel of the region + // Location of the pixel central of the region bitIndex = bit.GetIndex(); Xc = bitIndex[0]; Yc = bitIndex[1]; - // Location of the central pixel between zone 1 and zone 2 + // Location of the pixel central between zone 1 and zone 2 Xc12 = Xc - m_WidthLine - 1; - // Location of the central pixel between zone 1 and zone 3 + // Location of the pixel central between zone 1 and zone 3 Xc13 = Xc + m_WidthLine + 1; // Loop on the region @@ -268,12 +268,12 @@ void LineRatioDetector< TInputImage, TOutputImage, InterpolatorType> for ( int dir=0; dir<NB_DIR; dir++ ) { - // Calculation of the averages of the 3 zones + // Calculation of the mean for the 3 zones M1 = Sum[dir][0] / static_cast<double>(NbPixelZone); M2 = Sum[dir][1] / static_cast<double>(NbPixelZone); M3 = Sum[dir][2] / static_cast<double>(NbPixelZone); - // Calculation of the intensity of the linear feature + // Calculation of the intensity of detection if (( M1 != 0 ) && (M2 != 0)) R12_theta[dir] = static_cast<double>( 1 - MIN( (M1/M2), (M2/M1) ) ); else @@ -284,13 +284,13 @@ void LineRatioDetector< TInputImage, TOutputImage, InterpolatorType> else R13_theta[dir] = 0.; - // Determination of the maximum intensity of the linear feature + // Determination of the maximum intensity of detection R12 = static_cast<double>( MAX( R12, R12_theta[dir] ) ); R13 = static_cast<double>( MAX( R13, R13_theta[dir] ) ); } // end of the loop on the directions - // Intensity of the linear feature + // Intensity of detection R = MIN ( R12, R13 ); // Assignment of this value to the output pixel diff --git a/Code/FeatureExtraction/otbTouziEdgeDetector.h b/Code/FeatureExtraction/otbTouziEdgeDetector.h index f0ae82803b..c5509ac5bd 100755 --- a/Code/FeatureExtraction/otbTouziEdgeDetector.h +++ b/Code/FeatureExtraction/otbTouziEdgeDetector.h @@ -25,18 +25,25 @@ namespace otb /** \class TouziEdgeDetector * \brief Application of a filter of detection of contours. * - * We define a square window of size 2n+1. - * Then, we calculate the mean of each half window located on both sides of the contour - * in a given direction. The intensity of contour is then calculated in the four - * directions (\theta_{i}) vertical , diagonal 1, horizontal - * and diagonal 2 : - * \[R(\theta_{i}) = 1 - min(\fract{\mu_{1}/\mu_{2}};\fract{\mu_{2}/\mu_{1}}) \] + * This class implements the Touzi's ratio edge detector used to detect + * contours. + * + * We define a square region of size 2n+1 that we devided in two regions. * - * The exit is an image of intensity of the detection of contour: - * \[R = max ( (\theta_{i}), (\theta_{i}), (\theta_{i}), (\theta_{i})) \[ + * The response of the edge detector between two regions 1 and 2 in + * one direction \theta_{i} is: + * \[R(\theta_{i}) = 1 - \min (\fract{\mu_{1}}{\mu_{2}};\fract{\mu_{2}}{\mu_{1}}) \] + * where \mu_{1} and \mu_{2} are the mean of regions 1 and 2. + * + * The intensity of contour is calculated in four directions + * vertical , diagonal 1, horizontal and diagonal 2. + * + * The exit is an image of intensity of the detection of contour R, the + * maximum response of the ratio edge detector of R(\theta_{i}: + * \[R = \max ( R(\theta_{i}) ) \] * * An image of the direction of contours can also be determined by this filter: - * \[D = \fract{\sum_{i=1}^{4} s_{i}\theta_{i}R(\theta_{i})}{\sum_{i=1}^{4} R(\theta_{i}} \[ + * \[D = \fract{\sum_{i=1}^{4} s_{i}\theta_{i}R(\theta_{i})}{\sum_{i=1}^{4} R(\theta_{i}} \] * where \[if \mu_{1}>\mu_{2} s_{i}=+1 \] * \[else if \mu_{1}<\mu_{2} s_{i}=-1 \] * diff --git a/Code/FeatureExtraction/otbTouziEdgeDetector.txx b/Code/FeatureExtraction/otbTouziEdgeDetector.txx index 8abb8630b0..10de01d812 100755 --- a/Code/FeatureExtraction/otbTouziEdgeDetector.txx +++ b/Code/FeatureExtraction/otbTouziEdgeDetector.txx @@ -160,8 +160,8 @@ void TouziEdgeDetector< TInputImage, TOutputImage> // --------------- // Number of direction const int NB_DIR = 4; - // Number of half window of the filter - const int NB_WIN = 2; + // Number of region of the filter + const int NB_REGION = 2; // Definition of the 4 directions double Theta[NB_DIR]; @@ -171,11 +171,11 @@ void TouziEdgeDetector< TInputImage, TOutputImage> Theta[3] = 3*M_PI / 4. ; - // contains for the 4 directions the sum of the pixels belonging to each half window - double Sum[NB_DIR][NB_WIN]; - // Mean of half window 1 + // contains for the 4 directions the sum of the pixels belonging to each region + double Sum[NB_DIR][NB_REGION]; + // Mean of region 1 double M1; - // Mean of half window 2 + // Mean of region 2 double M2; // Result of the filter for each direction double R_theta[NB_DIR]; @@ -222,7 +222,7 @@ void TouziEdgeDetector< TInputImage, TOutputImage> // Initialisations for (int dir=0; dir<NB_DIR; dir++) { - for (int m=0; m<NB_WIN; m++) + for (int m=0; m<NB_REGION; m++) Sum[dir][m] = 0.; } @@ -231,7 +231,7 @@ void TouziEdgeDetector< TInputImage, TOutputImage> Sum_R_theta = 0.; - // Loop on the window of the filter + // Loop on pixels of the filter for (i = 0; i < neighborhoodSize; ++i) { @@ -239,7 +239,7 @@ void TouziEdgeDetector< TInputImage, TOutputImage> x = bitIndex[0]; y = bitIndex[1]; - // We determine for each direction with which half window the pixel belongs. + // We determine for each direction with which region the pixel belongs. // Vertical direction if ( x < xc ) @@ -265,13 +265,13 @@ void TouziEdgeDetector< TInputImage, TOutputImage> else if ( (y-yc) > (x-xc) ) Sum[3][1] += static_cast<double>(bit.GetPixel(i)); - } // end of the loop on the pixels of the window + } // end of the loop on pixels of the filter // Loop on the 4 directions for ( int dir=0; dir<NB_DIR; dir++ ) { - // Calculation of the averages of the 2 half windows + // Calculation of the mean of the 2 regions M1 = Sum[dir][0] / static_cast<double>(m_Radius[0]*(2*m_Radius[0]+1)); M2 = Sum[dir][1] / static_cast<double>(m_Radius[0]*(2*m_Radius[0]+1)); -- GitLab