一个matlab数字图像处理程序的解释

clc;                                                   %clc是清除command window里的内容
clear all; %clear是清除workspace里的变量
close all; %close all来关闭所有已经打开的图像窗口
image_ori = imread('skeleton_orig.bmp'); %读取图像数据
image_ori = rgb2gray(image_ori); % 将rgb模式转换成灰度图
figure; %画图
subplot(,,); %把区域分成2行4列,并把图像显示到第一个
imshow(image_ori); %显示图像
title('a.original image'); %显示标题
image_ext = [zeros(,);image_ori;zeros(,)]'; %分别在上下两边加一行,并转置
image_ext = [zeros(,);image_ext;zeros(,);]'; %分别在左右两边加一列,并转置
image_double = im2double(image_ext); %将imdata_add转换成双精度 % lapa_modelace Operating
lapa_mode = [-,-,-;-,,-;-,-,-]; %拉普拉斯变换用模板[-,-,-;-,,-;-,-,-];
lapa_mode = lapa_mode(:); %转换成列矩阵
for x = ::
for y = ::
A =image_double([x-:x+],[y-:y+]); %从image_double中以(x,y)为中心取出一个3*3的矩阵
image_lapa(x-,y-) = lapa_mode'*A(:); %将取出的矩阵与模板进行拉普拉斯变换取得的值放在image_lapa的(x-1,y-1)位置
end
end
subplot(,,);
imshow(image_lapa);
title('b.lapalace image');
subplot(,,); %Sharpening Operating
image_ab_sha = image_lapa+im2double(image_ori);
imshow(image_ab_sha);
title('c.a+b sharpening image'); %Grads Operating
sobel_mode_1= [-,-,-;,,;,,]; %定义梯度处理的一个掩膜
sobel_mode_1= sobel_mode_1(:);
sobel_mode_2 = [-,,;-,,;-,,]; %定义梯度处理的另一个掩膜
sobel_mode_2 = sobel_mode_2(:);
for x = ::
for y = ::
A =image_double([x-:x+],[y-:y+]);
mid_1(x-,y-) = sobel_mode_1'*A(:);
mid_2(x-,y-) = sobel_mode_2'*A(:);
end
end
image_grad = abs(mid_1)+abs(mid_2); %对gx、gy绝对值化,然后求和
subplot(,,);
imshow(image_grad);
title('d.grads image'); %Smoothing Operating
Mxy_Ext = [zeros(,);image_grad;zeros(,)]; %分别在上下两边加两行
Mxy_Ext = [zeros(,);Mxy_Ext';zeros(2,804)]'; %先将Mxy_Ext转置,然后分别在左右两边加一列,最后将所得结果再转置
Linear_smooth = ones(,); %创建一个5*5矩阵,初始值全是1
Linear_smooth = Linear_smooth(:); %将矩阵Linear_smooth转换成列矩阵
for x = :: %大循环,x从3--,步进是1
for y = :: %小循环,y从3--,步进是1
A = Mxy_Ext([x-:x+],[y-:y+]); %以Emx_Ext(x,y)为中心,截取5*5矩阵复制到A中
image_smooth(x-,y-) = Linear_smooth'*A(:); %将获取的矩阵值各个值求和然后放在新矩阵image_smooth的(x-2,y-2)位置
end
end
image_smooth = image_smooth/; %求平均值
subplot(,,); %把区域分成1行4列,并把图像显示到第一个
imshow(image_smooth); %显示图像
title('e.smoothing image'); %显示标题 %Masking Operating
image_mask = image_ab_sha.*image_smooth; %点乘
subplot(,,);
imshow(image_mask);
title('f.Masking image'); %Sharpening Operating
image_af_sha = im2double(image_ori) + image_mask;
subplot(,,);
imshow(image_af_sha);
title('g.a+f sharpening image'); %Exponential Transform
image_fin = image_af_sha.^0.5; %幂律变换
subplot(,,);
imshow(image_fin);
title('h.final result');
上一篇:主数据管理(MDM)的6大层级简述,你不可不知的数据治理参考!


下一篇:数控AGC实现(转)