本文整理汇总了Python中skimage.filter.sobel函数的典型用法代码示例。如果您正苦于以下问题:Python sobel函数的具体用法?Python sobel怎么用?Python sobel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sobel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_edges
def get_edges(img):
edge = np.empty(img.shape)
if len(img.shape) == 3:
for i in range(3):
edge[:, :, i] = imfilt.sobel(img[:, :, i])
else:
edge = imfilt.sobel(img)
edge = rescale_intensity(edge)
return edge
开发者ID:iedo,项目名称:scikits.image,代码行数:9,代码来源:scikits_image_logo.py
示例2: test_convolution_upcast
def test_convolution_upcast(self):
i, j = np.mgrid[-5:6, -5:6]
image = np.load(os.path.join(data_dir, 'lena_GRAY_U8.npy'))
result1 = F.sobel(image)
image = image.astype(float)
result2 = F.sobel(image)
assert_array_equal(result1, result2)
开发者ID:kapilkumawat,项目名称:scikits-image,代码行数:9,代码来源:test_edges.py
示例3: sobel
def sobel(data, sliceId=2):
edges = np.zeros(data.shape)
if sliceId == 2:
for idx in range(data.shape[2]):
edges[:, :, idx] = skifil.sobel(data[:, :, idx])
elif sliceId == 0:
for idx in range(data.shape[0]):
edges[idx, :, :] = skifil.sobel(data[idx, :, :])
return edges
开发者ID:Trineon,项目名称:lisa,代码行数:9,代码来源:tools.py
示例4: segment
def segment(self, src):
image = src.ndarray[:]
if self.use_adaptive_threshold:
block_size = 25
markers = threshold_adaptive(image, block_size) * 255
markers = invert(markers)
else:
markers = zeros_like(image)
markers[image < self.threshold_low] = 1
markers[image > self.threshold_high] = 255
elmap = sobel(image, mask=image)
wsrc = watershed(elmap, markers, mask=image)
# elmap = ndimage.distance_transform_edt(image)
# local_maxi = is_local_maximum(elmap, image,
# ones((3, 3))
# )
# markers = ndimage.label(local_maxi)[0]
# wsrc = watershed(-elmap, markers, mask=image)
# fwsrc = ndimage.binary_fill_holes(out)
# return wsrc
if self.use_inverted_image:
out = invert(wsrc)
else:
out = wsrc
# time.sleep(1)
# do_later(lambda:self.show_image(image, -elmap, out))
return out
开发者ID:softtrainee,项目名称:arlab,代码行数:31,代码来源:region.py
示例5: segment
def segment(self, src):
'''
pychron: preprocessing cv.Mat
'''
# image = pychron.ndarray[:]
# image = asarray(pychron)
image = src[:]
if self.use_adaptive_threshold:
# block_size = 25
markers = threshold_adaptive(image, self.block_size)
n = markers[:].astype('uint8')
n[markers == True] = 255
n[markers == False] = 1
markers = n
else:
markers = zeros_like(image)
markers[image < self.threshold_low] = 1
markers[image > self.threshold_high] = 255
elmap = sobel(image, mask=image)
wsrc = watershed(elmap, markers, mask=image)
# wsrc = wsrc.astype('uint8')
return invert(wsrc)
开发者ID:OSUPychron,项目名称:pychron,代码行数:26,代码来源:region.py
示例6: watershed_3d
def watershed_3d(sphere):
"""
Markers should be int8
Image should be uint8
"""
sphere = median_filter(sphere, 3)
thresh = threshold_otsu(sphere)
sphere = (sphere >= thresh) * 1
sphere = sobel(sphere)
size = (sphere.shape[0], sphere.shape[1], sphere.shape[2])
marker = np.zeros(size, dtype=np.int16)
pl.imshow(sphere[:,:,50])
pl.show()
# mark everything outside as background
marker[5, :, :] = -1
marker[size[0] - 5, :, :] = -1
marker[:, :, 5] = -1
marker[:, :, size[2] - 5] = -1
marker[:, 5, :] = -1
marker[:, size[1] - 5, :] = -1
marker[:,0,0] = -1
# mark everything inside as a sphere
marker[size[0] / 2., size[1] / 2., size[2] / 2.] = 5
result = measurements.watershed_ift(sphere.astype(dtype=np.uint16), marker)
pl.imshow(result[:,:,50])
pl.show()
return result
开发者ID:DiamondLightSource,项目名称:auto_tomo_calibration-experimental,代码行数:32,代码来源:Segmentation.py
示例7: houghLine
def houghLine(img2d):
"gray input"
med_filter = ndimg.median_filter(img2d, size = (5,5))
edges = filter.sobel(med_filter/255.)
[H,theta,distances] = transform.hough_line(edges);
imgsize = float(len(theta)*len(distances))
return H.sum()/imgsize
开发者ID:yigong,项目名称:AY250,代码行数:7,代码来源:run_final_classifier.py
示例8: __init__
def __init__(self):
self.logo = scipy_logo.ScipyLogo(radius=self.radius)
self.mask_1 = self.logo.get_mask(self.image.shape, 'upper left')
self.mask_2 = self.logo.get_mask(self.image.shape, 'lower right')
edges = np.array([sobel(img) for img in self.image.T]).T
# truncate and stretch intensity range to enhance contrast
self.edges = rescale_intensity(edges, in_range=(0, 0.4))
开发者ID:A-0-,项目名称:scikit-image,代码行数:8,代码来源:scikit_image_logo.py
示例9: detect_edges
def detect_edges(image):
# 1. convert to grayscale image
image_gray = rgb2gray(image)
# 2. convolve with Sobel filter
image_sobel = sobel(image_gray)
# 3. compute binary edge image with threshold from Otsu's method
image_edges = image_sobel > threshold_otsu(image_sobel)
return image_sobel, image_edges
开发者ID:AlexanderFabisch,项目名称:picamera-project,代码行数:8,代码来源:image_processing.py
示例10: test_sobel_vertical
def test_sobel_vertical():
"""Sobel on a vertical edge should be a vertical line."""
i, j = np.mgrid[-5:6, -5:6]
image = (j >= 0).astype(float)
result = F.sobel(image) * np.sqrt(2)
j[np.abs(i) == 5] = 10000
assert (np.all(result[j == 0] == 1))
assert (np.all(result[np.abs(j) > 1] == 0))
开发者ID:ramosapf,项目名称:scikit-image,代码行数:8,代码来源:test_edges.py
示例11: test_01_01_horizontal
def test_01_01_horizontal(self):
"""Sobel on an edge should be a horizontal line"""
i, j = np.mgrid[-5:6, -5:6]
image = (i >= 0).astype(float)
result = F.sobel(image)
# Fudge the eroded points
i[np.abs(j) == 5] = 10000
assert (np.all(result[i == 0] == 1))
assert (np.all(result[np.abs(i) > 1] == 0))
开发者ID:Teva,项目名称:scikits.image,代码行数:9,代码来源:test_edges.py
示例12: dynamic_masking
def dynamic_masking(image,method='edges',filter_size=7,threshold=0.005):
""" Dynamically masks out the objects in the PIV images
Parameters
----------
image: image
a two dimensional array of uint16, uint8 or similar type
method: string
'edges' or 'intensity':
'edges' method is used for relatively dark and sharp objects, with visible edges, on
dark backgrounds, i.e. low contrast
'intensity' method is useful for smooth bright objects or dark objects or vice versa,
i.e. images with high contrast between the object and the background
filter_size: integer
a scalar that defines the size of the Gaussian filter
threshold: float
a value of the threshold to segment the background from the object
default value: None, replaced by sckimage.filter.threshold_otsu value
Returns
-------
image : array of the same datatype as the incoming image with the object masked out
as a completely black region(s) of zeros (integers or floats).
Example
--------
frame_a = openpiv.tools.imread( 'Camera1-001.tif' )
imshow(frame_a) # original
frame_a = dynamic_masking(frame_a,method='edges',filter_size=7,threshold=0.005)
imshow(frame_a) # masked
"""
imcopy = np.copy(image)
# stretch the histogram
image = exposure.rescale_intensity(img_as_float(image), in_range=(0, 1))
# blur the image, low-pass
blurback = gaussian_filter(image,filter_size)
if method is 'edges':
# identify edges
edges = sobel(blurback)
blur_edges = gaussian_filter(edges,21)
# create the boolean mask
bw = (blur_edges > threshold)
bw = binary_fill_holes(bw)
imcopy -= blurback
imcopy[bw] = 0.0
elif method is 'intensity':
background = gaussian_filter(median_filter(image,filter_size),filter_size)
imcopy[background > threshold_otsu(background)] = 0
return imcopy #image
开发者ID:joedborg,项目名称:openpiv-python,代码行数:57,代码来源:preprocess.py
示例13: sobelgm
def sobelgm(provider):
"""
mean sobel gradient magnitude
"""
gray = provider.as_gray()
mag = sobel(gray)
mag *= 100.0 / np.max(mag)
return np.mean(mag)
开发者ID:cuppster,项目名称:imagefeatures,代码行数:9,代码来源:basic.py
示例14: test_sobel_horizontal
def test_sobel_horizontal():
"""Sobel on a horizontal edge should be a horizontal line."""
i, j = np.mgrid[-5:6, -5:6]
image = (i >= 0).astype(float)
result = F.sobel(image) * np.sqrt(2)
# Fudge the eroded points
i[np.abs(j) == 5] = 10000
assert_allclose(result[i == 0], 1)
assert (np.all(result[np.abs(i) > 1] == 0))
开发者ID:ramosapf,项目名称:scikit-image,代码行数:9,代码来源:test_edges.py
示例15: edge
def edge(self):
'''
implements a edge detection
'''
self.img = self.img.mean(2)
self.img = filter.sobel(self.img)
self.refreshimg()
开发者ID:r-b-g-b,项目名称:AY250_HW,代码行数:9,代码来源:hw8.py
示例16: GlaremaskSobel
def GlaremaskSobel(Arrimg,**kwargs):
highthresh = kwargs.get('highthresh', None)
if highthresh is None:
highthresh = 2000
sob = filter.sobel(Arrimg)
sob[sob<highthresh] = 0
sob[sob>0] = 1
filled = NDIMG.binary_fill_holes(sob);
return 1-filled
开发者ID:rayg1234,项目名称:PyEdiffProcess,代码行数:9,代码来源:ImageUtils.py
示例17: process
def process(self, src, dest, config):
try:
srcImg = imread(src, flatten=True)
destImg = filter.sobel(srcImg)
scipy.misc.imsave(dest, destImg)
return True
except:
return False
开发者ID:RhinoLance,项目名称:PythonProcessQueue,代码行数:11,代码来源:sobel.py
示例18: image_features_sobel
def image_features_sobel(img, maxPixel, num_features,imageSize):
# X is the feature vector with one row of features per image
# consisting of the pixel values a, num_featuresnd our metric
X=np.zeros(num_features, dtype=np.float32)
image = filter.sobel(img)
edges = resize(image, (maxPixel, maxPixel))
# Store the rescaled image pixels
X[0:imageSize] = np.reshape(edges,(1, imageSize))
return X
开发者ID:kailex,项目名称:Bowl,代码行数:12,代码来源:Prepare_Features.py
示例19: run
def run(self, workspace):
image = workspace.image_set.get_image(self.image_name.value)
nuclei_image = image.pixel_data[:,:]
image_collection = []
#
#Get the global Threshold with Otsu algorithm and smooth nuclei image
#
# nuclei_smoothed = self.smooth_image(image_collection[3][0], image.mask, 1)
global_threshold_nuclei = otsu(nuclei_image, min_threshold=0, max_threshold=1)
print "the threshold compute by the Otsu algorythm is %f" % global_threshold_nuclei
#
#Binary thee "DAPI" Image (Nuclei) and labelelize the nuclei
#
binary_nuclei = (nuclei_image >= global_threshold_nuclei)
labeled_nuclei, object_count = scipy.ndimage.label(binary_nuclei, np.ones((3,3), bool))
print "the image got %d detected" % object_count
#
#Fill the hole and delete object witch touch the border.
#labeled_nuclei is modify after the function
#Filter small object and split object
#
labeled_nuclei = fill_labeled_holes(labeled_nuclei)
labeled_nuclei = self.filter_on_border(labeled_nuclei)
labeled_nuclei = self.filter_on_size(labeled_nuclei, object_count)
labeled_nuclei = self.split_object(labeled_nuclei)
#
#Edge detection of nuclei image and object are more separated
#
labeled_nuclei_canny = skf.sobel(labeled_nuclei)
labeled_nuclei[labeled_nuclei_canny > 0] = 0
labeled_nuclei = skr.minimum(labeled_nuclei.astype(np.uint16), skm.disk(3))
image_collection.append((nuclei_image, "Original"))
image_collection.append((labeled_nuclei, "Labelized image"))
workspace.display_data.image_collection = image_collection
#
#Create a new object which will be add to the workspace
#
objects = cellprofiler.objects.Objects()
objects.segmented = labeled_nuclei
objects.parent_image = nuclei_image
workspace.object_set.add_objects(objects, self.object_name.value)
开发者ID:Brainjump,项目名称:CellProfiler-Module,代码行数:52,代码来源:IdentifyNuclei.py
示例20: label_regions
def label_regions(im, mark_min=200, mark_max=230):
elevation_map = sobel(im)
markers = np.zeros_like(im)
markers[im < mark_min] = 1
markers[im > mark_max] = 2
segmentation = morphology.watershed(elevation_map, markers)
segmentation = ndimage.binary_fill_holes(segmentation - 1)
labeled_regions, _ = ndimage.label(segmentation)
return labeled_regions
开发者ID:ericmjonas,项目名称:franktrack,代码行数:13,代码来源:filters.py
注:本文中的skimage.filter.sobel函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论