forked from CellProfiler/CellProfiler-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_laplacianofgaussian.py
46 lines (29 loc) · 1009 Bytes
/
test_laplacianofgaussian.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import cellprofiler.image
import numpy.testing
import scipy.ndimage.filters
import skimage.color
import laplacianofgaussian
instance = laplacianofgaussian.LaplacianOfGaussian
def test_run(image, image_set, module, workspace):
module.x_name.value = "example"
module.y_name.value = "LaplacianOfGaussian"
module.x.value = 1.1
module.y.value = 1.2
module.z.value = 1.3
module.run(workspace)
actual = image_set.get_image("LaplacianOfGaussian")
data = image.pixel_data
if image.multichannel:
data = skimage.color.rgb2gray(data)
data = skimage.img_as_float(data)
if image.dimensions == 2:
sigma = (1.1, 1.2)
else:
sigma = (1.3, 1.1, 1.2)
expected_data = scipy.ndimage.filters.gaussian_laplace(data, sigma)
expected = cellprofiler.image.Image(
dimensions=image.dimensions,
image=expected_data,
parent_image=image
)
numpy.testing.assert_array_equal(expected.pixel_data, actual.pixel_data)