Convolution Filter


转载http://www.roborealm.com/help/Convolution.php

Convolution filters are a great way to process images for certain features. Features are defined by an n by m matrix that is applied to the image in the following way: (grayscale only for purposes of example)

Interface

Convolution Filter - chqj_163 - chqj_163 的博客

Instructions

1. Kernal - Edit the 5x5 textbox grid to add in your convolution values OR

2. Dropdown - Select a pre-created filter using the dropdown menu to help you get started

3. Divisor/Bias - Specify the divisor and/or bias. The result of the kernal above will be divided by the divisor to help keep the pixel within the 0 to 255 range. The bias will be added to the result to also keep it within the positive 0 to 255 range.

Example

SourceSharpen More
Convolution Filter - chqj_163 - chqj_163 的博客Convolution Filter - chqj_163 - chqj_163 的博客

An example small grayscale image (10x10):

342277482372052921210741
501507715823325111216547229
9307721943564211314094
3219443036941511012884
10904873631481591839922
19270278820230533438106
23920219620550123192884137
2301741422127100189186214187
227861956531684616636249
215165237110125191191941238

An example convolution filter for line detection:

-1-1-1
-18-1
-1-1-1

The row=2, column=2 pixel and its neighborhood from the image above: The row=2, column=2 pixel and its neighborhood from the image above:

342277
5015077
93077

To apply the convolution filter multiply the filter values with the image data block. Work with each pixel and its 3x3 neighborhood:

-1*34-1*22-1*77
-1*508*150-1*77
-1*93-1*0-1*77

Then sum all the values:
(-34)+(-22)+(-77)+
(-50)+(1200)+(-77)+
(-93)+(0)+(-77) = 770

Divide by the divisor and add the bias.
(770/divisor)+bias=770 (in this example divisor=1, bias=0)

If the new pixel value is > 255 set it to 255
If the new pixel value is < 0 set it to 0

The new pixel value is 255. Store that in a new image:

342277
5025577
93077

Continue with all other 3x3 blocks in the image using original values. For example the next image block could be

227748
15077158
077219

Note the 3x3 "window" is shifted to the right by one and that the new pixel value is NOT used but stored as a second new image.

Most of the image is processed in this manner. Image borders create problems and are ignored.

Many other filters can easily be defined for other purposes

Blur:

111    121
111    242
111    121

Sharpen:

-1-1-1    0-10
-19-1    -15-1
-1-1-1    0-10

Edge Enhancement:

000    0-10    -100
-110    010    010
000    000    000

Find Edges:

010    -1-1-1    1-21
1-41    -18-1    -24-2
010    -1-1-1    1-21

Emboss:

-2-10
-111
012
The convolution matrix is displayed in the convolution interface. Changing any number will alter the matrix and change the image as a result of applying that matrix.

Select a matrix from the pull down menu which will populate the matrix with those values.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值