# Help needed to build a Shape Classifier

**URL:** https://discourse.processing.org/t/help-needed-to-build-a-shape-classifier/23341
**Category:** Processing.py
**Created:** [August 18, 2020, 6:19pm UTC](https://discourse.processing.org/t/help-needed-to-build-a-shape-classifier/23341 "2020-08-18T18:19:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![solub](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/solub/32/333_2.png) [@solub](https://discourse.processing.org/u/solub)
#### Post date: [August 18, 2020, 6:19pm UTC](https://discourse.processing.org/t/help-needed-to-build-a-shape-classifier/23341/1 "2020-08-18T18:19:13Z")

</div>

Dear all,

I am trying to implement [this paper](https://cis.temple.edu/%7Elatecki/Papers/IJPRAI08.pdf) (_Skeleton-based shape classification using path similarity_) in Processing but have difficulties understanding formulas **5** and **7** on page 7.

The goal is to find a shape (named “class”) whose topology is the closest to a query shape.

 ![Annotation 2020-08-05 150427](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/435def228bad472978216a02147e7f5346e31af2.png)

_In this example, the probability that the query shape belongs to class C should be the highest_

More specifically I am trying to calculate the “posterior probability” that a query shape belongs to a given class (formula 7)

**What I understand** : This “posterior probability” is based on “path similarity”, i.e how far/close the skeleton paths of the compared shapes (“query” and “class”) are.

- a _skeleton path_ (`sp`) is the route along the edges of the skeleton that starts at one vertex of the polygonal shape and ends at another one.

- the _distance_ is the difference between the respective radii of the `m` equidistant maximum disks along 2 different skeleton paths

 ![Annotation 2020-08-05 145244](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5f4a4fdab09475e8e3bc6bea7a99c92fb9d8ddaf.png)

**What I DO NOT understand** : Path comparison.

Do I need to compare each path of the query shape against each path of a class shape (nested ` for` loop) ?  
If not, what paths do I need to compare ?

Again, I believe understanding formula 7 is key to get this right

Here a snippet in Python mode showcasing the example displayed on the first picture (query shape vs A/B/C classes):

> **[trinket: run code anywhere](https://www.trinket.io/python/19970b1a66)**
>
> Python in the browser. No installation required.
