当前位置: 首页>>代码示例>>Python>>正文


Python rank.mean函数代码示例

本文整理汇总了Python中skimage.filters.rank.mean函数的典型用法代码示例。如果您正苦于以下问题:Python mean函数的具体用法?Python mean怎么用?Python mean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: 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_equal(res, out)
    rank.geometric_mean(image=image, selem=elem, out=out, mask=mask,
                        shift_x=0, shift_y=0)
    assert_equal(res, out)
    rank.minimum(image=image, selem=elem, out=out, mask=mask,
                 shift_x=0, shift_y=0)
    assert_equal(res, out)
    rank.maximum(image=image, selem=elem, out=out, mask=mask,
                 shift_x=0, shift_y=0)
    assert_equal(res, out)
开发者ID:AbdealiJK,项目名称:scikit-image,代码行数:26,代码来源:test_rank.py

示例2: filter_img

def filter_img(img):
    selem = square(11)
    img[:, :, 0] = rank.mean(img[:, :, 0], selem=selem)
    img[:, :, 1] = rank.mean(img[:, :, 1], selem=selem)
    img[:, :, 2] = rank.mean(img[:, :, 2], selem=selem)
    #return np.array(img, dtype=float)
    return img_as_float(img)
开发者ID:OleNet,项目名称:caffe-windows,代码行数:7,代码来源:img_mani.py

示例3: test_inplace_output

    def test_inplace_output(self):
        # rank filters are not supposed to filter inplace

        selem = disk(20)
        image = (np.random.rand(500, 500) * 256).astype(np.uint8)
        out = image
        with pytest.raises(NotImplementedError):
            rank.mean(image, selem, out=out)
开发者ID:andreydung,项目名称:scikit-image,代码行数:8,代码来源:test_rank.py

示例4: test_random_sizes

def test_random_sizes():
    # make sure the size is not a problem

    niter = 10
    elem = np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]], dtype=np.uint8)
    for m, n in np.random.random_integers(1, 100, size=(10, 2)):
        mask = np.ones((m, n), dtype=np.uint8)

        image8 = np.ones((m, n), dtype=np.uint8)
        out8 = np.empty_like(image8)
        rank.mean(image=image8, selem=elem, mask=mask, out=out8,
                  shift_x=0, shift_y=0)
        assert_equal(image8.shape, out8.shape)
        rank.mean(image=image8, selem=elem, mask=mask, out=out8,
                  shift_x=+1, shift_y=+1)
        assert_equal(image8.shape, out8.shape)

        image16 = np.ones((m, n), dtype=np.uint16)
        out16 = np.empty_like(image8, dtype=np.uint16)
        rank.mean(image=image16, selem=elem, mask=mask, out=out16,
                  shift_x=0, shift_y=0)
        assert_equal(image16.shape, out16.shape)
        rank.mean(image=image16, selem=elem, mask=mask, out=out16,
                  shift_x=+1, shift_y=+1)
        assert_equal(image16.shape, out16.shape)

        rank.mean_percentile(image=image16, mask=mask, out=out16,
                             selem=elem, shift_x=0, shift_y=0, p0=.1, p1=.9)
        assert_equal(image16.shape, out16.shape)
        rank.mean_percentile(image=image16, mask=mask, out=out16,
                             selem=elem, shift_x=+1, shift_y=+1, p0=.1, p1=.9)
        assert_equal(image16.shape, out16.shape)
开发者ID:haohao200609,项目名称:Hybrid,代码行数:32,代码来源:test_rank.py

示例5: test_selem_dtypes

def test_selem_dtypes():

    image = np.zeros((5, 5), dtype=np.uint8)
    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

    for dtype in (np.uint8, np.uint16, np.int32, np.int64, np.float32, np.float64):
        elem = np.array([[0, 0, 0], [0, 1, 0], [0, 0, 0]], dtype=dtype)
        rank.mean(image=image, selem=elem, out=out, mask=mask, shift_x=0, shift_y=0)
        assert_equal(image, out)
        rank.mean_percentile(image=image, selem=elem, out=out, mask=mask, shift_x=0, shift_y=0)
        assert_equal(image, out)
开发者ID:YangChuan80,项目名称:scikit-image,代码行数:15,代码来源:test_rank.py

示例6: zoom

def zoom(imName, img, imageclass, conf):
	imName = imName+1
	im = Image.open(img)
	if not isdir(conf.output_folder+imageclass):
		try:
			mkdir(conf.output_folder+imageclass)
		except:
			pass
	fileMatch = 0
	for file in listdir(conf.output_folder+"/"+imageclass):
		if fnmatch.fnmatch(file, str(imName)+"_zoom_"+'*.jpg'):
			fileMatch = fileMatch+1
			if fileMatch>=3:
				if conf.VERBOSE: print "exists, so breaking: #"+str(imName)+" in "+str(imageclass)
				return str(imName)
	x, y = im.size
	x1=0
	y1=0
	means=[]
	while y1<=y-480:
		while x1<=x-640:
			ims = im.crop((x1, y1, x1+640, y1+480))
			mean1 = mean(np.array(ims)[:,:,1], disk(700))
			means.append(((x1,y1),int(mean1[0][0])))
			x1 = x1+160
		x1=0
		y1 = y1+120
	zoomNRC(imName, img, imageclass, conf, conf.mean_threshold, means, im)
	return str(imName)
开发者ID:lbarnett,项目名称:BirdID,代码行数:29,代码来源:roi.py

示例7: watershed

