2019-03-11 21:54:19 lz0499 阅读数 3370
  • 高通骁龙™开发者工具链介绍及性能优化

    在本次课程中,将会就高通骁龙™开发者工具链、异构并行计算SDK、功耗优化SDK和性能分析工具进行深入浅出的介绍,帮忙开发者实现更高效的图形渲染和更低功耗,从而设计出更具表现力的游戏画面和更加稳定流畅的高帧率游戏。

    828 人正在学习 去看看 CSDN讲师

                          图像处理中的高通滤波与低通滤波

High pass filter

A high pass filter (HPF) is a filter that examines a region of an image and boosts

the intensity of certain pixels based on the difference in the intensity with the

surrounding pixels.

Take, for example, the following kernel:

[[0, -0.25, 0],

[-0.25, 1, -0.25],

[0, -0.25, 0]]

 

After calculating the sum of differences of the intensities of the central pixel

compared to all the immediate neighbors, the intensity of the central pixel will be

boosted (or not) if a high level of changes are found. In other words, if a pixel stands

out from the surrounding pixels, it will get boosted.

This is particularly effective in edge detection, where a common form of HPF called

high boost filter is used.

 

Here, the pixel of interest has a weight of 9 and its immediate neighbors each

have a weight of -1. For the pixel of interest, the output color will be nine times

its input color minus the input colors of all eight adjacent pixels. If the pixel

of interest is already a bit different from its neighbors, this difference becomes

intensified. The effect is that the image looks sharper as the contrast between the

neighbors is increased.

 

Note that both filters sum up to 0, the reason for this is

explained in detail in the Edge detection section.

If we modify a sharpening kernel slightly so that its weights sum up to 0 instead, we have an edge detection kernel that turns edges white and non-edges black.

array([[-1, -1, -1],

[-1, 9, -1],

[-1, -1, -1]])

这个模板其权重之和为1.在图像非高频部分作用于该模板之后,中心像素所得的灰度值总是非零灰度值,和周边像素一样;而高频部分作用于改模板之后,中心像素的灰度值得到了增强,但也是非零灰度值。对于查找边缘或锐化而言,是无法区分图像的边缘或图像的高频部分。

 

所以,修改该模板使得其权重之和为0.这样边缘部分经过该模板之后,中心像素变成白色或者说有灰度值;非边缘部分经过该模板卷积之后,中心像素的灰度值变为0,这样就可以很好的区别边缘和非边缘部分了。2019.1.11

 

Low pass filter

If an HPF boosts the intensity of a pixel, given its difference with its neighbors, a

low pass filter (LPF) will smoothen the pixel if the difference with the surrounding

pixels is lower than a certain threshold. This is used in denoising and blurring. For

example, one of the most popular blurring/smoothening filters, the Gaussian blur,

is a low pass filter that attenuates the intensity of high frequency signals.

Take, for example, the following kernel:

\frac{1}{9}\begin{bmatrix} 1 1 1\\ 1 1 1\\ 1 1 1 \end{bmatrix}

以上是均值滤波模板,各个权重权重值都相等。对于高斯滤波而言,模板中靠近中心像素的权重值比远离中心像素的权重值要大,但是其所有权重值相加之后也应该也是为1.因为高斯滤波作为低通滤波器而言,仍然需要将中心像素灰度值向邻域内的像素的灰度值靠拢。

 

图像中的边缘、细节部分属于图像的高频信息;图像的非边缘、细节部分属于图像的低频信息。高通滤波器的作用顾名思义,就是可以让高频信号通过的滤波器,低通滤波器就是让低频信号通过的滤波器。

 

在上述高通滤波器模板中,如果中心像素的灰度值大于邻域内其他像素,那么中心像素通过高通滤波器之后其灰度值将被增加;反之,低通滤波器中,如果中心像素的灰度值大于邻域其他像素的灰度值,那么中心像素的灰度值将会向周边邻域内像素灰度值大小靠拢。

 

