Skip to content

🌀 Detects and labels connected components in binary images via Torch7 / Lua

License

Notifications You must be signed in to change notification settings

AaronJackson/torch-bwconncomp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

torch-bwconncomp

Used to detect connected groups of pixels in a black and white image.

  • bwconncomp.label - Labels the connected components
  • bwconncomp.centroids - Identifies the centres (mean of pixels) of the labelled components.

Download

$ git clone https://github.com/AaronJackson/torch-bwconncomp.git bwconncomp

Example Usage

Below we create a small 8x8 Tensor and use bwconncomp to label the connected groups of one:

th> bwconncomp = require('bwconncomp')
                                                                      [0.0007s]
th> Z = torch.rand(8,8):gt(0.8)
                                                                      [0.0001s]
th> Z
 0  0  0  0  0  1  0  0
 1  0  1  1  1  0  0  0
 0  0  0  0  1  0  0  1
 0  0  0  0  1  0  0  0
 0  1  0  0  0  0  1  1
 1  0  0  0  0  1  0  0
 0  0  0  1  1  0  0  0
 1  0  0  0  0  0  0  1
[torch.ByteTensor of size 8x8]

                                                                      [0.0031s]
th> bwconncomp.label(Z)
  0   0   0   0   0   1   0   0
  2   0   3   3   3   0   0   0
  0   0   0   0   3   0   0   4
  0   0   0   0   3   0   0   0
  0   5   0   0   0   0   6   7
  8   0   0   0   0   9   0   0
  0   0   0  10  10   0   0   0
 11   0   0   0   0   0   0  12
[torch.IntTensor of size 8x8]

                                                                      [0.0033s]
th>

Just a quick hack for work. :)

About

🌀 Detects and labels connected components in binary images via Torch7 / Lua

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages