the method can be summarized as follows : first of all , the center of the cartridge case base ( 1 ) is detected . according to this center , the surface height matrix is subjected to polar transformation and thus the polar height matrix is obtained . a one - dimensional signal is acquired by calculation of the mean value on the radius axis applied on the polar height matrix . this signal is called “ average height signal on the basis of radius ” ( ahsbr ). on the ahsbr , regions similar to circle signal models are determined and thus circles are detected . finally , the firing pin mark ( 4 ) region is determined by threshold processing of the primer ( 2 ) region surface height matrix . subsequently , letters on the cartridge case base ( 1 ) are detected by using slope matrices . in order to find the center of the cartridge case base ( 1 ), a surface height matrix ( 5 ) ( shm ) including the entire of the cartridge case base ( 1 ) region is quantized ( 6 ) first . on the basis of the quantized data , partial derivative of the surface is taken in the x - and y - directions (( x , y , z ) is a cartesian coordinate system and the + z - direction denotes height ). the resultant vector of these two derivative values is found . in other words , the magnitude value of the surface gradient is obtained . for each point on the matrix , the magnitude ( 7 ) of the resultant of the partial derivatives taken in the x - and y - directions is quantized ( 8 ). a new matrix is formed and on this matrix , the magnitude value of the resultant of the surface derivatives calculated for each point on the shm corresponds to the same - coordinate element of a matrix to be used to find the center . three significant circles — primer circle ( 28 ), primer pocket gap circle ( 29 ) and cartridge case base circle ( 27 )— are expected to appear explicitly on this matrix . in other words , the values of the matrix elements of these circles are expected to be significantly high . the acquired matrix is subjected to smoothing and it is prepared for circle detection . the method called the 2 stage hough transform ( 21ht ) method ( 10 ), referred to in “ h . k . yuen , j . princen , j . illingworth and j . kittler , “ comparative study of hough transform methods for circle finding ”, image and vision computing , vol . 8 , no . 1 , pp . 71 - 77 , 1990 ”, is used for circle detection . the hough transform method was described by p . v . c . hough in p . v . c . hough , “ method and means for recognizing complex patterns ”, u . s . pat . no . 3 , 069 , 654 , 1962 . the parameter space for circle detection was proposed in r . o . duda and p . e . hart , “ use of the hough transformation to detect lines and curves in pictures ”, communications of the acm , vol . 15 , no . 1 , pp . 11 - 15 , january 1972 . in another source ( d . h . ballard , “ generalizing the hough transform to detect arbitrary shapes ”, pattern recognition , vol . 13 , no . 2 , pp . 111 - 122 , 1981 ), detection of certain analytical figures in grayscale pictures by hough transformation was described . one of these analytical figures is the circle . several methods that use hough transformation for circle detection are compared in h . k . yuen , j . princen , j . illingworth and j . kittler , “ comparative study of hough transform methods for circle finding ”, image and vision computing , vol . 8 , no . 1 , pp . 71 - 77 , 1990 . parameter information on the realization of the 21ht method is given under the title “ houghcircles ” in “ cv reference manual ” in opencv ( open source computer vision ) software library ([ online ], date of access : 28 . 11 . 2007 ). the circle detection process carried out using the hough transformation is as follows ( see : h . k . yuen , j . princen , j . illingworth and j . kittler , “ comparative study of hough transform methods for circle finding ”, image and vision computing , vol . 8 , no . 1 , pp . 71 - 77 , 1990 ): the equation of a circle with center ( a , b ) and radius r is as follows : in an image , any edge point ( x , y ) may be located on a circle . in order to understand whether a point is located on the circle , first , an operation is made in the hough space . the hough space consists of three parameters , a , b and r , for the circle . possible quantized values of these three parameters are determined . these values receive votes from the edge points on the image . circles are detected from among the circle parameters with the highest number of votes . in order to reduce the operational memory space and the processing time , the 21ht method divides the problem into two stages . first of all , the circle centers ( a , b ) are estimated in the 2 - dimensional parameter space . according to these centers , circles are sensed in 1 - dimensional parameter space ( r ). in this invention , the 21ht method ( 10 ) was used for the selection of the center of the cartridge case base ( 1 ). this is because the three circles — primer circle ( 28 ), primer pocket gap circle ( 29 ) and cartridge case base circle ( 27 )— located explicitly on the cartridge case base ( 1 ) are approximately concentric . thus , in the 2 - dimensional parameter space ( a , b ), the center of these circles are expected to receive the highest number of votes . as a consequence , the circle center receiving the highest number of votes can be accepted as the center of the cartridge case base ( 1 ) ( 11 ). another approach used to find the center is as follows : following the selection of the circle center receiving the highest number of votes , the circle centers that are not located at a certain distance from this circle center are not accepted as the circle center , although their parameters receive a high number of votes . since the caliber size is known , attention is paid to ensure that the cartridge case base ( 1 ) covers the image ( matrix ) as far as possible . in other words , the cartridge case base ( 1 ) fills almost the entire image . thus , among the circle centers detected , the one which is the closest to the image center may be accepted as the center of the cartridge case base ( 1 ). several circles may be detected by the 21ht method ( 10 ). the centers of these detected circles are ranked according to their distance to the center of the image . the circle center that is the closest to the center of the image may be accepted as the center of the cartridge case base ( 1 ) ( 11 ). first , the surface height matrix ( 5 ) is normalized ( 14 ) linearly in the interval [ 0 , 1 ]. on the basis of the detected center ( 12 ) by the method described above , this normalized surface height matrix is subjected to polar transformation ( 15 ). let the values of a point p located on the cartesian coordinate system be a and b respectively on the x - and y - axes . the values c and d , which are respectively the locations of point p on the r -( radius ) and q -( angle ) axes of the polar coordinates calculated according to a center c ( x c y c ), are found as follows : on the polar height matrix , for each radius value , all data corresponding to that single radius value are added and the mean value is calculated . thus , average height values are obtained on the basis of radius . a one - dimensional sign ( 16 ) is established with these mean values acquired on the basis of each radius value . this one - dimensional sign is called “ average height signal on the basis of radius ” ( ahsbr ). with the model - based signal similarity analysis ( 17 ) carried out on the ahsbr , the circles ( 18 )— primer circle ( 28 ), primer pocket gap circle ( 29 ) and cartridge case base circle ( 27 )— are detected . step function is used as a model . on the one - dimensional sign , the regions most appropriate for the step function are detected with the similarity analysis . the concave regions have lower values in the one - dimensional sign . this means , the regions outside the cartridge case base ( 1 ) and the primer pocket gap give lower values . again , similarly , on the primer ( 2 ) region , areas outside the firing pin mark ( 4 ) and the cartridge case base ( 1 ) give high values . the general outline of a representative ahsbr drawing is given in fig4 . first of all , the primer border ( 30 ) can be detected . for that purpose , the step model 1 ( 33 ) is used in an interval higher than a certain radius value ( r 1 ) and lower than a certain radius value ( r 2 ) to carry out a signal similarity analysis . in other words , while the ahsbr is kept fixed , the step model 1 ( 33 ) is wandered throughout this interval , superposed with the ahsbr , and the place of highest similarity is found . in this interval , the place of highest similarity is the primer border ( 30 ). then , the primer pocket gap border ( 31 ) can be detected . for that purpose , on the ahsbr , a signal similarity analysis is carried out with a step model 2 ( 34 ) used in an interval higher than the radius value of the primer border ( 30 ) and lower than a certain radius value ( r 3 ). in this interval , the place of highest similarity is the primer pocket gap border ( 31 ). finally , the cartridge case base border ( 32 ) can be detected . for that purpose , on the ahsbr , a signal similarity analysis is carried out with a step model 3 ( 35 ) used in an interval higher than the radius value of the primer pocket gap border ( 31 ) and lower than the highest radius value ( r 3 ). in this interval , the place of highest similarity is the cartridge case base border ( 32 ). it is not absolutely necessary to detect the circles in the way mentioned above ; yet , starting from a certain point and detecting the circles one by one may result in a faster process as it would narrow the interval in which the similarity computation is to be carried out . the intervals in which similarity computations are to be carried out may be determined according to the radii of the cartridge cases . for the signal similarity analysis ,— although the criteria are not limited to the ones described below — any of the criteria described below may be used . one of them is correlation analysis . further detailed basic information on correlation analysis can be found in “ pattern classification ” ( r . o . duda , p . e . hart , d . g . stork , pattern classification , 2nd ed ., a wiley - interscience publication , john wiley & amp ; sons , 2001 ) and “ discrete random signals and statistical signal processing ” ( c . w . therrien , discrete random signals and statistical signal processing , prentice hall , 1992 ). for two one - dimensional , separate signals s1 ( t ) and s2 ( t ), with variable t , the correlation analysis may be carried out as follows : let the length of the signs be u and the length of the region in which the correlation analysis is to be carried out be w . let the mean values of s1 ( t ) and s2 ( t ) be o s1 and o s2 , respectively . while signal s1 is kept fixed , signal s2 is shifted at an amount of t on plane t . cross correlation ( ci ): this is the cross correlation function of two signs . at point t , where the two signals are most similar with each other , the ci value is the highest . this is shown in the following formula : normalized cross correlation coefficient ( dik ): this is the normalized cross correlation coefficient of two images . at value t , where the two signals are most similar with each other , the dik value is the highest . this is shown in the following formula : for signal similarity analysis , the equations described below may also be used : mean square difference ( fko ): this is the mean of the square of the difference of two signals . at value t , where the two signs are the most similar with each other , the fko value is the lowest . this is shown in the following formula : mean absolute difference ( mfo ): this is the mean of the absolute differences of two signals . at value t , where the two signs are the most similar with each other , the mfo value is the lowest . this is shown in the following formula : drawings of step models are given in fig5 . the mathematical definitions of signals of step model 1 ( 33 ), step model 2 ( 34 ) and step model 3 ( 35 ) are as follows : step model 1 ( 33 ) signal ( bm1 ): let l1 & lt ; 0 , l2 & gt ; 0 , v1max ≦ 1 and v1min ≧ 0 . it is defined as follows . the function is defined in interval [ l1 , l2 ]. step model 2 ( 34 ) signal ( bm2 ): let l3 & lt ; 0 , l4 & gt ; 0 , v2max ≦ 1 and v2min ≧ 0 . it is defined as follows . the function is defined in interval [ l3 , l4 ]. step model 3 ( 35 ) signal ( bm3 ): let l5 & lt ; 0 , l6 & gt ; 0 , v3max ≦ 1 and v3min ≧ 0 . it is defined as follows . the function is defined in interval [ l5 , l6 ]. values v1max , v2max and v3max are either 1 or very close to 1 . values v1min , v2min and v3min are either 0 or very close to 0 . these values are values determined according to the linear normalization of the surface height matrix ( 5 ) in interval [ 0 , 1 ]. in the event that the surface height matrix attains a value in another interval , these values may change . there may be an error in detection of the circle center of the cartridge case base ( 1 ). in pixel coordinates , the circle center may be detected not accurately but within a neighborhood of a certain number of pixels . thus , improvement can be made on the detected center . for that purpose , a cost function is defined by using the signal similarity values — relevant similarity values of step model 1 ( 33 ), step model 2 ( 34 ), step model 3 ( 35 )) with ahsbr — acquired by the method within the circle detection module . effort is made to either increase this cost above or decrease it below a certain value . the issue of whether to increase or decrease depends on how the cost is defined . for example , if the cross correlation function is defined as the cost function , then effort is made to increase the cost value above a certain value . wandering in a neighborhood , the center of which is the center of the cartridge case base ( 1 ), it may be possible to find a more accurate circle center . however , this process increases the burden of calculation . the firing pin mark ( 4 ) region is accepted to be an increasingly deepening region in the primer ( 2 ) region . in order for the estimation of the firing pin mark ( 4 ), first , the surface height matrix of the primer ( 2 ) region , where the firing pin mark ( 4 ) is located , is extracted from the entire surface height matrix ( 5 ) by primer extraction ( 20 ). in this process , a circular region which is a bit smaller than the primer ( 2 ) radius is selected . this is because distortions on the outer borders of the primer ( 2 ) and possible errors in the detection of the primer ( 2 ) circle may result in errors in selection of the firing pin mark ( 4 ). the primer ( 2 ) region selected is quantized ( 21 ) and a histogram of this quantized data is obtained ( 22 ). if one accepts that , in the primer ( 2 ) region , the area outside the firing pin mark ( 4 ) is rather plane , then the histogram should have a peak value . a threshold which is smaller than the peak value is selected ( 23 ) and the threshold function ( 24 ) is applied . regions below the adaptively selected threshold value are accepted as the detected firing pin mark ( 25 ) region . in this detected firing pin mark ( 25 ) region , if there are empty areas that are not included in this region , these areas shall be included in the detected firing pin mark ( 25 ) region . there are certain letters and signs outside the primer ( 2 ) area on the cartridge case base ( 1 ). these signs are regions that should not be used in the comparison process . thus , these signs and letters should be detected in the first place and comparison of these regions should be made accordingly . for detection of these regions on the surface height matrix , certain clues are used . the surface slope values of the circumference of these letters and signs are very high . this means , the surface has a sharp proclivity of almost 90 degrees . thus , partial derivative of the surface taken in x - and y - directions may be used in detection of these regions . the resultant vector of these two derivative values is found . in other words , the magnitude of the surface gradient is obtained . for each point on the matrix , the magnitude ( 7 ) of the resultant of the surface derivatives is quantized ( 8 ). a new matrix is formed and on this matrix , the gradient magnitude value for each point corresponds to the same - coordinate element of a matrix to be used for sign and letter detection . on this matrix , regions that are above a certain threshold value are selected . in order to eliminate noise from among these selected regions , areas that are not bigger than a certain value are eliminated . then , sections up to a close neighborhood of these remaining areas are also added to them . thus the letter and sign regions are detected . another approach to be used in this work is as follows : a gradient magnitude matrix ( gmm ) is formed with the magnitude of the surface gradient at each point obtained by the method explained above . again , a gradient is applied on this matrix . a matrix is formed with the magnitude values of this gradient . a new matrix is formed and on this matrix , the gradient magnitude value for each point corresponds to the same - coordinate element of a matrix to be used for sign and letter detection . in order to eliminate noise from among these selected regions , areas that are not bigger than a certain value are eliminated . then , sections up to a close neighborhood of these remaining areas are also added to them . thus the letter and sign regions are detected . the following method can be used to calculate the gradient matrices of the surface . mathematically , we can denote shm by h ( j , i ). in the h ( j , i ), j denotes the value in the x - direction and i denotes the value in the y - direction on the cartesian coordinate system . the height value of the point ( j , i ) on the matrix , in other words , the value of the matrix at that point , is h ( j , i ). h ( j , i ) is a height function sampled in equal intervals . first of all , for each pixel , a second - degree polynomial ( p ( j , i )= a j 2 + bi 2 + c ji + d j + ei + f ), which covers the pixel and its surrounding pixels is fitted . while fitting the polynomial , around the pixel , a square area with a width of wr is taken into consideration . for the point n = wr * wr in the window , we can write the equations in matrix form as : in the equation above , there are n equations for 6 variables . the system of equations can be solved in the least squares sense . the difference of the expected height values and the values at the surface gives the error to be minimized . the solution which minimizes this error is : the part in the parentheses is the pseudo - inverse of y . thus , we find the surface parameters . computation of the gradient : the gradient can be computed from the surface parameters as follows ( see . bryan s . morse , brigham young university , “ lecture 11 : differential geometry ”, 2000 . source : online , date of last access : feb . 8 , 2008 ): the gradient is defined as follows : the direction of the gradient is the direction of the vector g , and it can be computed as follows : its magnitude , on the other hand , can be found as follows : | g |=√{ square root over ( l j 2 + l i 2 )}.