2017-10-12 22:29:27 GoodShot 阅读数 2484
  • 高通骁龙™开发者工具链介绍及性能优化

    在本次课程中,将会就高通骁龙™开发者工具链、异构并行计算SDK、功耗优化SDK和性能分析工具进行深入浅出的介绍,帮忙开发者实现更高效的图形渲染和更低功耗,从而设计出更具表现力的游戏画面和更加稳定流畅的高帧率游戏。

    828 人正在学习 去看看 CSDN讲师

高通滤波:边缘提取与增强

低通滤波:边缘平滑

边缘区域的灰度变换加大,也就是频率较高。所以,对于高通滤波,边缘部分将被保留,非边缘部分将被过滤;对于低通滤波,边缘区域将被平滑过渡。

2019-10-26 17:34:40 wujuxKkoolerter 阅读数 152
  • 高通骁龙™开发者工具链介绍及性能优化

    在本次课程中,将会就高通骁龙™开发者工具链、异构并行计算SDK、功耗优化SDK和性能分析工具进行深入浅出的介绍,帮忙开发者实现更高效的图形渲染和更低功耗,从而设计出更具表现力的游戏画面和更加稳定流畅的高帧率游戏。

    828 人正在学习 去看看 CSDN讲师

梯形高通滤波

梯形高通滤波器(TLPF)的传递函数如下:

$$
H(u,v) = 1 - \begin{cases}
1 & D(u,v) \lt D_0 \\
\frac{D(u,v) - D_1}{D_0-D_1} & D_0 \lt D(u,v) \leq D_1 \\
0 &D(u,v) > D_1
\end{cases}

\tag{18-1}

$$

Python语言实现的代码如下:

def trapezoidal_low_pass_kernel(img,D0=5,D1=10):
    assert img.ndim == 2
    r,c = img.shape[1],img.shape[0]
    u = np.arange(r)
    v = np.arange(c)
    u, v = np.meshgrid(u, v)
    low_pass = np.sqrt( (u-r/2)**2 + (v-c/2)**2 )

    idx = low_pass < D0
    idx2 = (low_pass >= D0) & (low_pass <= D1)
    idx3 = low_pass > D1

    low_pass[idx] = 1
    low_pass[idx2] = (low_pass[idx2] - D1) / (D1 - D0)
    low_pass[idx3] = 0

    return low_pass

def trapezoidal_high_pass_filter(img,D0=5,D1=15):
    assert img.ndim == 2
    gray = np.float64(img)
    kernel = 1 - trapezoidal_low_pass_kernel(img,D0,D1)
    gray_fft = np.fft.fft2(gray)
    gray_fftshift = np.fft.fftshift(gray_fft)
    dst = np.zeros_like(gray_fftshift)
    dst_filtered = kernel * gray_fftshift
    dst_ifftshift = np.fft.ifftshift(dst_filtered)
    dst_ifft = np.fft.ifft2(dst_ifftshift)
    dst = np.abs(np.real(dst_ifft))
    dst = np.clip(dst,0,255)
    return np.uint8(dst)

程序运行结果:

在这里插入图片描述

2019-02-22 16:42:03 qq_34725005 阅读数 500
  • 高通骁龙™开发者工具链介绍及性能优化

    在本次课程中,将会就高通骁龙™开发者工具链、异构并行计算SDK、功耗优化SDK和性能分析工具进行深入浅出的介绍,帮忙开发者实现更高效的图形渲染和更低功耗,从而设计出更具表现力的游戏画面和更加稳定流畅的高帧率游戏。

    828 人正在学习 去看看 CSDN讲师
import numpy as np
import cv2

def convert_2d(r):
    r_ext = np.zeros((r.shape[0] * 2, r.shape[1] * 2))
    for i in range(r.shape[0]):
        for j in range(r.shape[1]):
            r_ext[i][j] = r[i][j]
    # 傅里叶变换
    r_ext_fu = np.fft.fft2(r_ext)
    # 将低频信号移至中间,等效于在时域上对f(x,y)乘以(-1)^(m+n)
    r_ext_fu = np.fft.fftshift(r_ext_fu)

    # 截止频率
    d0 = 20
    n = 2
    # 频率域中心坐标
    center = (r_ext_fu.shape[0] // 2, r_ext_fu.shape[1] // 2)
    h = np.empty(r_ext_fu.shape)
    # 绘制滤波器
    for u in range(h.shape[0]):
        for v in range(h.shape[1]):
            duv = ((u - center[0]) ** 2 + (v - center[1]) ** 2) ** 0.5
            if duv == 0:
                h[u][v] = 0
            else:
                h[u][v] = 1/((1+(d0/duv))**(2*n))

    s_ext_fu = r_ext_fu * h
    s_ext = np.fft.ifft2(np.fft.ifftshift(s_ext_fu))
    s_ext = np.abs(s_ext)
    s = s_ext[0:r.shape[0], 0:r.shape[1]]

    for i in range(s.shape[0]):
        for j in range(s.shape[1]):
            s[i][j] = min(max(s[i][j], 0), 255)
    return s.astype(np.uint8)

def convert_3d(r):
    s_dsplit = []
    for d in range(r.shape[2]):
        rr = r[:, :, d]
        ss = convert_2d(rr)
        s_dsplit.append(ss)
    s = np.dstack(s_dsplit)
    return s

im = cv2.imread('tetet.jpg')
im_converted_mat = convert_3d(im)
cv2.imshow('ditong', im_converted_mat)
cv2.imwrite('ditong4.jpg', im_converted_mat)
cv2.waitKey()

在这里插入图片描述
在这里插入图片描述

2019-10-26 17:29:50 wujuxKkoolerter 阅读数 72
  • 高通骁龙™开发者工具链介绍及性能优化

    在本次课程中,将会就高通骁龙™开发者工具链、异构并行计算SDK、功耗优化SDK和性能分析工具进行深入浅出的介绍,帮忙开发者实现更高效的图形渲染和更低功耗,从而设计出更具表现力的游戏画面和更加稳定流畅的高帧率游戏。

    828 人正在学习 去看看 CSDN讲师

理想高通滤波

H(u,v)={0,D(u,v)D01,D(u,v)>D0(14-1) H(u,v) = \begin{cases} 0 &, D(u,v) \leq D_0 \\ 1 &, D(u,v) \gt D_0 \end{cases} \tag{14-1}

式中的D(u,v)D(u,v)表达为:

D(u,v)=(uP2)2+(vQ2)2(14-2) D(u,v) = \sqrt{(u - \frac{P}{2})^2+(v - \frac{Q}{2})^2} \tag{14-2}

Python语言实现如下:

def high_pass_kernel(img,cut_off):
   
    assert img.ndim == 2
    r,c = img.shape[1],img.shape[0]
    u = np.arange(r)
    v = np.arange(c)
    u, v = np.meshgrid(u, v)
    low_pass = np.sqrt( (u-r/2)**2 + (v-c/2)**2 )

    low_pass[low_pass <= cut_off] = 1
    low_pass[low_pass > cut_off] = 0

    return low_pass

def high_pass(src,D0=5):
    assert src.ndim == 2
    kernel = high_pass_kernel(src,D0)
    gray = np.float64(src)
    gray_fft = np.fft.fft2(gray)
    gray_fftshift = np.fft.fftshift(gray_fft)
    dst = np.zeros_like(gray_fftshift)
    dst_filtered = kernel * gray_fftshift
    dst_ifftshift = np.fft.ifftshift(dst_filtered)
    dst_ifft = np.fft.ifft2(dst_ifftshift)
    dst = np.abs(np.real(dst_ifft))
    dst = np.clip(dst,0,255)
    return np.uint8(dst)

程序运行结果如下:

在这里插入图片描述

没有更多推荐了,返回首页