Commit Graph

22 Commits

Author SHA1 Message Date
Michal Romaniuk ee3ca829c6 Added a test for slic_zero and some other changes based on feedback from Github. 2014-01-26 18:01:59 +00:00
Michal Romaniuk 131dea07a0 Merged the separate loops for SLIC-zero and SLIC into one, and some minor improvements based on feedback on Github. 2014-01-21 20:08:07 +00:00
Guillem Palou Visa 4982b00f0c Labels start at 0, for backward compatibility
Code is PEP8 compliant
2013-12-24 18:45:55 +01:00
Guillem Palou Visa 64d945da71 fixing tests 2013-12-24 16:18:57 +01:00
Johannes Schönberger 4033566ae6 Add test for invalid parameter combination 2013-11-22 12:22:10 +01:00
Juan Nunez-Iglesias 846765e5f9 Add spacing support for new, speeded-up SLIC 2013-09-16 17:52:25 +10:00
Juan Nunez-Iglesias 610a0d1793 Add support for list sigma input in SLIC
Previously, having a different `sigma` for different dimensions
required an array input. This allows the user to use a simple list,
which gets converted to an array internally.

Importantly, it removes a very unhelpful error:

```python
>>> im = np.random.rand(10, 20)
>>> from skimage import segmentation as seg
Exception AttributeError: "'UmfpackContext' object has no attribute '_symbolic'" in <bound method UmfpackContext.__del__ of <scipy.sparse.linalg.dsolve.umfpack.umfpack.UmfpackContext object at 0x1045ff5d0>> ignored

>>> s = seg.slic(im, 2, sigma=[2, 1])
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-689b36a2f0ef> in <module>()
----> 1 s = seg.slic(im, 2, sigma=[2, 1])

/Users/nuneziglesiasj/venv/skimdev2/lib/python2.7/site-packages/scikit_image-0.9dev-py2.7-macosx-10.5-x86_64.egg/skimage/segmentation/slic_superpixels.pyc in slic(image, n_segments, compactness, max_iter, sigma, multichannel, convert2lab, ratio)
    106     if not isinstance(sigma, coll.Iterable):
    107         sigma = np.array([sigma, sigma, sigma])
--> 108     if (sigma > 0).any():
    109         sigma = list(sigma) + [0]
    110         image = ndimage.gaussian_filter(image, sigma)

AttributeError: 'bool' object has no attribute 'any'
```
2013-09-16 17:49:07 +10:00
Juan Nunez-Iglesias ea1566fffb Fix image dimension sanitizing at function start
`np.atleast_3d` will add a singleton dimension at the end of an array
if needed. This is not the correct thing to do if `multichannel=False`
based on the subsequent lines. If the input image was 2D with shape
`(40, 50)` and `multichannel=False`, then `np.atleast_3d` gives it
shape `(40, 50, 1)`, and then, because `multichannel=False`, the rest
of the code gives it shape `(40, 50, 1, 1)`. This results in the final
returned array having shape `(40, 50, 1)` instead of the desired
`(40, 50)`.

This commit fixes that and updates the test to detect this failure.
2013-09-16 16:02:24 +10:00
Johannes Schönberger eeddd9e35f Revert multichannel magic and improve parameter docs 2013-09-01 16:46:01 +02:00
Johannes Schönberger fd729a4e30 Improve SLIC 2013-09-01 16:46:00 +02:00
Juan Nunez-Iglesias 72833f1729 Do not use 'ratio' in test_slic.py either 2013-07-29 00:30:51 +10:00
Juan Nunez-Iglesias 878c562a45 Replace 'ratio' kwarg with 'compactness' in SLIC 2013-07-29 00:28:38 +10:00
Juan Nunez-Iglesias cba821d5e3 Suppress warning of ambiguous array dim in test 2013-07-02 13:22:14 +02:00
Juan Nunez-Iglesias 5c4d0218ce bug fix: 3d test working 2013-07-02 13:22:13 +02:00
Juan Nunez-Iglesias 215439b43c Add 3D slic tests (gray not working yet) 2013-07-02 13:22:13 +02:00
Juan Nunez-Iglesias 57cc86d7c8 Bug fix: remove unnecessary __get__ in test_slic 2013-07-02 13:22:13 +02:00
Juan Nunez-Iglesias 6dc8e6300b Separate inner loop of SLIC computation 2013-07-02 13:22:12 +02:00
Juan Nunez-Iglesias a2e32cc90c Add initial 3D modifications (not working) 2013-07-02 13:21:17 +02:00
Johannes Schönberger 983cb76319 Remove print statement 2013-02-22 17:05:39 +01:00
Juan Nunez-Iglesias 35e8ad2ccc Allow grayscale input images to SLIC segmentation
There is no reason for SLIC to be restricted to colour/RGB images. I
have added a few lines that allow single-channel input.
2012-12-17 16:45:23 +11:00
Andreas Mueller 73dd46019b FIX width/height trouble, add non-regression test 2012-08-05 21:06:37 +01:00
Andreas Mueller 8098718036 Fixup tests, add test for slic. 2012-08-05 14:33:30 +01:00