• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python restoration.denoise_bilateral函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_denoise_bilateral_multidimensional

def test_denoise_bilateral_multidimensional():
    img = np.ones((10, 10, 10, 10))
    with pytest.raises(ValueError):
        restoration.denoise_bilateral(img, multichannel=False)
    with pytest.raises(ValueError):
        restoration.denoise_bilateral(
            img, multichannel=True)
开发者ID:andreydung,项目名称:scikit-image,代码行数:7,代码来源:test_denoise.py


示例2: denoising

def denoising(astro):
	noisy = astro + 0.6 * astro.std() * np.random.random(astro.shape)
	noisy = np.clip(noisy, 0, 1)
	fig, ax = plt.subplots(nrows=2, ncols=3, figsize=(8, 5), sharex=True,
						   sharey=True, subplot_kw={'adjustable': 'box-forced'})

	plt.gray()

	ax[0, 0].imshow(noisy)
	ax[0, 0].axis('off')
	ax[0, 0].set_title('noisy')
	ax[0, 1].imshow(denoise_tv_chambolle(noisy, weight=0.1, multichannel=True))
	ax[0, 1].axis('off')
	ax[0, 1].set_title('TV')
	ax[0, 2].imshow(denoise_bilateral(noisy, sigma_range=0.05, sigma_spatial=15))
	ax[0, 2].axis('off')
	ax[0, 2].set_title('Bilateral')

	ax[1, 0].imshow(denoise_tv_chambolle(noisy, weight=0.2, multichannel=True))
	ax[1, 0].axis('off')
	ax[1, 0].set_title('(more) TV')
	ax[1, 1].imshow(denoise_bilateral(noisy, sigma_range=0.1, sigma_spatial=15))
	ax[1, 1].axis('off')
	ax[1, 1].set_title('(more) Bilateral')
	ax[1, 2].imshow(astro)
	ax[1, 2].axis('off')
	ax[1, 2].set_title('original')

	fig.tight_layout()

	plt.show()
开发者ID:omidi,项目名称:CellLineageTracking,代码行数:31,代码来源:slic.py


示例3: getSubImages

def getSubImages(img, pixels, size):
    subImages = []
    originals = []
    for i in range(len(img)):
        subImageRow = []
        originalRow = []
        for j in range(len(img[i])):
            if i % pixels == 0 and j % pixels == 0 and i+size-1 < len(img) and j+size-1 < len(img[i]):
                subImage = []
                for k in range(i, i+size, int(size/20)):
                    line = []
                    for l in range(j, j+size, int(size/20)):
                        line.append(img[k][l])
                    subImage.append(line)
                originalRow.append(subImage)
                if preprocess == preprocessing.SOBEL:
                    subImage = denoise_bilateral(subImage, sigma_range=0.1, sigma_spatial=15)
                    subImage = sobel(subImage)
                elif preprocess == preprocessing.HOG:
                    subImage = useHoG(subImage)
                else:
                    subImage = denoise_bilateral(subImage, sigma_range=0.1, sigma_spatial=15)
                    subImage = sobel(subImage)
                    subImage = useHoG(subImage)
                subImageRow.append(subImage)
        if len(subImageRow) > 0:
            subImages.append(subImageRow)
            originals.append(originalRow)
    return subImages, originals
开发者ID:morteano,项目名称:TDT4173,代码行数:29,代码来源:OCR.py


示例4: test_denoise_bilateral_color

def test_denoise_bilateral_color():
    img = checkerboard.copy()
    # add some random noise
    img += 0.5 * img.std() * np.random.rand(*img.shape)
    img = np.clip(img, 0, 1)

    out1 = restoration.denoise_bilateral(img, sigma_range=0.1, sigma_spatial=20)
    out2 = restoration.denoise_bilateral(img, sigma_range=0.2, sigma_spatial=30)

    # make sure noise is reduced in the checkerboard cells
    assert img[30:45, 5:15].std() > out1[30:45, 5:15].std()
    assert out1[30:45, 5:15].std() > out2[30:45, 5:15].std()
开发者ID:AceHao,项目名称:scikit-image,代码行数:12,代码来源:test_denoise.py


示例5: test_denoise_sigma_range_and_sigma_color

def test_denoise_sigma_range_and_sigma_color():
    img = checkerboard_gray.copy()[:50,:50]
    # add some random noise
    img += 0.5 * img.std() * np.random.rand(*img.shape)
    img = np.clip(img, 0, 1)
    out1 = restoration.denoise_bilateral(img, sigma_color=0.1,
                                         sigma_spatial=10, multichannel=False)
    with expected_warnings('`sigma_range` has been deprecated in favor of `sigma_color`. '
                           'The `sigma_range` keyword argument will be removed in v0.14'):
        out2 = restoration.denoise_bilateral(img, sigma_color=0.2, sigma_range=0.1,
                                             sigma_spatial=10, multichannel=False)
    assert_equal(out1, out2)
