An open API service indexing awesome lists of open source software.

https://github.com/aaronjackson/torch-bwconncomp

:cyclone: Detects and labels connected components in binary images via Torch7 / Lua
https://github.com/aaronjackson/torch-bwconncomp

components connected lua torch torch7

Last synced: 5 months ago
JSON representation

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

Awesome Lists containing this project

README

          

* 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

#+BEGIN_SRC
$ git clone https://github.com/AaronJackson/torch-bwconncomp.git bwconncomp
#+END_SRC

** Example Usage

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

#+BEGIN_SRC
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>
#+END_SRC

Just a quick hack for work. :)