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
- Host: GitHub
- URL: https://github.com/aaronjackson/torch-bwconncomp
- Owner: AaronJackson
- License: bsd-3-clause
- Created: 2019-01-17T15:03:27.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-23T15:48:52.000Z (about 5 years ago)
- Last Synced: 2025-02-14T23:56:06.544Z (about 1 year ago)
- Topics: components, connected, lua, torch, torch7
- Language: Lua
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE
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. :)