开发者ID:dfcollin,项目名称:scikit-image,代码行数:12,代码来源:test_denoise.py


示例6: test_denoise_bilateral_3d

def test_denoise_bilateral_3d():
    img = lena
    # add some random noise
    img += 0.5 * img.std() * np.random.random(img.shape)
    img = np.clip(img, 0, 1)

    out1 = restoration.denoise_bilateral(img, sigma_range=0.1, sigma_spatial=20)
    out2 = restoration.denoise_bilateral(img, sigma_range=0.2, sigma_spatial=30)

    # make sure noise is reduced
    assert img.std() > out1.std()
    assert out1.std() > out2.std()
开发者ID:jehturner,项目名称:scikit-image,代码行数:12,代码来源:test_denoise.py


示例7: test_denoise_bilateral_color

def test_denoise_bilateral_color():
    img = checkerboard.copy()[:50, :50]
    # add some random noise
    img += 0.5 * img.std() * np.random.rand(*img.shape)
    img = np.clip(img, 0, 1)

    out1 = restoration.denoise_bilateral(img, sigma_color=0.1,
                                         sigma_spatial=10, multichannel=True)
    out2 = restoration.denoise_bilateral(img, sigma_color=0.2,
                                         sigma_spatial=20, multichannel=True)

    # make sure noise is reduced in the checkerboard cells
    assert_(img[30:45, 5:15].std() > out1[30:45, 5:15].std())
    assert_(out1[30:45, 5:15].std() > out2[30:45, 5:15].std())
开发者ID:ThomasWalter,项目名称:scikit-image,代码行数:14,代码来源:test_denoise.py


示例8: blur_predict

def blur_predict(model, X, type="median", filter_size=3, sigma=1.0):
  
    if type == "median":
        blured_X = np.array(list(map(lambda x: ndimage.median_filter(x, filter_size), 
                                     X)))
    elif type == "gaussian":
        blured_X = np.array(list(map(lambda x: ndimage.gaussian_filter(x, filter_size),
                                     X)))
    elif type == "f_gaussian":
        blured_X = np.array(list(map(lambda x: filters.gaussian_filter(x.reshape((28, 28)), sigma=sigma).reshape(784),
                                     X))) 
    elif type == "tv_chambolle":
        blured_X = np.array(list(map(lambda x: restoration.denoise_tv_chambolle(x.reshape((28, 28)), weight=0.2).reshape(784),
                                     X)))
    elif type == "tv_bregman":
        blured_X = np.array(list(map(lambda x: restoration.denoise_tv_bregman(x.reshape((28, 28)), weight=5.0).reshape(784),
                                     X)))
    elif type == "bilateral":
        blured_X = np.array(list(map(lambda x: restoration.denoise_bilateral(np.abs(x).reshape((28, 28))).reshape(784),
                                     X)))
    elif type == "nl_means":
        blured_X = np.array(list(map(lambda x: restoration.nl_means_denoising(x.reshape((28, 28))).reshape(784),
                                     X)))
        
    elif type == "none":
        blured_X = X 

    else:
        raise ValueError("unsupported filter type", type)

    return predict(model, blured_X)
开发者ID:PetraVidnerova,项目名称:pyGAAdversary,代码行数:31,代码来源:blur_errors.py


示例9: denoise_image

def denoise_image(data, type=None):
    from skimage.restoration import denoise_tv_chambolle, denoise_bilateral

    if type == "tv":
        return denoise_tv_chambolle(data, weight=0.2, multichannel=True)

    return denoise_bilateral(data, sigma_range=0.1, sigma_spatial=15)
开发者ID:121onto,项目名称:noaa,代码行数:7,代码来源:facial_alignment.py


示例10: test_denoise_bilateral_nan

def test_denoise_bilateral_nan():
    img = np.full((50, 50), np.NaN)
    # This is in fact an optional warning for our test suite.
    # Python 3.5 will not trigger a warning.
    with expected_warnings([r'invalid|\A\Z']):
        out = restoration.denoise_bilateral(img, multichannel=False)
    assert_equal(img, out)
开发者ID:ThomasWalter,项目名称:scikit-image,代码行数:7,代码来源:test_denoise.py


示例11: crop_resize_other

