求大神翻译下列Matlab语句啊(最好每句都翻译啊).clear;tic;imgname='1.bmp';wavename='haar'; mode='per';[x,map]=imread(imgname); figure(1);subplot(2,2,1);imshow(x);title('原图');r=x; xx=histeq(r); subplot(2,2,2);im

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/09 10:07:37
求大神翻译下列Matlab语句啊(最好每句都翻译啊).clear;tic;imgname='1.bmp';wavename='haar';   mode='per';[x,map]=imread(imgname); figure(1);subplot(2,2,1);imshow(x);title('原图');r=x;                xx=histeq(r); subplot(2,2,2);im

求大神翻译下列Matlab语句啊(最好每句都翻译啊).clear;tic;imgname='1.bmp';wavename='haar'; mode='per';[x,map]=imread(imgname); figure(1);subplot(2,2,1);imshow(x);title('原图');r=x; xx=histeq(r); subplot(2,2,2);im
求大神翻译下列Matlab语句啊(最好每句都翻译啊).
clear;
tic;
imgname='1.bmp';
wavename='haar';
mode='per';
[x,map]=imread(imgname);
figure(1);
subplot(2,2,1);imshow(x);
title('原图');
r=x;
xx=histeq(r);
subplot(2,2,2);imshow(xx);
title('增强后的图像');
deccof=struct('ca',[],'ch',[],'cv',[],'cd',[]);
reccof=struct('rx',[]);
sx=size(xx);
nbcol=size(map,1);
dx=xx;
deccof(1).ca=xx;
[deccof(2).ca,deccof(2).ch,deccof(2).cv,deccof(2).cd]=dwt2(dx,wavename,'mode',mode);
figure(2);imshow([deccof(2).ca/255,deccof(2).ch/255;deccof(2).cv/255,deccof(2).cd/255;]);
title('小波分解');
am=deccof(2).ca/255;
figure(1);
subplot(2,2,3);imshow(am);
title('近似分量');
L=size(am,1);
W=size(am,2);
N=L*W;
[Count Ret]=imhist(am);
Pi=Count'./N;
g=[];
for t=0:255
w0=sum(Pi(1:t+1));
w1=1-w0;
mu0=sum(Pi(1:t+1).*(0:t))/w0;
mu1=sum(Pi(t+2:256).*(t+1:255))/w1;
mu=sum(Pi(1:256).*(0:255));
g=[g w0*w1*(mu0-mu1)^2/(w1*(mu0-mu)^2+w0*(mu1-mu)^2)];
end
[Ret1 T ]=max(g);
T1=T;
T=num2str(T-1);
disp(['最佳灰度threhold: ' T]);
I1=im2bw(am,T1/255);
figure(1),subplot(2,2,4);imshow(I1);
title('阈值分割后的图像');
u=idwt2(I1,deccof(2).ch/127,deccof(2).cv/127,deccof(2).cd/127,wavename,'mode',mode);
figure(3),imshow(u);title('小波分割图像')

求大神翻译下列Matlab语句啊(最好每句都翻译啊).clear;tic;imgname='1.bmp';wavename='haar'; mode='per';[x,map]=imread(imgname); figure(1);subplot(2,2,1);imshow(x);title('原图');r=x; xx=histeq(r); subplot(2,2,2);im
clear; %清除所有变量
tic; %保存当前时间,再用toc来记录完成时间,以此计算程序运行时间
imgname='1.bmp'; %待处理图像文件名
wavename='haar'; %小波基函数
mode='per'; %小波变换模式 periodization
[x,map]=imread(imgname); %读入图像,像素值在x中,颜色映射表在map中
figure(1); %绘图窗口1
subplot(2,2,1);imshow(x); %绘图窗口1分为2x2,在第一部分显示读入的图像
title('原图'); %绘图标题
r=x; %复制一份图像数据
xx=histeq(r); %图像直方图均衡化
subplot(2,2,2);imshow(xx); %在绘图窗口1的第二部分显示均衡化后的图像
title('增强后的图像'); %绘图标题
deccof=struct('ca',[],'ch',[],'cv',[],'cd',[]); %创建结构,用来保存小波变换结果
%ca:近似分量
%ch:水平细节分量
%cv:垂直细节分量
%cd:对角细节分量
reccof=struct('rx',[]); %创建结构
sx=size(xx); %获得图像大小
nbcol=size(map,1); %获得颜色映射表长度
dx=xx; %复制一份图像数据
deccof(1).ca=xx;
[deccof(2).ca,deccof(2).ch,deccof(2).cv,deccof(2).cd]=dwt2(dx,wavename,'mode',mode); %对图像dx进行二维离散小波变换
figure(2);imshow([deccof(2).ca/255,deccof(2).ch/255;deccof(2).cv/255,deccof(2).cd/255;]); %绘图窗口2,显示小波变换结果
title('小波分解'); %绘图标题
%绘图窗口1,第三部分绘制近似分量
am=deccof(2).ca/255;
figure(1);
subplot(2,2,3);imshow(am);
title('近似分量');
%对近似分量进行处理
L=size(am,1); %获得图像长度
W=size(am,2); %获得图像宽度
N=L*W; %像素点数
[Count Ret]=imhist(am); %获得图像的直方图,Count为直方图灰度级数量
Pi=Count'./N;
%以下计算各灰度级出现的概率
g=[];
for t=0:255
w0=sum(Pi(1:t+1));
w1=1-w0;
mu0=sum(Pi(1:t+1).*(0:t))/w0;
mu1=sum(Pi(t+2:256).*(t+1:255))/w1;
mu=sum(Pi(1:256).*(0:255));
g=[g w0*w1*(mu0-mu1)^2/(w1*(mu0-mu)^2+w0*(mu1-mu)^2)];
end
[Ret1 T ]=max(g); %获得灰度分布的峰值
T1=T;
T=num2str(T-1);
disp(['最佳灰度threhold:' T]);
I1=im2bw(am,T1/255); %以得到的灰度峰值作为阈值进行灰度变换
figure(1),subplot(2,2,4);imshow(I1); %绘图窗口第四部分显示该图像
title('阈值分割后的图像');
%灰度变换以后再进行小波反变换
u=idwt2(I1,deccof(2).ch/127,deccof(2).cv/127,deccof(2).cd/127,wavename,'mode',mode);
figure(3),imshow(u);title('小波分割图像') %显示反变换后得到的图像