# Arc Adjacency Matrix Based Detector

This folder contains the implementation of the arc adjacency matrix based detector according to my understanding of the
[original article](https://ieeexplore.ieee.org/document/8972900).

## Usage
Enter the build folder and run build.sh bash script or run: cmake .. && make (if using the provided docker file this step can be skipped).
The build folder contains a simple run.sh script with prefilled parameters and their
recommended ranges. The detector requires 7 arguments followed by paths to the images.
```bash
#!/bin/bash

LC_NUMERIC=de_DE.UTF-8

                    #Parameters    defVal      Range    
Ta=1.05             #theta_arc     1.05        <0.5,1.4>    parameter used in convexity testing
La=3.4              #lambda_arc    3.4         <2,5>        parameter used in convexity testing
Tr=0.8              #threshold     0.8         <0.45,85>    ellipses with Pscore > treshold are kept
sig=1.414           #sigma         1.414       <0,5>        parameter sigma used with Gaussian blur
scale=0.8           #scale         0.8         <0.3,1.0>    scales down image as images with lower scales may have more accurate ressults
show=0              #show          0           {0, 1}       displays image with detected ellipses if set to 1
# DISCLAIMER! the parameter show should always be set to 0
# if used with the provided dockerfile
out="../../extracted/AAMBED/" #outpit file path


./Arc_matrix ${Ta} ${La} ${Tr} ${sig} ${scale} ${show} ${out} $@
```

the detector then can be used by running the script with the path to the images,
as an example the images in the test_images folder are used.
```bash
./run.sh ../../test_images/*
```

## Examples

Running the program with the following arguments on test_images/sint.png .
```
                    #Parameters    defVal     Range    
Ta=1.05             #theta_arc     1.05        <0.5,1.4>
La=3.4              #lambda_arc    3.4         <2,5>
Tr=0.8              #threshold     0.8         <0.45,85>
sig=1.414           #sigma         1.414       <0,5>
scale=0.8           #scale         0.8         <0.3,1.0>
```
![extraction on sint.jpg with the parameters above](examples/sint-ellipses.png)


Running the program with the following arguments on test_images/sint.png .
```
                    #Parameters     defVal      Range    
Ta=1.05             # theta_arc     1.05        <0.5,1.4>
La=3.4              # lambda_arc    3.4         <2,5>
Tr=0.75             # threshold     0.8         <0.45,85>
sig=1.414           # sigma         1.414       <0,5>
scale=0.4           # scale         0.8         <0.3,1.0>
```
![extraction on test2.jpg with the parameters above](examples/test-color.png)

Running the program with the following arguments on tests_images/logs.jpg .
```
                    #Parameters     defVal      Range    
Ta=1.05             # theta_arc     1.05        <0.5,1.4>
La=3.4              # lambda_arc    3.4         <2,5>
Tr=0.75             # threshold     0.8         <0.45,85>
sig=1.414           # sigma         1.414       <0,5>
scale=0.5           # scale         0.8         <0.3,1.0>
```
![extraction on logs.jpg with the parameters above](examples/logs.jpg)


Running the program with the following arguments on test_images/Brown-eggs.jpg .
```
                    #Parameters     defVal      Range    
Ta=1.05             # theta_arc     1.05        <0.5,1.4>
La=3.4              # lambda_arc    3.4         <2,5>
Tr=0.75             # threshold     0.8         <0.45,85>
sig=1.414           # sigma         1.414       <0,5>
scale=0.8           # scale         0.8         <0.3,1.0>
```

![extraction on Brown-eggs.jpg with the parameters above](examples/Brown-eggs.jpg)
