title: Extraction of contour positions and orientations of an image
body: <p>I'm basically following a paper, " Using a statistical language model to improve the performance of an HMM-based cursive handwriting recognition system".</p>
  
  <p>Here the author has extracted a vector of 9 features from each sliding window. quoting the paper:</p>
  
  <blockquote>
    <p>The first three features are the weight of the window, its centre of
    gravity and the second order moment of the window.</p>
    
    <p>Features four and five define the position of the upper and lower
    contour in the window, features six and seven give the orientation of
    the upper and lower contour by the gradient of the contour at the
    windows position, feature eight gives the number of black to white
    transitions in vertical direction, while feature nine gives the number
    of black pixels between the upper and lower contour.</p>
  </blockquote>
  
  <p>I managed to calculate the first three features the paper is talking about, but I seem to have trouble understanding the features 4,5,6,7,8.</p>
  
  <p>I can calculate the contour of an image. Suppose, this is a window of one of the text lines(windows is of length 14 pixels, as suggested by paper):</p>
  
  <p><img src="https://i.stack.imgur.com/n7Fa6.jpg" alt="enter image description here"></p>
  
  <p>And this is the extracted contour of the image:</p>
  
  <p><img src="https://i.stack.imgur.com/JvPTS.jpg" alt="enter image description here"></p>
  
  <p>So what exactly is the upper and lower contour here? from where can I consider the limits, if it refers to the top and bottom pixels then I could have extracted those without contour extraction? Similarly the orientation of these contours is equally confusing.</p>
  
  <p>I would really appreciate some guidance here.</p>