Metadata-Version: 2.1
Name: adaptive-boxes
Version: 0.0.4
Summary: Python package for rectangular decomposition of 2D scenes/binary images
Home-page: https://github.com/jnfran92/adaptive-boxes
Author: Juan Francisco Chango
Author-email: jnfran92@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: certifi (==2019.3.9)
Requires-Dist: cycler (==0.10.0)
Requires-Dist: kiwisolver (==1.1.0)
Requires-Dist: matplotlib (==3.1.1)
Requires-Dist: numpy (==1.17.1)
Requires-Dist: pandas (==0.25.1)
Requires-Dist: plyfile (==0.7)
Requires-Dist: pyparsing (==2.4.2)
Requires-Dist: python-dateutil (==2.8.0)
Requires-Dist: pytz (==2019.2)
Requires-Dist: scipy (==1.3.1)
Requires-Dist: six (==1.12.0)

# Adaptive-Boxes
Python Library for rectangular decomposition of 2D binary images.

<img src="./hires_images/intro_image.png" alt="sample1">

See the CUDA GPU version: <a href="https://github.com/jnfran92/adaptive-boxes-gpu">adaptive-boxes-gpu</a>

## Quick Start

Install `adabox` from PiP:

    pip install adaptive-boxes


Call **adaptive-boxes** library

    from adabox import proc
    from adabox.plot_tools import plot_rectangles, plot_rectangles_only_lines

Call others too:

    import numpy as np
    import matplotlib.pyplot as plt

Load data in `.csv` format. File should contain data with columns: `[x1_position x2_position flag]`. 
Initially, `flag = 0` (See `sample_data` folder).


    # Input Path
    in_path = './sample_data/sample_2.csv'

    # Load Demo data with columns [x_position y_position flag]
    data_2d = np.loadtxt(in_path, delimiter=",")


If you want to see data, plot using:

    # Plot demo data
    plt.scatter(data_2d[:, 0], data_2d[:, 1])
    plt.axis('scaled')    

Decompose data in rectangles, it returns a list of rectangles and a separation value needed to plot them.

    rectangles = []
    # Number of random searches, more is better!
    searches = 2        
    (rectangles, sep_value) = proc.decompose(data_2d, searches)
    print('Number of rectangles found: ' + str(len(rectangles)))   


Plot resulting rectangles

    plot_rectangles(rectangles, sep_value)

or 

    plot_rectangles_only_lines(rectangles, sep_value) 


## Output

`Adabox` applied over: `./sample_data/` files. Click in the images to expand.

### Hi-res images

#### File: `sample_1.csv`

<img src="./hires_images/sample_1.jpg" alt="sample1">

#### File: `sample_2.csv`

<img src="./hires_images/sample_2.jpg" alt="sample2">

## Repo Content

Each folder contains the next information:

- data: Files with voxel information in Blender (`.ply` extension)
- proto: Prototype scripts
- results: Results of the heuristic process (`.json` extension)
- lib: library scripts

## More info



