Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create data fom image like "Letter Image Recognition Dataset" from UCI

Tags:

c++

opencv

I am using letter_regcog example from OpenCV, it used dataset from UCI which have structure like this:

Attribute Information:
     1. lettr   capital letter  (26 values from A to Z)
     2. x-box   horizontal position of box  (integer)
     3. y-box   vertical position of box    (integer)
     4. width   width of box            (integer)
     5. high    height of box           (integer)
     6. onpix   total # on pixels       (integer)
     7. x-bar   mean x of on pixels in box  (integer)
     8. y-bar   mean y of on pixels in box  (integer)
     9. x2bar   mean x variance         (integer)
    10. y2bar   mean y variance         (integer)
    11. xybar   mean x y correlation        (integer)
    12. x2ybr   mean of x * x * y       (integer)
    13. xy2br   mean of x * y * y       (integer)
    14. x-ege   mean edge count left to right   (integer)
    15. xegvy   correlation of x-ege with y (integer)
    16. y-ege   mean edge count bottom to top   (integer)
    17. yegvx   correlation of y-ege with x (integer)

example:

T,2,8,3,5,1,8,13,0,6,6,10,8,0,8,0,8
I,5,12,3,7,2,10,5,5,4,13,3,9,2,8,4,10

now I have segmented image of letter and want to transform it into data like this to put recognize it but I don't understand the mean of all value like "6. onpix total # on pixels" what is it mean ? Can you please explain the mean of these value. thanks.

like image 346
Nhu Phuong Avatar asked Aug 13 '09 08:08

Nhu Phuong


1 Answers

I am not familiar with OpenCV's letter_recog example, but this appears to be a feature vector, or set of statistics about the image of a letter that is used to classify the future occurrences of the letter. The results of your segmentation should leave you with a binary mask with 1's on the letter and 0's everywhere else. onpix is simply the total count of pixels that fall on the letter, or in other words, the sum of your binary mask.

Most of the rest values in the list need to be calculated based on the set of pixels with a value of 1 in your binary mask. x and y are just the position of the pixel. For instance, x-bar is just the sample mean of all of the x positions of all pixels that have a 1 in the mask. You should be able to easily find references on the web for mathematical definitions of mean, variance, covariance and correlation.

14-17 are a little different since they are based on edge pixels, but the calculations should be similar, just over a different set of pixels.

like image 5
Jason B Avatar answered Oct 20 '22 20:10

Jason B