def crop_resize_other(img, pixelspacing ):
   print("image shape {}".format(np.array(img).shape))

   xmeanspacing = float(1.25826490244)
   ymeanspacing = float(1.25826490244)

   xscale = float(pixelspacing) / xmeanspacing
   yscale = float(pixelspacing) / ymeanspacing
   xnewdim = round( xscale * np.array(img).shape[0])
   ynewdim = round( yscale * np.array(img).shape[1])
   img = transform.resize(img, (xnewdim, ynewdim))
  
   #img = cv2.normalize(img, None, 0, 255, cv2.NORM_MINMAX) 
   #img = auto_canny(img)
   img = denoise_bilateral(img, sigma_range=0.05, sigma_spatial=15)

   #im = cv2.normalize(im, None, 0, 255, cv2.NORM_MINMAX) 
   #img = img.Canny(im,128,128)
   """crop center and resize"""
   if img.shape[0] < img.shape[1]:
       img = img.T
   # we crop image from center
   short_egde = min(img.shape[:2])
   yy = int((img.shape[0] - short_egde) / 2)
   xx = int((img.shape[1] - short_egde) / 2)
   crop_img = img[yy : yy + short_egde, xx : xx + short_egde]
   crop_img *= 255
   return crop_img.astype("uint8")
开发者ID:zhengzhang828,项目名称:GithubVS2013,代码行数:28,代码来源:GithubTesting04172016.py


示例12: test_denoise_bilateral_types

def test_denoise_bilateral_types(dtype):
    img = checkerboard_gray.copy()[:50, :50]
    # add some random noise
    img += 0.5 * img.std() * np.random.rand(*img.shape)
    img = np.clip(img, 0, 1)

    # check that we can process multiple float types
    out = restoration.denoise_bilateral(img, sigma_color=0.1,
                                        sigma_spatial=10, multichannel=False)
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:9,代码来源:test_denoise.py


示例13: test_denoise_bilateral_3d_multichannel

def test_denoise_bilateral_3d_multichannel():
    img = np.ones((50, 50, 50))
    with expected_warnings(["grayscale"]):
        result = restoration.denoise_bilateral(img)

    expected = np.empty_like(img)
    expected.fill(np.nan)

    assert_equal(result, expected)
开发者ID:AceHao,项目名称:scikit-image,代码行数:9,代码来源:test_denoise.py


示例14: image_features_hog3

def image_features_hog3(img, num_features,orientation,maxcell,maxPixel):

     image=denoise_bilateral(img, win_size=5, sigma_range=None, sigma_spatial=1, bins=10000, mode='constant', cval=0)
     thresh = threshold_otsu(image)
     binary = image > thresh
     im = resize(binary, (maxPixel, maxPixel))
     ##hog scikit transform
     fd= hog(im, orientations=orientation, pixels_per_cell=(maxcell, maxcell),
                    cells_per_block=(1, 1), visualise=False,normalise=True)

     return fd
开发者ID:kailex,项目名称:Bowl,代码行数:11,代码来源:Prepare_Features.py


示例15: denoiseBilateral

def denoiseBilateral(imagen,multichannel):
    """
    -Reemplaza el valor de cada pixel en funcion de la proximidad espacial y radiometrica
     medida por la funcion Gaussiana de la distancia euclidiana entre dos pixels y con
     cierta desviacion estandar.
    -False si la imagen es una escala de grises, sino True
    """
    noisy = img_as_float(imagen)

    denoise = denoise_bilateral(noisy, 7, 9, 0.08,multichannel)

    return denoise
开发者ID:gastonzarate,项目名称:ReconocedorPlexoBraquialUltrasonido,代码行数:12,代码来源:ReducirRuido.py


示例16: image_features_resize_thres

def image_features_resize_thres(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=float)
     image=denoise_bilateral(img, win_size=5, sigma_range=None, sigma_spatial=1, bins=10000, mode='constant', cval=0)
     thresh = threshold_otsu(image)
     binary = image > thresh
     im = resize(binary, (maxPixel, maxPixel))

     # Store the rescaled image pixels
     X[0:imageSize] = np.reshape(im,(1, imageSize))

     return X
开发者ID:kailex,项目名称:Bowl,代码行数:14,代码来源:Prepare_Features.py


示例17: watershed

