本文整理汇总了Python中skimage.restoration.denoise_bilateral函数的典型用法代码示例。如果您正苦于以下问题:Python denoise_bilateral函数的具体用法?Python denoise_bilateral怎么用?Python denoise_bilateral使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了denoise_bilateral函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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()
示例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
示例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()
示例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)
示例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()
示例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())
示例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)
示例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)
示例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)
示例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")
示例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)
示例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)
示例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
示例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