Answers.Body: <p>I think one approach you can try to segment the digits and Connected Components Labeling (<a href="https://en.wikipedia.org/wiki/Connected-component_labeling" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Connected-component_labeling</a>).
  With it, you'll end up with a label for each letter and then you can try to find the convex hull of the letter.
  After that, just crop a square for each convex hull and input it to your CNN.
  Notice that it will only if there is at least one pixel between the letters...</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-17T11:57:00.947Z
Answers.Text: @Júlio César Batista Isn't that just looping over `contours` in OpenCV and removing them. Just this time, I have some labels thanks to the CCL. I really don't think it should work. What if there is some other element in front of that string, and It is big enough so that I can't close it with `dilation` or `erodion` without removing the parts that I care about.
Answers.UserDisplayName: Igor 
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-17T11:38:49.787Z
Answers.LastActivityDate: 2018-12-17T11:38:49.787Z
Answers.UserDisplayName: ejuliobatista
Answers.Body: <p>Use of CNNs to recognize digits is a reasonable approach as of this answer's writing, the effectiveness of which can be enhanced via <a href="https://link.springer.com/chapter/10.1007%2F11503415_1" rel="nofollow noreferrer"><em>Sensitive Error Correcting Output Codes</em></a>, (2005, John Langford, Alina Beygelzimer) according to Shuo Yang et. al. in <a href="https://www.aaai.org/ocs/index.php/AAAI/AAAI15/paper/viewFile/9773/9821" rel="nofollow noreferrer"><em>Deep Representation Learning with Target Coding</em></a>.</p>
  
  <p>Given a sufficient CNN depth, it can be trained to recognize the digits with the field name and underscore intact. Automatically removing them would generally only be possible after they are recognized using the CNN approach anyway.</p>
  
  <p>Isolating the digits from the field name and the underscore would be accomplished via the same approach used to isolate the digits from one another. There is no reason to perform these two conceptual tasks in series and consume additional development time and resources, when a single deep CNN can locate the digits and dismiss the field name and underscore. This is similar to animal vision. A mosquito's visual pathway distinguishes an oncoming object from the background to avoid a swat using the same network it uses to recognize the object.</p>
  
  <p>What would be helpful would be to normalize the input by finding a two dimensional plateau (much like a geological one) representing the distribution of black pixels in horizontal and vertical dimensions. Summing rows and columns of pixels and using a heuristic algorithm to find a rectangle outside of which there is only noise may be sufficient. Then trim and scale, which removes redundancy and may improve CNN training speed, accuracy, and/or reliability by distributing the image more widely over the input layer and likely reducing the layer count by at least one.</p>
  
  <p>Another approach is to use overall features of the form in which the field resides to rotate, position, and scale the image so that the field name and underscore is within a fraction of a pixel from an expected location on the form. In this case training a separate CNN is less redundant and has a higher return on development investment. In such a design, the field name and underscore can be removed by subtraction, however this may disturb field value recognition because the handwriting may overlap items blanked. It will require experimentation to determine the accuracy and reliability hit (diminution) from such disturbance.</p>
  
  <p><strong>Addendum in Response to Comment</strong></p>
  
  <p>For the first approach, a Field Name and Underscore Superimposer will need to be designed and implemented to transform the training example set features, the pixel arrays, but preserve the labels corresponding to each example. The hyper-parameter values that work best without the superimposition may need modification to work best with it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-08T11:34:22.510Z
Answers.Text: What would be your preferred way of solving the problem. I'm interested in your first approach. So, if I build network big enough it could understand field name and underscore like some kind of a constant, that would not impact on the result? In general one bounding box that will hold filed name, underscore and number in one scale and normalize that as input and use it for training. I'm not sure in this approach would it ask for more training examples and what else would change? But it sounds great. By the way, `labels` would still be only exact number values?
Answers.UserDisplayName: Igor 
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-08T12:25:50.367Z
Answers.Text: I guess that by `Field Name and Underscore Superimposer will need to be designed and implemented to transform the training example set features, the pixel arrays, but preserve the labels` you really mean: the data set will have different features because images would include a Field Name and Underscore Superimposer but labels would stay the same of course. On the other hand, the new feature of data set would not have such a great impact on the hyper-parameters because basically, every picture would have the same new feature.
Answers.UserDisplayName: Igor 
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-08T12:25:59.823Z
Answers.Text: Also if a model is trained on 28x28 image, wouldn't that approach maybe had its pitfalls as scaling to 28x28 would make the image more unreadable. The dimensions would need to go up?
Answers.UserDisplayName: Igor 
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-27T18:51:09.460Z
Answers.LastActivityDate: 2019-01-08T12:02:00.553Z
Answers.LastEditDate: 2019-01-08T12:02:00.553Z
Answers.UserDisplayName: Douglas Daseeco
Body: <p>I have multiple pictures that look exactly like the one below this text. I'm trying to train <code>CNN</code> to read the digits for me. Problem is isolating the digits. They could be written in any shape, way, and position that person who is writing them wanted to. I thought of maybe training another <code>CNN</code> to recognize the position/location of the digits, but I'm not sure how to approach the problem. But, I need to get rid of that string and underline. Any clue would be a great one. Btw. I would love to get the 28x28 format just like the one in <code>MNIST</code>.</p>
  
  <p>Thanks up front.</p>
  
  <p><a href="https://i.sstatic.net/wOMma.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wOMma.jpg" alt="enter image description here"></a></p>
  
