Skip to content

Instantly share code, notes, and snippets.

@stefanv
Created January 16, 2019 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanv/6030eb81858d332fa9a83d713503d150 to your computer and use it in GitHub Desktop.
Save stefanv/6030eb81858d332fa9a83d713503d150 to your computer and use it in GitHub Desktop.
_________________________________________________________________________________ test_convex_image _________________________________________________________________________________
def test_convex_image():
img = regionprops(SAMPLE)[0].convex_image
# determined with MATLAB
ref = np.array(
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
)
> assert_array_equal(img, ref)
E AssertionError:
E Arrays are not equal
E
E (mismatch 31.111111111111114%)
E x: array([ True, True, True, True, True, True, True, True, True,
E True, True, True, True, True, True, True, True, True,
E True, True, True, True, True, True, True, True, True,...
E y: array([0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
E 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
E 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
skimage/measure/tests/test_regionprops.py:142: AssertionError
___________________________________________________________________ [doctest] skimage.filters._gaussian.gaussian ____________________________________________________________________
074 Examples
075 --------
076
077 >>> a = np.zeros((3, 3))
078 >>> a[1, 1] = 1
079 >>> a
080 array([[ 0., 0., 0.],
081 [ 0., 1., 0.],
082 [ 0., 0., 0.]])
083 >>> gaussian(a, sigma=0.4) # mild smoothing
Differences (unified diff with -expected +actual):
@@ -1,3 +1,3 @@
-array([[ 0.00163116, 0.03712502, 0.00163116],
- [ 0.03712502, 0.84496158, 0.03712502],
- [ 0.00163116, 0.03712502, 0.00163116]])
+array([[ 0.0016311596, 0.0371250207, 0.0016311596],
+ [ 0.0371250207, 0.8449615765, 0.0371250207],
+ [ 0.0016311596, 0.0371250207, 0.0016311596]])
/home/stefan/src/scikit-image/skimage/filters/_gaussian.py:83: DocTestFailure
_______________________________________________________________ [doctest] skimage.measure._moments.moments_normalized _______________________________________________________________
305
306 Examples
307 --------
308 >>> image = np.zeros((20, 20), dtype=np.double)
309 >>> image[13:17, 13:17] = 1
310 >>> m = moments(image)
311 >>> cr = m[0, 1] / m[0, 0]
312 >>> cc = m[1, 0] / m[0, 0]
313 >>> mu = moments_central(image, cr, cc)
314 >>> moments_normalized(mu)
Differences (unified diff with -expected +actual):
@@ -1,4 +1,4 @@
-array([[ nan, nan, 0.078125 , 0. ],
- [ nan, 0. , 0. , 0. ],
- [ 0.078125 , 0. , 0.00610352, 0. ],
- [ 0. , 0. , 0. , 0. ]])
+array([[ nan, nan, 0.078125 , 0. ],
+ [ nan, 0. , 0. , 0. ],
+ [ 0.078125 , 0. , 0.0061035156, 0. ],
+ [ 0. , 0. , 0. , 0. ]])
/home/stefan/src/scikit-image/skimage/measure/_moments.py:314: DocTestFailure
______________________________________________________________________ [doctest] skimage.util.lookfor.lookfor _______________________________________________________________________
007
008 Parameters
009 ----------
010 what : str
011 Words to look for.
012
013 Examples
014 --------
015 >>> import skimage
016 >>> skimage.lookfor('regular_grid')
UNEXPECTED EXCEPTION: TypeError("'NoneType' object is not iterable",)
Traceback (most recent call last):
File "/usr/lib/python3.6/doctest.py", line 1330, in __run
compileflags, 1), test.globs)
File "<doctest skimage.util.lookfor.lookfor[1]>", line 1, in <module>
File "/home/stefan/src/scikit-image/skimage/util/lookfor.py", line 24, in lookfor
return np.lookfor(what, sys.modules[__name__.split('.')[0]])
File "/home/stefan/envs/py36/lib/python3.6/site-packages/numpy/lib/utils.py", line 754, in lookfor
cache = _lookfor_generate_cache(module, import_modules, regenerate)
File "/home/stefan/envs/py36/lib/python3.6/site-packages/numpy/lib/utils.py", line 906, in _lookfor_generate_cache
for pth in item.__path__:
TypeError: 'NoneType' object is not iterable
/home/stefan/src/scikit-image/skimage/util/lookfor.py:16: UnexpectedException
______________________________________________________________________ [doctest] skimage.feature.blob.blob_log ______________________________________________________________________
322 References
323 ----------
324 .. [1] http://en.wikipedia.org/wiki/Blob_detection#The_Laplacian_of_Gaussian
325
326 Examples
327 --------
328 >>> from skimage import data, feature, exposure
329 >>> img = data.coins()
330 >>> img = exposure.equalize_hist(img) # improves detection
331 >>> feature.blob_log(img, threshold = .3)
Differences (unified diff with -expected +actual):
@@ -1,17 +1,17 @@
-array([[ 266. , 115. , 11.88888889],
- [ 263. , 302. , 17.33333333],
- [ 263. , 244. , 17.33333333],
- [ 260. , 174. , 17.33333333],
- [ 198. , 155. , 11.88888889],
- [ 198. , 103. , 11.88888889],
- [ 197. , 44. , 11.88888889],
- [ 194. , 276. , 17.33333333],
- [ 194. , 213. , 17.33333333],
- [ 185. , 344. , 17.33333333],
- [ 128. , 154. , 11.88888889],
- [ 127. , 102. , 11.88888889],
- [ 126. , 208. , 11.88888889],
- [ 126. , 46. , 11.88888889],
- [ 124. , 336. , 11.88888889],
- [ 121. , 272. , 17.33333333],
- [ 113. , 323. , 1. ]])
+array([[ 266. , 115. , 11.8888888889],
+ [ 263. , 302. , 17.3333333333],
+ [ 263. , 244. , 17.3333333333],
+ [ 260. , 174. , 17.3333333333],
+ [ 198. , 155. , 11.8888888889],
+ [ 198. , 103. , 11.8888888889],
+ [ 197. , 44. , 11.8888888889],
+ [ 194. , 276. , 17.3333333333],
+ [ 194. , 213. , 17.3333333333],
+ [ 185. , 344. , 17.3333333333],
+ [ 128. , 154. , 11.8888888889],
+ [ 127. , 102. , 11.8888888889],
+ [ 126. , 208. , 11.8888888889],
+ [ 126. , 46. , 11.8888888889],
+ [ 124. , 336. , 11.8888888889],
+ [ 121. , 272. , 17.3333333333],
+ [ 113. , 323. , 1. ]])
/home/stefan/src/scikit-image/skimage/feature/blob.py:331: DocTestFailure
_______________________________________________________________ [doctest] skimage.external.tifffile.tifffile.TiffFile _______________________________________________________________
1267 series : list of TiffPageSeries
1268 TIFF pages with compatible shapes and types.
1269 micromanager_metadata: dict
1270 Extra MicroManager non-TIFF metadata in the file, if exists.
1271
1272 All attributes are read-only.
1273
1274 Examples
1275 --------
1276 >>> with TiffFile('temp.tif') as tif:
Expected:
(5, 301, 219)
Got:
(2, 5, 3, 301, 219)
/home/stefan/src/scikit-image/skimage/external/tifffile/tifffile.py:1276: DocTestFailure
___________________________________________________________________ [doctest] skimage.feature.texture.greycoprops ___________________________________________________________________
195 [0 degrees, 90 degrees]
196
197 >>> image = np.array([[0, 0, 1, 1],
198 ... [0, 0, 1, 1],
199 ... [0, 2, 2, 2],
200 ... [2, 2, 3, 3]], dtype=np.uint8)
201 >>> g = greycomatrix(image, [1, 2], [0, np.pi/2], levels=4,
202 ... normed=True, symmetric=True)
203 >>> contrast = greycoprops(g, 'contrast')
204 >>> contrast
Expected:
array([[ 0.58333333, 1. ],
[ 1.25 , 2.75 ]])
Got:
array([[ 0.5833333333, 1. ],
[ 1.25 , 2.75 ]])
/home/stefan/src/scikit-image/skimage/feature/texture.py:204: DocTestFailure
______________________________________________________________________ [doctest] skimage.feature.blob.blob_doh ______________________________________________________________________
428
429 .. [2] Herbert Bay, Andreas Ess, Tinne Tuytelaars, Luc Van Gool,
430 "SURF: Speeded Up Robust Features"
431 ftp://ftp.vision.ee.ethz.ch/publications/articles/eth_biwi_00517.pdf
432
433 Examples
434 --------
435 >>> from skimage import data, feature
436 >>> img = data.coins()
437 >>> feature.blob_doh(img)
Differences (unified diff with -expected +actual):
@@ -1,17 +1,17 @@
-array([[ 270. , 363. , 30. ],
- [ 265. , 113. , 23.55555556],
- [ 262. , 243. , 23.55555556],
- [ 260. , 173. , 30. ],
- [ 197. , 153. , 20.33333333],
- [ 197. , 44. , 20.33333333],
- [ 195. , 100. , 23.55555556],
- [ 193. , 275. , 23.55555556],
- [ 192. , 212. , 23.55555556],
- [ 185. , 348. , 30. ],
- [ 156. , 302. , 30. ],
- [ 126. , 153. , 20.33333333],
- [ 126. , 101. , 20.33333333],
- [ 124. , 336. , 20.33333333],
- [ 123. , 205. , 20.33333333],
- [ 123. , 44. , 23.55555556],
- [ 121. , 271. , 30. ]])
+array([[ 270. , 363. , 30. ],
+ [ 265. , 113. , 23.5555555556],
+ [ 262. , 243. , 23.5555555556],
+ [ 260. , 173. , 30. ],
+ [ 197. , 153. , 20.3333333333],
+ [ 197. , 44. , 20.3333333333],
+ [ 195. , 100. , 23.5555555556],
+ [ 193. , 275. , 23.5555555556],
+ [ 192. , 212. , 23.5555555556],
+ [ 185. , 348. , 30. ],
+ [ 156. , 302. , 30. ],
+ [ 126. , 153. , 20.3333333333],
+ [ 126. , 101. , 20.3333333333],
+ [ 124. , 336. , 20.3333333333],
+ [ 123. , 205. , 20.3333333333],
+ [ 123. , 44. , 23.5555555556],
+ [ 121. , 271. , 30. ]])
/home/stefan/src/scikit-image/skimage/feature/blob.py:437: DocTestFailure
================================================================================= warnings summary ==================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment