Skip to content

Commit

Permalink
docs: minor fixes in code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
EscapedGibbon committed Feb 9, 2024
1 parent 2ab9952 commit 18f6eb8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/Tutorials/ROI analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ For the tutorial's sake let's take a more trivial example. Here we have a bunch
![Screws and bolts](./images/roiAnalysis/good.jpg)

What sets nuts and washers apart from other elements is the fact that they have holes in them. In this case we can use `fillRatio` property which gives a ratio of ROIs surfaces with and without holes. We will also be applying `holesInfo()` method to see the information about how many holes a region possesses.
Finally we will also take their form factor into account and use `roundness` property. Roundness quantifies the deviation of an object's shape from a perfect circle. So, if the roundness of the perfect circle is 1, we will use 0.6 as a measure for our regions.
Finally we will also take their form factor into account and use `roundness` property. Roundness quantifies the deviation of an object's shape from a perfect circle. So, if the roundness of the perfect circle is 1, we will use 0.55 as a measure for our regions.

It is reasonable to assume that you don't know exactly what is the exact roundness coefficient or fill ratio of a washer, so you will eyeball it to see if your guess is close enough or not.
To visualize it better you can use `paintMask()` method to paint a mask of a region of interest on the image.
Expand All @@ -137,7 +137,7 @@ const washersAndNuts = [];
for (const roi of rois) {
if (
roi.holesInfo().number >= 1 &&
roi.roundness > 0.6 &&
roi.roundness > 0.55 &&
roi.fillRatio() < 0.9
) {
//paintMask allows painting regions of interest on our
Expand Down Expand Up @@ -209,7 +209,11 @@ const washersAndNuts = [];
//Part where elements get picked apart from
//bolts and screws.
for (const roi of rois) {
if (roi.holesInfo.number >= 1 && roi.roundness > 0.6) {
if (
roi.holesInfo.number >= 1 &&
roi.roundness > 0.55 &&
roi.fillRatio() < 0.9
) {
console.log(roi.id, roi.roundness, roi.mbr.aspectRatio);
image = image.paintMask(roi.getMask(), {
origin: { column: roi.origin.column, row: roi.origin.row },
Expand Down

0 comments on commit 18f6eb8

Please sign in to comment.