对图象进行求反的matlab程序

对图象进行求反的matlab程序,第1张

好多人回答啊!

图像求反两种方法都可以

>> g1=imgdjust(f,[0 1],[1 0])%f为输入图像,此为第一种方法

>> g2=imcomplement(f)%f同样为输入图像,此为第二种方郑迅法

至于邻域均值嘛,主要肢丛激用 fspecial和imfilter 两个函数,具体可以看一下帮助 ^_^

下面的两个例子分别用正方形和圆形的模板进行邻域均值。

>>w1=fspecial('average') %产生一个3x3大小的方形平均滤波模板w1

>>g1=imfilter(f,w1,'replicate') % g1为处理后的图像。'replicate'指卷积填充边缘时用复制边界历袜的值来扩展。

>>w2=fspecial('disk') %产生一个半径为5的圆形平均滤波模板w2

>>g2=imfilter(f,w2,'replicate') % 同样,g2为处理后的图像,'replicate'指卷积填充边缘时用复制边界的值来扩展。

cd(g,k0,input)

% cnv¬_encd(g,k0,input)

% determines the output sequence of a binary convolutional encoder

% g is the generator matric of the convolutional code

% with n0 rows and l*k0 columns, Its rows are g1,g2….gn

% k0 is the number of bus entering the encoder at each clock cycle.

% input The binary input seq

g = [0 0 1 0 0 1 0 00 0 0 0 0 0 0 11 0 0 0 0 0 0 10 1 0 0 1 1 0 1]

k0 = 2

input=[10011100110000111]

Output=cnv_encd(g,k0,input)

% check to see if extra zero padding is necessary 看填充的0是否必须

if rem(length(input), k0) >0

input = [input, zeros(size(1:k0-rem(length(input),k0)))]

end

n = length(input)/k0% 把输入比特按k0分组,n为所得的组数。

% check the size of matrix g

if rem(size(g, 2), k0) >0

error('Error, g is not of the right size.')

end

% determine L and n0

L = size(g, 2)/k0

n0 = size(g, 1)

% add extra zeros,以启陆樱保证编码器是从悉者全0开始,并回到全0状态。

u = [zeros(size(1:(L-1)*k0)), input, zeros(size(1:(L-1)*k0))]

% generate uu, a matrix whose columns are the contents of conv. encoder at

% various clock cycles.

u1 = u(L*k0: -1 :1)

for i = 1:n+L-2

u1 = [u1, u((i+L)*k0:-1:i*k0+1)]

end

uu = reshape(u1, L*k0, n+L-1)

% determine the output

output = reshape(rem(g*uu, 2), 1, n0*(L+n-1))

len_tal = n0*(L + n - 1)

% write the output to the encodetext

result = fopen(encodetext, 'w'悄丛)

for i = 1:n0*(L+n -1)

fwrite(result, output(i), 'bit1')

end

fclose(result)

matlab中的deconv其实是在进行长除法运算。那么在无法除尽的情况下自然会有余数了,这个余数就是误差。

从另一个角度来看,v不一定能由u和某个数列进行拦型卷积得到(即:u和任何数列进行卷积都无法得到v),所以这里所得到的结果q其实是一个近似的结果,此时r可以看作误差。

deconv--反褶积多项式除法

【功能简介】求向量反褶积和进行多项式除法运算。

【语法格式】[q,r]=deconv(v,u)

参数q和r分别返回多项式v除以多项式u的商多项式和余多项式。

【实例3.33】求多项式(x2+2x+1)与多项式(2x2+x+3)的积,再求积与简慎猜(x2+2x+1)的商。

>>a=[1,2,1] >>孝凯 b=[2,1,3]

>>c=conv(a,b)%求多项式a、b的积

c = 2 5 7 7 3

>>d=deconv(c,a) %求积与a的商

d = 2 1 3


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12346797.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存