def watershed(image):
    """ the watershed algorithm """
    if len(image.shape) != 2:
        raise TypeError("The input image must be gray-scale ")

    h, w = image.shape
    image = cv2.equalizeHist(image)
    image = denoise_bilateral(image, sigma_range=0.1, sigma_spatial=10)
    image = rescale_intensity(image)
    image = img_as_ubyte(image)
    image = rescale_intensity(image)
    # com.debug_im(image)

    _, thres = cv2.threshold(image, 80, 255, cv2.THRESH_BINARY_INV)

    distance = ndi.distance_transform_edt(thres)
    local_maxi = peak_local_max(distance, indices=False,
                                labels=thres,
                                min_distance=5)

    # com.debug_im(thres)
    # implt = plt.imshow(-distance, cmap=plt.cm.jet, interpolation='nearest')
    # plt.show()

    markers = ndi.label(local_maxi, np.ones((3, 3)))[0]
    labels = ws(-distance, markers, mask=thres)
    labels = np.uint8(labels)
    # result = np.round(255.0 / np.amax(labels) * labels).astype(np.uint8)
    # com.debug_im(result)

    segments = []
    for idx in range(1, np.amax(labels) + 1):

        indices = np.where(labels == idx)
        left = np.amin(indices[1])
        right = np.amax(indices[1])
        top = np.amin(indices[0])
        down = np.amax(indices[0])

        # region = labels[top:down, left:right]
        # m = (region > 0) & (region != idx)
        # region[m] = 0
        # region[region >= 1] = 1
        region = image[top:down, left:right]
        cont = Contour(mask=region)
        cont.lt = [left, top]
        cont.rb = [right, down]
        segments.append(cont)

    return segments
开发者ID:dangkhoasdc,项目名称:CellCounter,代码行数:50,代码来源:watershed.py


示例18: get_regions

def get_regions(img):
    denoised=restoration.denoise_bilateral(img.astype('uint16'), 
#                                            sigma_range=0.01, 
                                           sigma_spatial=15,
                                          multichannel=False)
    smoothened = filters.median(denoised,np.ones((4,4)))
    markers = np.zeros(smoothened.shape, dtype=np.uint)
# otsu works only for only for multi-channel images     
#     markers[smoothened < filters.threshold_otsu(smoothened)] = 1
#     markers[smoothened > filters.threshold_otsu(smoothened)] = 2
    markers[smoothened < filters.median(smoothened)] = 1
    markers[smoothened > filters.median(smoothened)] = 2

    labels = random_walker(smoothened, markers, beta=10, mode='bf')
    regions= measure.label(labels)
    return regions, denoised, smoothened,markers
开发者ID:rraadd88,项目名称:htsimaging,代码行数:16,代码来源:utils.py


示例19: localToneMap

def localToneMap(img,dR=4,filt="bilateral",sigma=6, sr=0.05, ss=15):

	r = img[:,:,0]
	g = img[:,:,1]
	b = img[:,:,2]

	pixList = [r,g,b]
	(width,height,_) = img.shape

	# Intensity -- consider using weighted average?? 
	I = np.mean(pixList, axis=0)

	# Chrominance Channels
	chromeChannels = map(lambda x:x/I,  pixList) 

	# Log Intensity
	L = np.log2(I)

	# bilateral filter
	if filt == "gaussian":
		B = ndimage.filters.gaussian_filter(L,sigma)
	else:
		B = denoise_bilateral(L,sigma_range=sr, sigma_spatial=ss)

	# Compute the detail layer: 
	D = L - B 

	offset = np.amax(B) 

	scale = dR / (offset - np.amin(B))

	B_Prime = (B - offset*np.ones((width,height))) * scale

	# Reconstruct the log intensity: O = 2^(B' + D)
	reconLogIntens = map(lambda x: 2**x, B_Prime + D)

	# New Colors R',G',B' = O * (R/I, G/I, B/I)
	newColors = map(lambda x: x * reconLogIntens, chromeChannels)

	# Gamma Compression/correction
	newColors = map(gammaCorrect, newColors)

	img[:,:,0] = newColors[0]
	img[:,:,1] = newColors[1]
	img[:,:,2] = newColors[2]

	return img
开发者ID:zrathustra,项目名称:project5,代码行数:47,代码来源:hdr.py


示例20: _get_processed_image

 def _get_processed_image(self):
     # read image
     image = mpimg.imread(self.image_path)
     mask = image[:,:,1] > 150.
     image[mask] = 255.
     #plt.imshow(image)
     #plt.show()
     # convert to grayscale
     image = self.rgb2gray(image)
     # crop image
     image = image[100:1000,200:1100]
     mask = mask[100:1000,200:1100]
     image = image - np.min(image)
     image[mask] *= 255. / np.max(image[mask])
     if self.filter == True:
         image = denoise_bilateral(image, sigma_spatial=self.denoise_spatial)
     if self.denoise == True:
         image = threshold_adaptive(image, self.block_size, offset=self.offset)
     return image, mask
开发者ID:rostar,项目名称:rostar,代码行数:19,代码来源:image_processing_lab.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python restoration.denoise_nl_means函数代码示例发布时间:2022-05-27
下一篇:
Python watershed.watershed函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap