matlab sigma编程求助,想要编一个输入G,就可以输出sigma值的程序

用MATLAB编程:使用for函数编写一个程序实现sum(A)的功能,其中A为矩阵。急求???_百度知道
用MATLAB编程:使用for函数编写一个程序实现sum(A)的功能,其中A为矩阵。急求???
提问者采纳
m)[N;for n = 1:M
a = a + A(n;a = 0:N
for m = 1,M]=size(A)
??? Undefined function or variable 'A'.??? Undefined function or variable &A&.不行啊
有错误 老兄快改过来
提问者评价
我知道改了
收了你答案
其他类似问题
matlab的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁matlab处理噪声的问题我用的是Sigma平滑滤波器原理:构造一个5×5大小模板,计算模板的标准差σ,置信区间为当前像素值的±2σ范围。将模板中落在置信范围内的像素的均值替换原来的像素值。写出如下程序:image=_百度作业帮
matlab处理噪声的问题我用的是Sigma平滑滤波器原理:构造一个5×5大小模板,计算模板的标准差σ,置信区间为当前像素值的±2σ范围。将模板中落在置信范围内的像素的均值替换原来的像素值。写出如下程序:image=
我用的是Sigma平滑滤波器原理:构造一个5×5大小模板,计算模板的标准差σ,置信区间为当前像素值的±2σ范围。将模板中落在置信范围内的像素的均值替换原来的像素值。写出如下程序:image=imread('trees.tif');[m,n]=size(image);image1=imnoise(image,'Gaussian',0,0.002);
% 加高斯噪声image1=imnoise(image,'salt & pepper',0.01); %加椒盐噪声image1=double(image1); figure,imagesc(image1);image2=image1;for i=3:m-2
for j=3:n-2
temp=image1(i-2:i+2,j-2:j+2);
sig=std(temp);
min=round(image1(i,j)-2*sig);
max=round(image1(i,j)+2*sig);
if min < image1(k,l) && image1(k,l) < max
sum=sum+image1(k,l);
equ=sum/q;
equ=round(equ);
image2(i,j)=
endendfigure,imagesc(image2);运行之后出现:??? Operands to the || and && operators must be convertible to logical scalar values.请问而问题处在哪里?应该如何做,请写出正确的程序。“&”这个也试过,运行后matlab就不反应了,郁闷。终于做出个正确的出来了:image=imread('bacteria.tif');[m,n]=size(image);image1=imnoise(image,'Gaussian',0,0.002);
% 加高斯噪声image1=double(image1); figure,imagesc(image1),colormap(gray);image2=image1;for i=3:m-2
for j=3:n-2
temp=image1(i-2:i+2,j-2:j+2);
sig=std(temp(:));
Xmin=round(image1(i,j)-2*sig);
Xmax=round(image1(i,j)+2*sig);
temp1=zeros(5,5);
俺茶饭不思,辗转反侧多年,程序如下:%高斯噪声下的滤波image=imread('bacteria.tif');[m,n]=size(image);image1=imnoise(image,'Gaussian',0,0.002);
%加高斯噪声image1=double(image1);
%将uint8转换成双精度figure,imagesc(image1),colormap(gray) %显示滤波前的图像%Sigma滤波image2=image1;for i=3:m-2
for j=3:n-2
temp=image1(i-2:i+2,j-2:j+2);
q=std(temp(:));
max=image1(i,j)+2*q;
min=image1(i,j)-2*q;
temp1=zeros(5,5);
if temp2(r,s)=min
temp1(r,s)=temp2(r,s);
temp1(r,s)=0;
tem=sum(temp1(:))/t;
image2(i,j)=
endend %做5×5的模板,计算模板的标准差σ,置信区间为当前像素值的±2σ范围。将模板中落在置信范围内的像素的均值替换原来的像素值figure,imagesc(image2),colormap(gray) %显示滤波后的图像加分!
具体的内容(算法)没有细看,看到你的运行错误,是说(你的那个if语句中):MATLAB里面与、或操作应当是&、|而不是&&、||优化设计Matlab编程作业_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
&&&#165;1.00
&&&#165;2.00
喜欢此文档的还喜欢
优化设计Matlab编程作业
优&#8203;化&#8203;设&#8203;计&#8203;M&#8203;a&#8203;t&#8203;l&#8203;a&#8203;b&#8203;编&#8203;程&#8203;作&#8203;业&#8203; &#8203; &#8203;约&#8203;束&#8203;设&#8203;计&#8203;,&#8203;非&#8203;约&#8203;束&#8203;设&#8203;计
阅读已结束,如果下载本文需要使用
想免费下载本文?
把文档贴到Blog、BBS或个人站等:
普通尺寸(450*500pix)
较大尺寸(630*500pix)
你可能喜欢&& 查看话题
【分享】自已编的matlab图像处理程序(不断增加中),和大家一起交流.
看了一些图像处理的书籍和文献,对基本算法思路有了一些认识,但一直没编程实验过这些算法,现在想实际动手做做,结果发现编程对于我这个没有多少编程经验的初学者来说还是有难度的,就从最基本的开始练习吧,希望大家能帮我提出程序中的不合理之处。
------------------------------------------------------------------------------------------------------
% 中值滤波
function y=ghwmedfilt2(g,m,n)
% 定义中值滤波函数名为‘ghwmedfilt2’,g为待滤波的含噪图像,m、n是滤波窗口大小
if nargin==0 | nargin>3
& &&&error('输入的参数不对')
elseif nargin==1
& & m=3;n=3;
elseif nargin==2
r=floor(m/2);
c=floor(n/2);
gp=padarray(g,,'symmetric');
% 对图像g的边界进镜像反射扩展
% 计算图像g的尺寸
uint8 y=zeros(M,N);
%创建处理后图像
funBox=zeros(m,n);
temp=zeros(m*n);
for i=r+1:M+r
& & for j=c+1:N+c
& && &&&funBox=gp(i-r:i+r,j-c:j+c);
& && &&&temp=funBox(: );
& && &&&tempsort=sort(temp);
& && &&&y(i-r,j-c)=tempsort(median(1:m*n));
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
% 计算峰值信噪比PSNR
function y=ghwpsnr(im1,im2)
% im1和im2为两幅大小相等的图像,y为计算后的峰值信噪比输出
if (size(im1))~=(size(im2))
& & error('错误:两幅输入图像的尺寸不一致')
elseif im1==im2
& & error('两幅输入图像相同,PSNR将为无穷大')
=size(im1);
m1=double(im1);
m2=double(im2);
MSE=(sum(sum((m1-m2).^2)))/(M*N);
% 计算两幅图像的均方差
y=10*log10(255^2/MSE);
----------------------------------------------------------------------------------------------------
% 误检率和漏检率
function =ghwwl(f,fn,g)
% 定义计算误检率和漏检率的函数名为‘ghwwl’,=ghwwl(f,fn,g),f为原始图像,fn为噪声图像,g为滤波图像
% 误检率为本身未受到噪声的污染、而检测算法却误将其判为噪声的像素数与实际噪声像素数的比值
% 漏检率为未被检测出的噪声像素数与实际噪声像素数的比值
n=(fn-f)~=0;&&% 计算噪声矩阵
sumn=sum(n(: ));&&% 计算噪声数
wn=(((g-f)~=0)|n)&(~n);&&% 计算被误检的像素标记矩阵
sumwn=sum(wn(: )); % 计算被误检的像素数
ln=n&(~(n&((g-f)~=0))); % 计算漏检的像素标记矩阵
sumln=sum(ln(: )); % 计算漏检的噪声像素数
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
:rol::rol: 值得学习一下 支持楼主,学习图像处理,就是从编写小处理程序做起,更好的理解处理的算法. 我也正在学习中。。
建议楼主在每段程序前给予功能、算法、结构、参数等方面简单说明,有利于其他人在读具体语句前先初步了解程序,以及在读程序时便于理解。否则只有一堆代码放在那里,即使有注释,也会让想读的人却步! 有没有图像压缩方面的? Originally posted by yidday at
有没有图像压缩方面的? 没有,我现在在做椒盐噪声去噪.编了很多文献的去噪算法. Originally posted by 莫非是我 at
没有,我现在在做椒盐噪声去噪.编了很多文献的去噪算法. 楼主可用去噪方面的程序?
请教,如何在灰度图像中加噪声
我知道这是个比较基本的问题比如
randn('seed',init);
x=X+18*randn(size(X));
这是加随机噪声
但是我想加高斯白噪声,请问怎么加? Originally posted by 莫非是我 at
看了一些图像处理的书籍和文献,对基本算法思路有了一些认识,但一直没编程实验过这些算法,现在想实际动手做做,结果发现编程对于我这个没有多少编程经验的初学者来说还是有难度的,就从最基本的开始练习吧,希望 ... lz这就没信了? 下面是我在网上看到的一些内容,看看合不合适你:
注意其中的一句:
J = imnoise(I,'gaussian',m,v) adds Gaussian white noise of mean m and variance v to the image I. The default is zero mean noise with 0.01 variance.
Add noise to image
J = imnoise(I,type)
J = imnoise(I,type,parameters)
J = imnoise(I,'gaussian',m,v)
J = imnoise(I,'localvar',V)
J = imnoise(I,'localvar',image_intensity,var)
J = imnoise(I,'poisson')
J = imnoise(I,'salt & pepper',d)
J = imnoise(I,'speckle',v)
Description
J = imnoise(I,type) adds noise of a given type to the intensity image I. type is a string that can have one of these values.
Description
'gaussian'
Gaussian white noise with constant mean and variance
'localvar'
Zero-mean Gaussian white noise with an intensity-dependent variance
Poisson noise
'salt & pepper'
On and off pixels
Multiplicative noise
J = imnoise(I,type,parameters) Depending on type, you can specify additional parameters to imnoise. All numerical param they correspond to operations with images with intensities ranging from 0 to 1.
J = imnoise(I,'gaussian',m,v) adds Gaussian white noise of mean m and variance v to the image I. The default is zero mean noise with 0.01 variance.
J = imnoise(I,'localvar',V) adds zero-mean, Gaussian white noise of local variance V to the image I. V is an array of the same size as I.
J = imnoise(I,'localvar',image_intensity,var) adds zero-mean, Gaussian noise to an image I, where the local variance of the noise, var, is a function of the image intensity values in I. The image_intensity and var arguments are vectors of the same size, and plot(image_intensity,var) plots the functional relationship between noise variance and image intensity. The image_intensity vector must contain normalized intensity values ranging from 0 to 1.
J = imnoise(I,'poisson') generates Poisson noise from the data instead of adding artificial noise to the data. If I is double precision, then input pixel values are interpreted as means of Poisson distributions scaled up by 1e12. For example, if an input pixel has the value 5.5e-12, then the corresponding output pixel will be generated from a Poisson distribution with mean of 5.5 and then scaled back down by 1e12. If I is single precision, the scale factor used is 1e6. If I is uint8 or uint16, then input pixel values are used directly without scaling. For example, if a pixel in a uint8 input has the value 10, then the corresponding output pixel will be generated from a Poisson distribution with mean 10.
J = imnoise(I,'salt & pepper',d) adds salt and pepper noise to the image I, where d is the noise density. This affects approximately d*numel(I) pixels. The default for d is 0.05.
J = imnoise(I,'speckle',v) adds multiplicative noise to the image I, using the equation J = I+n*I, where n is uniformly distributed random noise with mean 0 and variance v. The default for v is 0.04.
Note& &The mean and variance parameters for 'gaussian', 'localvar', and 'speckle' noise types are always specified as if the image were of class double in the range . If the input image is of class uint8 or uint16, the imnoise function converts the image to double, adds noise according to the specified type and parameters, and then converts the noisy image back to the same class as the input.
Class Support
For most noise types, I can be of class uint8, uint16, int16, single, or double. For Poisson noise, int16 is not allowed. The output image J is of the same class as I. If I has more than two dimensions it is treated as a multidimensional intensity image and not as an RGB image.
I = imread('eight.tif');
J = imnoise(I,'salt & pepper',0.02);
figure, imshow(I)
figure, imshow(J)
rand , randn&&in the MATLAB Function Reference Originally posted by 莫非是我 at
没有,我现在在做椒盐噪声去噪.编了很多文献的去噪算法. 下面是我在网上看到的一些内容,看看合不合适你:
注意其中的一句:
J = imnoise(I,'gaussian',m,v) adds Gaussian white noise of mean m and variance v to the image I. The default is zero mean noise with 0.01 variance.
Add noise to image
J = imnoise(I,type)
J = imnoise(I,type,parameters)
J = imnoise(I,'gaussian',m,v)
J = imnoise(I,'localvar',V)
J = imnoise(I,'localvar',image_intensity,var)
J = imnoise(I,'poisson')
J = imnoise(I,'salt & pepper',d)
J = imnoise(I,'speckle',v)
Description
J = imnoise(I,type) adds noise of a given type to the intensity image I. type is a string that can have one of these values.
Description
'gaussian'
Gaussian white noise with constant mean and variance
'localvar'
Zero-mean Gaussian white noise with an intensity-dependent variance
Poisson noise
'salt & pepper'
On and off pixels
Multiplicative noise
J = imnoise(I,type,parameters) Depending on type, you can specify additional parameters to imnoise. All numerical param they correspond to operations with images with intensities ranging from 0 to 1.
J = imnoise(I,'gaussian',m,v) adds Gaussian white noise of mean m and variance v to the image I. The default is zero mean noise with 0.01 variance.
J = imnoise(I,'localvar',V) adds zero-mean, Gaussian white noise of local variance V to the image I. V is an array of the same size as I.
J = imnoise(I,'localvar',image_intensity,var) adds zero-mean, Gaussian noise to an image I, where the local variance of the noise, var, is a function of the image intensity values in I. The image_intensity and var arguments are vectors of the same size, and plot(image_intensity,var) plots the functional relationship between noise variance and image intensity. The image_intensity vector must contain normalized intensity values ranging from 0 to 1.
J = imnoise(I,'poisson') generates Poisson noise from the data instead of adding artificial noise to the data. If I is double precision, then input pixel values are interpreted as means of Poisson distributions scaled up by 1e12. For example, if an input pixel has the value 5.5e-12, then the corresponding output pixel will be generated from a Poisson distribution with mean of 5.5 and then scaled back down by 1e12. If I is single precision, the scale factor used is 1e6. If I is uint8 or uint16, then input pixel values are used directly without scaling. For example, if a pixel in a uint8 input has the value 10, then the corresponding output pixel will be generated from a Poisson distribution with mean 10.
J = imnoise(I,'salt & pepper',d) adds salt and pepper noise to the image I, where d is the noise density. This affects approximately d*numel(I) pixels. The default for d is 0.05.
J = imnoise(I,'speckle',v) adds multiplicative noise to the image I, using the equation J = I+n*I, where n is uniformly distributed random noise with mean 0 and variance v. The default for v is 0.04.
Note& &The mean and variance parameters for 'gaussian', 'localvar', and 'speckle' noise types are always specified as if the image were of class double in the range . If the input image is of class uint8 or uint16, the imnoise function converts the image to double, adds noise according to the specified type and parameters, and then converts the noisy image back to the same class as the input.
Class Support
For most noise types, I can be of class uint8, uint16, int16, single, or double. For Poisson noise, int16 is not allowed. The output image J is of the same class as I. If I has more than two dimensions it is treated as a multidimensional intensity image and not as an RGB image.
I = imread('eight.tif');
J = imnoise(I,'salt & pepper',0.02);
figure, imshow(I)
figure, imshow(J)
rand , randn&&in the MATLAB Function Reference 谢谢楼主整合的好东西,THX! 按照自己的理解 把算法予以编程实现 才会更加深刻的理解和掌握该方法 搞科研搞科研 是要动手的 : Originally posted by liuhuidd623 at
楼主可用去噪方面的程序?
请教,如何在灰度图像中加噪声
我知道这是个比较基本的问题比如
randn('seed',init);
x=X+18*randn(size(X));
这是加随机噪声
但是我想加高斯白噪声,请问 ... %加入噪声,生成噪声图像
sigma =30;
Noisyim = GWNoisy2(im,30);
这个就是加入方差为30 的高斯白噪声 有没有关于Curvelet变换的代码,学习一下 楼主有没有CT模拟投影数据的? :victory::work:
var cpro_id = 'u1216994';
欢迎监督和反馈:本帖内容由
提供,小木虫仅提供交流平台,不对该内容负责。欢迎协助我们监督管理,共同维护互联网健康,如果您对该内容有异议,请立即发邮件到
联系通知管理员,也可以通过QQ周知,我们的QQ号为:8835100
我们保证在1个工作日内给予处理和答复,谢谢您的监督。
小木虫,学术科研第一站,为中国学术科研研究提供免费动力
广告投放请联系QQ: &
违规贴举报删除请联系邮箱: 或者 QQ:8835100
Copyright &
eMuch.net, All Rights Reserved. 小木虫 版权所有Matlab编程及应用――绘图和数据可视化_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
文档贡献者
评价文档:
喜欢此文档的还喜欢
Matlab编程及应用――绘图和数据可视化
把文档贴到Blog、BBS或个人站等:
普通尺寸(450*500pix)
较大尺寸(630*500pix)
大小:3.80MB
登录百度文库,专享文档复制特权,财富值每天免费拿!
你可能喜欢}

我要回帖

更多关于 matlab编程实例 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信