本文整理汇总了Python中skimage.filter.rank.maximum函数的典型用法代码示例。如果您正苦于以下问题:Python maximum函数的具体用法?Python maximum怎么用?Python maximum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了maximum函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: split_object
def split_object(self, labeled_image):
""" split object when it's necessary
"""
labeled_image = labeled_image.astype(np.uint16)
labeled_mask = np.zeros_like(labeled_image, dtype=np.uint16)
labeled_mask[labeled_image != 0] = 1
#ift structuring element about center point. This only affects eccentric structuring elements (i.e. selem with even num===============================
labeled_image = skr.median(labeled_image, skm.disk(4))
labeled_mask = np.zeros_like(labeled_image, dtype=np.uint16)
labeled_mask[labeled_image != 0] = 1
distance = scipym.distance_transform_edt(labeled_image).astype(np.uint16)
#=======================================================================
# binary = np.zeros(np.shape(labeled_image))
# binary[labeled_image > 0] = 1
#=======================================================================
distance = skr.mean(distance, skm.disk(15))
l_max = skr.maximum(distance, skm.disk(5))
#l_max = skf.peak_local_max(distance, indices=False,labels=labeled_image, footprint=np.ones((3,3)))
l_max = l_max - distance <= 0
l_max = skr.maximum(l_max.astype(np.uint8), skm.disk(6))
marker = ndimage.label(l_max)[0]
split_image = skm.watershed(-distance, marker)
split_image[split_image[0,0] == split_image] = 0
return split_image
示例2: test_structuring_element8
def test_structuring_element8():
# check the output for a custom structuring element
r = np.array([[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 255, 0, 0, 0],
[0, 0, 255, 255, 255, 0],
[0, 0, 0, 255, 255, 0],
[0, 0, 0, 0, 0, 0]])
# 8-bit
image = np.zeros((6, 6), dtype=np.uint8)
image[2, 2] = 255
elem = np.asarray([[1, 1, 0], [1, 1, 1], [0, 0, 1]], dtype=np.uint8)
out = np.empty_like(image)
mask = np.ones(image.shape, dtype=np.uint8)
rank.maximum(image=image, selem=elem, out=out, mask=mask,
shift_x=1, shift_y=1)
assert_array_equal(r, out)
# 16-bit
image = np.zeros((6, 6), dtype=np.uint16)
image[2, 2] = 255
out = np.empty_like(image)
rank.maximum(image=image, selem=elem, out=out, mask=mask,
shift_x=1, shift_y=1)
assert_array_equal(r, out)
示例3: test_compare_with_cmorph_dilate
def test_compare_with_cmorph_dilate():
# compare the result of maximum filter with dilate
image = (np.random.random((100, 100)) * 256).astype(np.uint8)
out = np.empty_like(image)
mask = np.ones(image.shape, dtype=np.uint8)
for r in range(1, 20, 1):
elem = np.ones((r, r), dtype=np.uint8)
rank.maximum(image=image, selem=elem, out=out, mask=mask)
cm = cmorph.dilate(image=image, selem=elem)
assert_array_equal(out, cm)
示例4: test_percentile_max
def test_percentile_max():
# check that percentile p0 = 1 is identical to local max
img = data.camera()
img16 = img.astype(np.uint16)
selem = disk(15)
# check for 8bit
img_p0 = rank.percentile(img, selem=selem, p0=1.)
img_max = rank.maximum(img, selem=selem)
assert_array_equal(img_p0, img_max)
# check for 16bit
img_p0 = rank.percentile(img16, selem=selem, p0=1.)
img_max = rank.maximum(img16, selem=selem)
assert_array_equal(img_p0, img_max)
示例5: test_16bit
def test_16bit():
image = np.zeros((21, 21), dtype=np.uint16)
selem = np.ones((3, 3), dtype=np.uint8)
for bitdepth in range(17):
value = 2 ** bitdepth - 1
image[10, 10] = value
assert rank.minimum(image, selem)[10, 10] == 0
assert rank.maximum(image, selem)[10, 10] == value
assert rank.mean(image, selem)[10, 10] == int(value / selem.size)
示例6: test_smallest_selem16
def test_smallest_selem16():
# check that min, max and mean returns identity if structuring element
# contains only central pixel
image = np.zeros((5, 5), dtype=np.uint16)
out = np.zeros_like(image)
mask = np.ones_like(image, dtype=np.uint8)
image[2, 2] = 255
image[2, 3] = 128
image[1, 2] = 16
elem = np.array([[1]], dtype=np.uint8)
rank.mean(image=image, selem=elem, out=out, mask=mask,
shift_x=0, shift_y=0)
assert_array_equal(image, out)
rank.minimum(image=image, selem=elem, out=out, mask=mask,
shift_x=0, shift_y=0)
assert_array_equal(image, out)
rank.maximum(image=image, selem=elem, out=out, mask=mask,
shift_x=0, shift_y=0)
assert_array_equal(image, out)
示例7: test_empty_selem
def test_empty_selem():
# check that min, max and mean returns zeros if structuring element is empty
image = np.zeros((5, 5), dtype=np.uint16)
out = np.zeros_like(image)
mask = np.ones_like(image, dtype=np.uint8)
res = np.zeros_like(image)
image[2, 2] = 255
image[2, 3] = 128
image[1, 2] = 16
elem = np.array([[0, 0, 0], [0, 0, 0]], dtype=np.uint8)
rank.mean(image=image, selem=elem, out=out, mask=mask,
shift_x=0, shift_y=0)
assert_array_equal(res, out)
rank.minimum(image=image, selem=elem, out=out, mask=mask,
shift_x=0, shift_y=0)
assert_array_equal(res, out)
rank.maximum(image=image, selem=elem, out=out, mask=mask,
shift_x=0, shift_y=0)
assert_array_equal(res, out)
示例8: run
def run(self, workspace):
cell_object = workspace.object_set.get_objects(self.primary_objects.value)
cell_labeled = cell_object.get_segmented()
cell_image = cell_object.get_parent_image()
cell_image = (cell_image * 1000).astype(np.uint16)
# object_count = cell_labeled.max()
maxi = skr.maximum(cell_image.astype(np.uint8), skm.disk(10))
local_max = maxi - cell_image < 10
local_max_labelize, object_count = scipy.ndimage.label(local_max, np.ones((3, 3), bool))
histo_local_max, not_use = np.histogram(local_max_labelize, range(object_count + 2))
old = local_max_labelize.copy()
# filter in intensity mean
# =======================================================================
#
# regionprops_result = skmes.regionprops(local_max_labelize, intensity_image=cell_image)
#
# for region in regionprops_result:
# if region["mean_intensity"]
# =======================================================================
# filter on size
for i in range(object_count + 1):
value = histo_local_max[i]
if value > self.range_size.max or value < self.range_size.min:
local_max_labelize[local_max_labelize == i] = 0
# split granule for each cell
cell_labeled = skm.label(cell_labeled)
cell_count = np.max(cell_labeled)
for cell_object_value in range(1, cell_count):
cell_object_mask = cell_labeled == cell_object_value
granule_in_cell = np.logical_and(cell_object_mask, local_max_labelize)
granule_in_cell = skm.label(granule_in_cell)
# ===================================================================
# plt.imshow(granule_in_cell + cell_object_mask)
# plt.show()
# ===================================================================
#
# get the filename
#
measurements = workspace.measurements
file_name_feature = self.source_file_name_feature
filename = measurements.get_current_measurement("Image", file_name_feature)
print "filename = ", filename
示例9: cr_max
def cr_max(image, selem):
return maximum(image=image, selem=selem)
示例10: filters
.. note::
`skimage.dilate` and `skimage.erode` are equivalent filters (see below for
comparison).
Here is an example of the classical morphological greylevel filters: opening,
closing and morphological gradient.
"""
from skimage.filter.rank import maximum, minimum, gradient
ima = data.camera()
closing = maximum(minimum(ima, disk(5)), disk(5))
opening = minimum(maximum(ima, disk(5)), disk(5))
grad = gradient(ima, disk(5))
# display results
fig = plt.figure(figsize=[10, 7])
plt.subplot(2, 2, 1)
plt.imshow(ima, cmap=plt.cm.gray)
plt.xlabel('original')
plt.subplot(2, 2, 2)
plt.imshow(closing, cmap=plt.cm.gray)
plt.xlabel('greylevel closing')
plt.subplot(2, 2, 3)
plt.imshow(opening, cmap=plt.cm.gray)
plt.xlabel('greylevel opening')
plt.subplot(2, 2, 4)
示例11: filters
.. note::
`skimage.dilate` and `skimage.erode` are equivalent filters (see below for
comparison).
Here is an example of the classical morphological gray-level filters: opening,
closing and morphological gradient.
"""
from skimage.filter.rank import maximum, minimum, gradient
noisy_image = img_as_ubyte(data.camera())
closing = maximum(minimum(noisy_image, disk(5)), disk(5))
opening = minimum(maximum(noisy_image, disk(5)), disk(5))
grad = gradient(noisy_image, disk(5))
# display results
fig = plt.figure(figsize=[10, 7])
plt.subplot(2, 2, 1)
plt.imshow(noisy_image, cmap=plt.cm.gray)
plt.title('Original')
plt.axis('off')
plt.subplot(2, 2, 2)
plt.imshow(closing, cmap=plt.cm.gray)
plt.title('Gray-level closing')
plt.axis('off')
示例12: normalize3Chan
probs = sv.predict(td)
out_cell = np.reshape(probs,(winds.shape[0],winds.shape[1]))
plt.figure()
plt.subplot(121)
plt.imshow(out_cell)
try:
io.imsave('C:/users/attialex/Desktop/out_cell_4.png',skimage.img_as_uint(out_cell))
except Exception as e:
print e.message
try:
bg = normalize3Chan(imex*1.)
fg_c = normalize3Chan(out_cell)
fg_c[:,:,0]=0;
fg_c[:,:,2]=0;
s1 = cv2.addWeighted(bg,.8,fg_c,.2,0)
cv2.imshow('cell',s1)
cv2.waitKey()
except Exception as e:
print e.message
max_cell = maximum(out_cell,np.ones((40,40)))
unique_cell = np.unique(max_cell)
plt.show()
示例13: normalize3Chan
plt.subplot(122)
plt.imshow(out_pile)
try:
io.imsave('C:/users/attialex/Desktop/out_pile_3.png',skimage.img_as_uint(out_pile))
io.imsave('C:/users/attialex/Desktop/out_cell_3.png',skimage.img_as_uint(out_cell))
except Exception as e:
print e.message
try:
bg = normalize3Chan(imex*1.)
fg_c = normalize3Chan(out_cell)
fg_p = normalize3Chan(out_pile)
fg_c[:,:,0]=0;
fg_c[:,:,2]=0;
s1 = cv2.addWeighted(bg,.8,fg_c,.2,0)
cv2.imshow('cell',s1)
s2 = cv2.addWeighted(bg,.8,fg_p,.2,0)
cv2.imshow('pile',s2)
cv2.waitKey()
except Exception as e:
print e.message
max_pile = maximum(out_pile,np.ones((40,40)))
unique_pile = np.unique(max_pile)
max_cell = maximum(out_cell,np.ones((40,40)))
unique_cell = np.unique(max_cell)
plt.show()