Tags: <convolutional-neural-networks><image-recognition><computer-vision><handwritten-characters>
Title: How to approach this handwritten digit recognition?
UserDisplayName: Igor 
ThreadText: # How to approach this handwritten digit recognition?
  
  (Asked by: username_0 on 2018-12-16)
  
  I have multiple pictures that look exactly like the one below this text. I'm trying to train `CNN` to read the digits for me. Problem is isolating the digits. They could be written in any shape, way, and position that person who is writing them wanted to. I thought of maybe training another `CNN` to recognize the position/location of the digits, but I'm not sure how to approach the problem. But, I need to get rid of that string and underline. Any clue would be a great one. Btw. I would love to get the 28x28 format just like the one in `MNIST`.
  
  Thanks up front.
  
  [![enter image description here](https://i.sstatic.net/wOMma.jpg)](https://i.sstatic.net/wOMma.jpg)
  
  **Tags:** convolutional-neural-networks, image-recognition, computer-vision, handwritten-characters
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-12-17. Score: 1
  
  I think one approach you can try to segment the digits and Connected Components Labeling (<https://en.wikipedia.org/wiki/Connected-component_labeling>).
  With it, you'll end up with a label for each letter and then you can try to find the convex hull of the letter.
  After that, just crop a square for each convex hull and input it to your CNN.
  Notice that it will only if there is at least one pixel between the letters...
  
  > **Comments:**
  > **username_0**: @Júlio César Batista Isn't that just looping over `contours` in OpenCV and removing them. Just this time, I have some labels thanks to the CCL. I really don't think it should work. What if there is some other element in front of that string, and It is big enough so that I can't close it with `dilation` or `erodion` without removing the parts that I care about.  
  
  ---
  
  ### Answer by username_2 on 2018-12-27. Score: 0
  
  Use of CNNs to recognize digits is a reasonable approach as of this answer's writing, the effectiveness of which can be enhanced via [*Sensitive Error Correcting Output Codes*](https://link.springer.com/chapter/10.1007%2F11503415_1), (2005, John Langford, Alina Beygelzimer) according to Shuo Yang et. al. in [*Deep Representation Learning with Target Coding*](https://www.aaai.org/ocs/index.php/AAAI/AAAI15/paper/viewFile/9773/9821).
  
  Given a sufficient CNN depth, it can be trained to recognize the digits with the field name and underscore intact. Automatically removing them would generally only be possible after they are recognized using the CNN approach anyway.
  
  Isolating the digits from the field name and the underscore would be accomplished via the same approach used to isolate the digits from one another. There is no reason to perform these two conceptual tasks in series and consume additional development time and resources, when a single deep CNN can locate the digits and dismiss the field name and underscore. This is similar to animal vision. A mosquito's visual pathway distinguishes an oncoming object from the background to avoid a swat using the same network it uses to recognize the object.
  
  What would be helpful would be to normalize the input by finding a two dimensional plateau (much like a geological one) representing the distribution of black pixels in horizontal and vertical dimensions. Summing rows and columns of pixels and using a heuristic algorithm to find a rectangle outside of which there is only noise may be sufficient. Then trim and scale, which removes redundancy and may improve CNN training speed, accuracy, and/or reliability by distributing the image more widely over the input layer and likely reducing the layer count by at least one.
  
  Another approach is to use overall features of the form in which the field resides to rotate, position, and scale the image so that the field name and underscore is within a fraction of a pixel from an expected location on the form. In this case training a separate CNN is less redundant and has a higher return on development investment. In such a design, the field name and underscore can be removed by subtraction, however this may disturb field value recognition because the handwriting may overlap items blanked. It will require experimentation to determine the accuracy and reliability hit (diminution) from such disturbance.
  
  **Addendum in Response to Comment**
  
  For the first approach, a Field Name and Underscore Superimposer will need to be designed and implemented to transform the training example set features, the pixel arrays, but preserve the labels corresponding to each example. The hyper-parameter values that work best without the superimposition may need modification to work best with it.
  
  > **Comments:**
  > **username_0**: What would be your preferred way of solving the problem. I'm interested in your first approach. So, if I build network big enough it could understand field name and underscore like some kind of a constant, that would not impact on the result? In general one bounding box that will hold filed name, underscore and number in one scale and normalize that as input and use it for training. I'm not sure in this approach would it ask for more training examples and what else would change? But it sounds great. By the way, `labels` would still be only exact number values?  
  > **username_0**: I guess that by `Field Name and Underscore Superimposer will need to be designed and implemented to transform the training example set features, the pixel arrays, but preserve the labels` you really mean: the data set will have different features because images would include a Field Name and Underscore Superimposer but labels would stay the same of course. On the other hand, the new feature of data set would not have such a great impact on the hyper-parameters because basically, every picture would have the same new feature.  
  > **username_0**: Also if a model is trained on 28x28 image, wouldn't that approach maybe had its pitfalls as scaling to 28x28 would make the image more unreadable. The dimensions would need to go up?  
  
  ---
  
  