Commit Graph

50 Commits

Author SHA1 Message Date
Johannes Schönberger 615866ae16 Cast label_field to integer dtype for float intput 2013-11-09 21:56:18 +01:00
Andreas Mueller 57e37352cb FIX add missing min_size parameter, add regression test. 2013-10-20 15:15:36 -07:00
Josh Warner (Mac) f25ca3a835 ENH: spacing kwarg for random_walker and improved tests 2013-10-13 12:39:13 -05:00
Josh Warner (Mac) e5e1918a2b REBASE: Resolve first conflict 2013-10-13 12:38:35 -05:00
Juan Nunez-Iglesias bfab493133 Add new tests for relabel_sequential 2013-10-03 16:11:52 +10: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
Josh Warner (Mac) e3c3a69560 add assertion checks to ensure data shape is unchanged 2013-04-14 20:16:18 -05:00
Josh Warner (Mac) f1ef7d5da2 PEP8 fixes; remove unneeded pyamg import; add data shape check 2013-04-11 14:02:10 -05:00
Johannes Schönberger 983cb76319 Remove print statement 2013-02-22 17:05:39 +01:00
Stefan van der Walt 18aef47100 Merge pull request #395 from jni/jni-slic-bw
ENH: Allow grayscale input images to SLIC segmentation.
2012-12-22 11:42:19 -08:00
Tony S Yu 7c0424fd83 Merge pull request #378 from sergeyk/master
Fixed RGB<->XYZ conversion (was incorrect before).
2012-12-18 07:57:06 -08: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 b5d1e9f209 FIX quickshift nosetest with different xyz color conversion 2012-11-30 15:36:01 +01:00
Juan Nunez-Iglesias b906082034 Add testing functions for join and relabel 2012-11-28 12:48:13 +11:00
Andreas Mueller 6c59e04714 MISC remove unused imports, some pep8 corrections. 2012-09-27 20:01:45 +01:00
Stefan van der Walt 03a701c831 Merge pull request #323 from emmanuelle/bug_rw
BUG: Correct a newly appeared bug in the random walker.
2012-09-19 17:53:25 -07:00
Emmanuelle Gouillart 6635cf16db [BUG] Corrected a bug in the random walker that appeared
* when returning the full probability instead of the segmentation
    * for three or more labels (two was OK)
2012-09-18 19:56:52 +02:00
Tony S Yu f2d5b109e9 Add assert_greater compatibility function.
Fix tests to work with nose < 1.1.3. Compatibility functions borrowed from scikit-learn.
2012-09-13 22:17:24 -04:00
Emmanuelle Gouillart 58a57238cc Merge pull request #282 from JDWarner/multispectral_random_walker
Multispectral random walker
2012-09-02 06:23:58 -07:00
JDWarner e8ddcefae3 PEP8 compliance, removed scaling, different data parsing.
This commit represents all recommended changes since the last
commit, notably:

* PEP8 compliance (in new sections; a few old ones still
  noncompliant w/indentations)

* Moved `depth` kwarg to end of list and in docstring.
  Clarified `depth` docstring, and added section in Notes
  further explaining this parameter.

* Added section in Notes warning that for multichannel inputs,
  all channels are combined during scaling.  The user must
  separately normalize each channel prior to calling
  random_walker()

* New method for parsing data, allowing more elegant gradient
  calculation code. Probably also more extensible. The 2D
  multispectral case forced this change.

* New test: `test_multispectral_2d()`
2012-08-31 14:14:46 -05:00
JDWarner 61320957eb Changes based on PR review recommendations: input format, scaling, and bugfix.
In this new version, all instances of 'spectrum' have been replaced with 'channel'.  The documentation also reflects this change, and the new multichannel kwarg used to indicate multichannel input is named appropriately.

New boolean multichannel kwarg added, which controls if the input has multiple channels or not.  Input 'data' is now array_like for both gray-level and multichannel.  This kwarg is needed mainly because a 3-D array could be either 3 spatial dimensions or a set of different 2-D channels.

New scaling kwarg added (may be removed in future), controlling if data scaling is applied to ALL channels or each channel individually, if multichannel=True. No effect for gray-level data.

Removed np.sqrt(gradients) in _compute_weights_3d(), which was a bug. Tests now pass consistently.

New method for maintaining shape from input to output, where dims = data.shape prior to np.atleast_3d().  A theoretical (70,100,1) array passed should now result in a (70,100,1) shaped output, for example.

Updated and fixed multispectral test script to work with new version.  TODO: Additional test(s) likely needed to cover code branches from new kwargs.
2012-08-29 16:33:56 -05:00
JDWarner 682d0535cd Added multispectral random walker test.
Since the multispectral path is equivalent except for gradient calcs,
only one test case is needed.  This test is modeled on the 3-D
non-multispectral version.  If deemed necessary, adding a 2-D case
would be simple.
2012-08-27 13:41:41 -05:00
Johannes Schönberger 1177cf1393 Move clear_border to segmentation package 2012-08-27 18:56:05 +02:00
Stefan van der Walt 8d54380dc0 Merge pull request #259 from emmanuelle/fix_random_walker
ENH: Fix random walker.
2012-08-27 02:40:56 -07:00
Emmanuelle Gouillart 28161eaee6 ENH: better handling of labels that need to be reordered
(this is now done automatically)
2012-08-24 15:09:46 +02:00
Stefan van der Walt 1c3aeec2a8 BUG: Remove uses of xrange for py3 compatibility. 2012-08-20 15:25:40 -07:00
Andreas Mueller fe2a4334fa ENH addressed (hopefully all) of Tony's and Stefan's comments. 2012-08-20 20:22:06 +01: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
Andreas Mueller 49bc44c6e9 FIXed test to work with the fixed "hashing" of colors 2012-08-03 11:37:11 +01:00
Andreas Mueller d2e226fe59 ENH tests for Felzenszwalbs segmentation, fixed off-by-one error 2012-08-03 11:37:11 +01:00
Andreas Mueller f0a7212c4f ENH Rename parameters in quickshift, add "ratio" 2012-08-03 11:37:11 +01:00
Andreas Mueller ce26467ad4 ENH: make quickshift more tolerant to input type, just convert to float. Also keep track of random seed for reproducable tests.
Finally, do a unique on the output and add testing.
2012-08-03 11:37:11 +01:00
Emmanuelle Gouillart aa92d5f0bd Better handling of labeled pixels in random walker segmentation when we
return the whole probability.
2012-07-24 23:01:15 +02:00
Emmanuelle Gouillart 4ab7d0a4fa Modifications to random walker segmentation algorithm:
* returning the probability to belong to a label instead of only the most
  likely label is now possible

* fixing some type issues

* handling non-consecutive label values
2012-06-24 19:35:27 +02:00
emmanuelle 528187c2b0 ENH: addressed Tony's comments (renaming of functions, doc) 2012-01-21 11:43:53 +01:00
emmanuelle 09e3a43f58 More explanations about the algorithm
Also: removed copyright
      changed module name
2012-01-17 21:32:08 +01:00
emmanuelle d1e608bfe9 Random walker algo for segmentation + example 2012-01-15 17:22:59 +01:00