Giter Club home page Giter Club logo

rlsa's Introduction

RLSA

C implementation of RLSA for use in python.

Usage

Requirements

  • Python: 3.8+

Install

Install with:

pip install rlsa

Usage

The main function is rlsa.
It takes as input a black and white image (as a uint8 numpy array), and the hvs, vsv and (optionally) ahvs values. The function returns a new black and white image, leaving the original one intact.

You can also import the rlsa_horizontal and rlsa_vertical functions to apply only one of the RLSA components.

Usage example

A full example would be:

import cv2
from rlsa import rlsa

img = cv2.imread("assets/rlsa_test_image.jpg", cv2.IMREAD_GRAYSCALE)
_, binary_img = cv2.threshold(img, 190, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)

hsv = vsv = 25
out_img = rlsa(binary_img, hsv, vsv, hsv//10)

With a similar setup, the other functions can be used like this:

out_img = rlsa_horizontal(binary_img, hsv)
out_img = rlsa_vertical(binary_img, vsv)

Results

Input image After RLSA
Input Output
Horizontal only Vertical only
Horizontal Vertical

Included scripts

A few scripts are included in the tests folder. One is a python implementation of rlsa, serving as reference. The other two compare the result and speed of the implementations.
To run the those scripts, you need to install opencv.

Test

python -m tests.test assets/rlsa_test_image.jpg

Benchmark

python -m tests.benchmark assets/rlsa_test_image.jpg

--> C version is around 400 times faster than the naive python one.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.