def watershed(image):
    hsv_image = color.rgb2hsv(image)

    low_res_image = rescale(hsv_image[:, :, 0], SCALE)
    local_mean = mean(low_res_image, disk(50))
    local_minimum_flat = np.argmin(local_mean)
    local_minimum = np.multiply(np.unravel_index(local_minimum_flat, low_res_image.shape), round(1 / SCALE))

    certain_bone_pixels = np.full_like(hsv_image[:, :, 0], False, bool)
    certain_bone_pixels[
    local_minimum[0] - INITIAL_WINDOW_SIZE/2:local_minimum[0]+INITIAL_WINDOW_SIZE/2,
    local_minimum[1] - INITIAL_WINDOW_SIZE/2:local_minimum[1]+INITIAL_WINDOW_SIZE/2
    ] = True

    certain_non_bone_pixels = np.full_like(hsv_image[:, :, 0], False, bool)
    certain_non_bone_pixels[0:BORDER_SIZE, :] = True
    certain_non_bone_pixels[-BORDER_SIZE:-1, :] = True
    certain_non_bone_pixels[:, 0:BORDER_SIZE] = True
    certain_non_bone_pixels[:, -BORDER_SIZE:-1] = True

    smoothed_hsv = median(hsv_image[:, :, 0], disk(50))
    threshold = MU * np.median(smoothed_hsv[certain_bone_pixels])

    possible_bones = np.zeros_like(hsv_image[:, :, 0])
    possible_bones[smoothed_hsv < threshold] = 1

    markers = np.zeros_like(possible_bones)
    markers[certain_bone_pixels] = 1
    markers[certain_non_bone_pixels] = 2

    labels = morphology.watershed(-possible_bones, markers)

    return labels
开发者ID:selaux,项目名称:master-of-bones,代码行数:33,代码来源:segmentation.py

示例8: substract_mean

 def substract_mean(self, radius_disk):
     circle = disk(radius_disk)
     for i_rot in np.arange(self.stack_height):
         stack_slice = self.score_stack[:,:,i_rot]
         norm_factor = max(stack_slice.min(), stack_slice.max(), key=abs)
         stack_slice *= 1./norm_factor 
         stack_slice = np.array(rank.mean(stack_slice, selem=circle), dtype=np.float32)
         stack_slice *= norm_factor
         self.score_stack[:,:,i_rot] = self.score_stack[:,:,i_rot]-stack_slice
开发者ID:Matze385,项目名称:Scoremapanalysis,代码行数:9,代码来源:scorestack.py

示例9: 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_equal(image, out)
    rank.minimum(image=image, selem=elem, out=out, mask=mask, shift_x=0, shift_y=0)
    assert_equal(image, out)
    rank.maximum(image=image, selem=elem, out=out, mask=mask, shift_x=0, shift_y=0)
    assert_equal(image, out)
开发者ID:YangChuan80,项目名称:scikit-image,代码行数:18,代码来源:test_rank.py

示例10: skmean

def skmean(image):

    from skimage.filters.rank import mean

    mean_filtered = mean(image, disk(30))

    print mean_filtered.min(), mean_filtered.max()

    return mean_filtered
开发者ID:JIC-Image-Analysis,项目名称:senescence-in-field,代码行数:9,代码来源:segment_single_file.py

示例11: 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)
开发者ID:borevitzlab,项目名称:scikit-image,代码行数:10,代码来源:test_rank.py

示例12: smooth

    def smooth(self):
        # TODO: there is non nan in the ff img, or?
        mask = self.flatField == 0
        from skimage.filters.rank import median, mean
        from skimage.morphology import disk

        ff = mean(median(self.flatField, disk(5), mask=~mask),
                  disk(13), mask=~mask)

        return ff.astype(float) / ff.max(), mask
开发者ID:radjkarl,项目名称:imgProcessor,代码行数:10,代码来源:vignettingFromRandomSteps.py

示例13: _coarsenImage

def _coarsenImage(image, f):
    '''
    seems to be a more precise (but slower)
    way to down-scale an image
    '''
    from skimage.morphology import square
    from skimage.filters import rank
    from skimage.transform._warps import rescale
    selem = square(f)
    arri = rank.mean(image, selem=selem)
    return rescale(arri, 1 / f, order=0)
开发者ID:radjkarl,项目名称:imgProcessor,代码行数:11,代码来源:positionToIntensityUncertainty.py

示例14: _segment_edge_areas

 def _segment_edge_areas(self, edges, disk_size, mean_threshold, min_object_size):
     """
     Takes a greyscale image (with brighter colors corresponding to edges) and returns a
     binary image where white indicates an area with high edge density and black indicates low density.
     """
     # Convert the greyscale edge information into black and white (ie binary) image
     threshold = threshold_otsu(edges)
     # Filter out the edge data below the threshold, effectively removing some noise
     raw_channel_areas = edges <= threshold
     # Smooth out the data
     channel_areas = rank.mean(raw_channel_areas, disk(disk_size)) < mean_threshold
     # Remove specks and blobs that are the result of artifacts
     clean_channel_areas = remove_small_objects(channel_areas, min_size=min_object_size)
     # Fill in any areas that are completely surrounded by the areas (hopefully) covering the channels
     return ndimage.binary_fill_holes(clean_channel_areas)
开发者ID:jimrybarski,项目名称:fylm_critic,代码行数:15,代码来源:rotate.py

示例15: 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
        if bitdepth > 11:
            expected = ['Bitdepth of %s' % (bitdepth - 1)]
        else:
            expected = []
        with expected_warnings(expected):
            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)
开发者ID:AbdealiJK,项目名称:scikit-image,代码行数:15,代码来源:test_rank.py


注:本文中的skimage.filters.rank.mean函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。