algorithm - How to compare two contours? (font comparison) -


i'm trying analyse 2 contours , give percent corresponding similarity. assuming have point's coordinates describing these contours (just svg path), based on factor should tell they're identical ?

after google searches, found related fourier descriptors, relevant case ?


edit

what want compare several fonts one. what font, not image. produced algorithm, possible find font equivalent according similarity percentage.

some scripts compare bounding box each letters, it's not enough. need way tell arial closest verdana webdings. assuming can extract contour fonts, need way compare 2 contours.

for example (with "logical" percent values):

font comparison, bold g closest

there 2 basic ways approach general problem (font matching): symbolic , statistical. solution combine both in way.

a symbolic approach uses knowledge of problem in direct way. example, can make list of things (as intelligent human) use characterise fonts. kind of questions identifont uses. approach means writing routines smart enough detect various properties (eg stroke width, whether loops closed, existence of serifs, etc) plus decision tree (or "rule engine") puts yes/no/unsure answers , comes answer.

the statistical approach sounds more thinking about, , how font works. here idea find general properties , use weights find "best" selection. example, if have lots of fonts can train neural net (input being pixels @ sample resolution). there don't need know "how" net decides - given enough training data find way so. or @ sum of dark pixels - give results similar percentages above.

this sounds simple, it's not easy find simple statistical measurements show differences in ways want.

so there's large middle ground between two. idea being if can pull in of ideas first group can make approaches in second more efficient. while simplest neural net approach "all in one" (it includes calculations , decisions) can separate out. instead of giving net bunch of pixels can give more "meaningful" inputs - things know detect between different fonts. things stroke width, or number of "holes" in character. can add smarts remove things might otherwise confuse results - example, pre-scaling same height (if have full font set can scale height of lowercase "m", say, constant).

fourier descriptors way of characterising "outside shape" of , used input statistical approach i've described above. in example give fourier descriptors pick "spikiness" of serifs in lower g, , indicate different g on left. care less stroke width , nothing @ scale (magnification/zoom) (which can or bad thing - if you're being given random letters of different sizes, don't want sensitive size, if you've normalized standard "m" entire alphabet want include that). since output spectrum can compare different letters cross-correlation of use pca categorize different types of letter.

other ideas 2d cross-correlation (the maximum of normalised correlation gives idea of how similar 2 things are) or seeing fraction of pixels common in both letters.

as comments say, huge problem (and not expert - above random bullshit being interested bystander).

but, answer question, if have outline, fourier descriptor place start. since focuses on shape rather "weight" combine total area enclosed outline. write code calculate , see numbers example alphabets. if seems distinguish letters, not others, other measurements in cases. end combining quite few approaches both fast , reliable.

alternatively, if want simple, try using easy-to-measure values height, width, total number of pixels "inside" contours, how many strokes cross along vertical or horizontal lines, etc. combining bunch of "good enough" purposes, if aren't comfortable maths involved in fourier transforms etc.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -