Skip to main content

Python Library for Stroke Width Transform

Project description

SWTloc : Stroke Width Transform Text Localizer

Description

This repo contains a python implementation structured as a python package pertaining to the text localization method as in a natural image as outlayed in the Research Paper :-

Detecting Text in Natural Scenes with Stroke Width Transform. Boris Epshtein, Eyal Ofek & Yonatan Wexler (June, 2010)

Installation


Installation

pip install swtloc

Usage


  • Stroke Width Transform

    This function applies Stroke Width Transform on a list of images or a single image, and once done with the transformation the results are stored in the directory mentioned save_rootpath under the name of the image being processed (Process images with different names)

    from swtloc import SWTLocalizer
    
    swtl = SWTLocalizer()
    imgpaths = ... # Image paths, can be one image or more than one
    swtl.swttransform(imgpaths=imgpath, save_results=True, save_rootpath='swtres/',
                      edge_func = 'ac', ac_sigma = 1.0, text_mode = 'wb_bf',
                      gs_blurr=True, blurr_kernel = (5,5), minrsw = 3, 
                      maxCC_comppx = 10000, maxrsw = 200, max_angledev = np.pi/6, 
                      acceptCC_aspectratio = 5)
    

  • Individual & Grouped Bounding Boxes and Annotations

    These group of functions returns bounding boxes to individual components and grouped bounding boxes of words.

    • Minimum CC Bounding Boxes

      Generate Minimum Bounding box for each of the Connected Components after applying SWT, can be a rotated rectangle.

      min_bboxes, min_bbox_annotated = swtl.get_min_bbox(show=True, padding=10)
      
    • Extreme CC Bounding Boxes

      Generate External Bounding box for each of the Connected Components after applying SWT.

      min_bboxes, min_bbox_annotated = swtl.get_extreme_bbox(show=True, padding=10)
      
    • CC Outline

      Generate Outline of each of the Connected Components after applying SWT.

      comp_outlines, comp_outline_annot = swtl.get_comp_outline(show=True, padding=10)
      
    • CC Bubble Bounding Boxes

      Generate Bubble Bounding box for the grouped letters into a word.

      respacket = swtl.get_grouped(lookup_radii_multiplier=1, sw_ratio=2,
                           cl_deviat=[13,13,13], ht_ratio=2, 
                           ar_ratio=3, ang_deviat=30)
      
      grouped_labels = respacket[0]
      grouped_bubblebbox = respacket[1]
      grouped_annot_bubble = respacket[2]
      grouped_annot = respacket[3]
      maskviz = respacket[4]
      maskcomb  = respacket[5]
      

    *CC = Connected Component

Documentation


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swtloc-1.0.0.0.tar.gz (17.3 kB view hashes)

Uploaded Source

Built Distribution

swtloc-1.0.0.0-py3-none-any.whl (17.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page