1.灰度变换增强程序:


% GRAY TRANSFORM
clc;
I=imread('pout.tif');
imshow(I);
J=imadjust(I,[0.3 0.7],[0 1],1);  %transforms the walues in the %intensity image I to values in J by linealy mapping %values between 0.3 and 0.7 to values between 0 and 1.
figure;
imshow(J);
J=imadjust(I,[0.3 0.7],[0 1],0.5);  % if GAMMA is less than 1,the  mapping si weighted toward higher (brighter)
%output values.
figure;
imshow(J);
J=imadjust(I,[0.3 0.7],[0 1],1.5);  % if GAMMA is greater than 1,the mapping si weighted toward lower (darker)
%output values.
figure;
imshow(J)
J=imadjust(I,[0.3 0.7],[0 1],1);  % If TOP<BOTTOM,the output image is reversed,as in a photographic negative.
figure;
imshow(J);

2.直方图灰度变换

%直方图灰度变换
[X,map]=imread('forest.tif');
I=ind2gray(X,map);%把索引图像转换为灰度图像
imshow(I);
title('原图像');
improfile%用鼠标选择一条对角线,显示线段的灰度值
figure;subplot(121)
plot(0:0.01:1,sqrt(0:0.01:1))
axis square
title('平方根灰度变换函数')
subplot(122)
maxnum=double(max(max(I)));%取得二维数组最大值
J=sqrt(double(I)/maxnum);%把数据类型转换成double,然后进行平方根变换
%sqrt函数不支持uint8类型
J=uint8(J*maxnum);%把数据类型转换成uint8类型
imshow(J)
title('平方根变换后的图像')

3.直方图均衡化程序举例

% HISTGRAM EAQUALIZATION
clc;
% Clear command window
I=imread('tire.tif');
% reads the image in tire.tif into I
imshow(I);
% displays the intensity image I with 256 gray levels
figure;
%creates a new figure window
imhist(I);
% displays a histogram for the intensity image I
J=histeq(I,64);
% transforms the intensity image I,returning J an intensity
figure;
%image with 64 discrete levels
imshow(J);
figure;
imhist(J);
J=histeq(I,32);
%transforms the intensity image ,returning in % J an intensity
figure;
%image with 32 discrete levels
imshow(J);
figure;
imhist(J);

4.直方图规定化程序举例

% HISTGRAM REGULIZATION
clc;
%Clear command window
I=imread('tire.tif');
%reads the image in tire.tif into I
J=histeq(I,32);
%transforms the intensity image I,returning in
%J an intensity image with 32 discrete levels
[counts,x]=imhist(J);
%displays a histogram for the intensity image I
Q=imread('pout.tif');
%reads the image in tire.tif into I
figure;
imshow(Q);
figure;
imhist(Q);
M=histeq(Q,counts);
%transforms the intensity image Q so that the
%histogram of the output image M approximately matches counts
figure;
imshow(M);
figure;
imhist(M);

空域滤波增强部分程序

1.线性平滑滤波
I=imread('eight.tif');
J=imnoise(I,'salt & pepper',0.02);
subplot(221),imshow(I)
title('原图像')
subplot(222),imshow(J)
title('添加椒盐噪声图像')
K1=filter2(fspecial('average',3),J)/255;%应用3*3邻域窗口法
subplot(223),imshow(K1)
title('3x3窗的邻域平均滤波图像')
K2=filter2(fspecial('average',7),J)/255;%应用7*7邻域窗口法
subplot(224),imshow(K2)
title('7x7窗的邻域平均滤波图像')
2.中值滤波器
MATLAB中的二维中值滤波函数medfit2来进行图像中椒盐躁声的去除
%IMAGE NOISE REDUCTION WITH MEDIAN FILTER
clc;
hood=3;%滤波窗口
[I,map]=imread('eight.tif');
imshow(I,map);
noisy=imnoise(I,'salt & pepper',0.05);
figure;
imshow(noisy,map);
filtered1=medfilt2(noisy,[hood hood]);
figure;
imshow(filtered1,map);
hood=5;
filtered2=medfilt2(noisy,[hood hood]);
figure;
imshow(filtered2,map);
hood=7;
filtered3=medfilt2(noisy,[hood hood]);
figure;
imshow(filtered3,map);
3. 4邻域8邻域平均滤波算法
% IMAGE NOISE REDUCTION WITH MEAN ALGORITHM
clc;
[I,map]=imread('eight.tif');
noisy=imnoise(I,'salt & pepper',0.05);
myfilt1=[0 1 0;1 1 1;0 1 0];%4邻域平均滤波模版
myfilt1=myfilt1/9;%对模版归一化
filtered1=filter2(myfilt1,noisy);
imshow(filtered1,map);
myfilt2=[1 1 1;1 1 1;1 1 1];
myfilt2=myfilt2/9;
filtered2=filter2(myfilt2,noisy);
figure;
imshow(filtered2,map);

频域增强程序举例

1.低通滤波器
% LOWPASS FILTER
clc;
[I,map]=imread('eight.tif');
noisy=imnoise(I,'gaussian',0.05);
imshow(noisy,map);
myfilt1=[1 1 1;1 1 1;1 1 1];
myfilt1=myfilt1/9;
filtered1=filter2(myfilt1,noisy);
figure;
imshow(filtered1,map);
myfilt2=[1 1 1;1 2 1;1 1 1];
myfilt2=myfilt2/10;
filtered2=filter2(myfilt2,noisy);
figure;
imshow(filtered2,map);
myfilt3=[1 2 1;2 4 2; 1 2 1];
myfilt3=filter2(myfilt3,noisy);
figure;
imshow(filtered3,map);

2.布特沃斯低通滤波器图像实例
I=imread('saturn.png');
J=imnoise(I,'salt & pepper',0.02);
subplot(121),imshow(J)
title('含噪声的原图像')
J=double(J);
f=fft2(J);
g=fftshift(f);
[M,N]=size(f);
n=3;d0=20;
n1=floor(M/2);n2=floor(N/2);
for i=1:M;
for j=1:N;
d=sqrt((i-n1)^2+(j-n2)^2);
h=1/(1+0.414*(d/d0)^(2*n));
g(i,j)=h*g(i,j);
end
end
g=ifftshift(g);
g=uint8(real(ifft2(g)));
subplot(122),imshow(g)
title('三阶Butterworth滤波图像')

色彩增强程序举例

1.真彩色增强实例:
%真彩色图像的分解
clc;
RGB=imread('peppers.png');
subplot(221),imshow(RGB)
title('原始真彩色图像')
subplot(222),imshow(RGB(:,:,1))
title('真彩色图像的红色分量')
subplot(223),imshow(RGB(:,:,2))
title('真彩色图像的绿色分量')
subplot(224),imshow(RGB(:,:,3))
title('真彩色图像的蓝色分量')
2.伪彩色增强举例:
I=imread('cameraman.tif');
imshow(I);
X=grayslice(I,16);%thresholds the intensity image I using
%threshold values 1/16,2/16,…..,15/16,returning an indexed %image in X
figure;
imshow(X,hot(16));
 
3.假彩色增强处理程序举例
[RGB]=imread('ghost.bmp');
imshow(RGB);
RGBnew(:,:,1)=RGB(:,:,3);
RGBnew(:,:,2)=RGB(:,:,1);
RGBnew(:,:,3)=RGB(:,:,2);
figure;
subplot(121);
imshow(RGB);
subplot(122);
imshow(RGBnew);

MATLAB图像增强程序举例相关推荐

  1. 用matlab程序表示三角形序列,MATLAB程序举例带注释

    1.绘制云图 Ex=18 En=2 He=0.2 hold on for i=1:1000 Enn=randn(1)*He+En; x(i)=randn(1)*Enn+Ex; y(i)=exp(-(x ...

  2. MATLAB图像基本变换实验报告,MATLAB图像增强与变换处理实验报告

    实验一 MATLAB图像增强与变换处理实验 一.实验目的 1.熟悉掌握数字图像处理的基本概念. 2.了解MATLAB的的编程环境,图像处理工具箱的使用方法. 3.掌握数字图像处理图像增强的基本方法. ...

  3. matlab图像增强实验总结,图像处理实验报告

    以下为<图像处理实验报告>的无排版文字预览,完整格式请下载 下载前请仔细阅读文字预览以及下方图片预览.图片预览是什么样的,下载的文档就是什么样的. 图像处理实验报告 一.实验目的: 1.通 ...

  4. 图像处理边缘增强matlab,数字图像处理实验 matlab 图像增强 边缘检测 图像操作.doc...

    数字图像处理实验 matlab 图像增强 边缘检测 图像操作 实验1 点运算和直方图处理 实验目的 1. 掌握利用Matlab图像工具箱显示直方图的方法 2. 掌握运用点操作进行图像处理的基本原理. ...

  5. 三次固支样条matlab,matlab连续梁程序的编制与使用

    <matlab连续梁程序的编制与使用>由会员分享,可在线阅读,更多相关<matlab连续梁程序的编制与使用(21页珍藏版)>请在人人文库网上搜索. 1.第三章 连续梁程序的编制 ...

  6. matlab多元回归程序,多元回归程序MATLAB程序

    <多元回归程序MATLAB程序>由会员分享,可在线阅读,更多相关<多元回归程序MATLAB程序(45页珍藏版)>请在人人文库网上搜索. 1.程序MATLAB多元回归程序matl ...

  7. 无源定位之时差估计的精确时差估计算法(ETDE)及MATLAB实现程序

    精确时差估计算法(ETDE)及MATLAB实现程序 算法原理 算法总结 性能分析 实验结果 算法原理 假设两接收站分别接收的带噪信号为 {x(kT)=s(kT)+ε1(kT)y(kT)=s(kT−D) ...

  8. matlab潮流程序,IEEE33节点matlab潮流程序.doc

    IEEE33节点matlab潮流程序 Bus [1,0,0 ; 2,100, 60; 3,90,40; 4,120,80; 5,60,30; 6,60,20; 7, 200, 100 ; 8,200, ...

  9. 改变循环执行的状态,循环程序举例

    //  改变循环执行的状态 1.  用 break 语句提前终止循环 #include "stdafx.h" #define SUM 100000                  ...

最新文章

  1. 《从零开始学Swift》学习笔记(Day 47)——final关键字
  2. 【微读书】《人工智能颠覆未来战争》连载之一:机器战胜人类?——AlphaGo人机对战的启示...
  3. docker卸载命令_使用docker完成生信分析环境搭建
  4. java应用高内存占用
  5. vn.py 2.0.1 发布,全功能交易程序开发框架
  6. 云服务器镜像麻烦吗_云服务器的镜像功能有什么作用?
  7. php框架例子,php框架中的动态实例化对象详解
  8. 西电版《离散数学》勘误
  9. Mac 技巧|忘记了开机密码的解决办法
  10. 【两台电脑之间实现鼠标键盘共享】
  11. Android学习之RecyclerView带刺的玫瑰
  12. 如何实现微信内域名防封,微信域名防封跳转
  13. Linux内核虚拟摄像头,Qt Opencv 在Linux下摄像头简单示例v1.0
  14. Gem Port和T-CONT实现业务复用
  15. 名医高效良方(三叉神经痛)
  16. python经典程序练习题6:健康食谱的输出。列出5种不同的食材,输出两两之间可能的组合形式
  17. 为什么美国程序员不用加班,而中国程序员就只能996?
  18. Dapper 分页查询MySQL
  19. 单考单招计算机试卷及答案,高职单考单招计算机模拟试卷一模板.doc
  20. linux命令补全包安装,RED HAT LINUX bash 自动补全命令安装

热门文章

  1. mysql show 语句大全
  2. 动态代理3之代理工厂实现
  3. ubuntu解压zip文件乱码问题
  4. DataGridView控件初始化,添加删除行(不绑定数据库)
  5. python自动化第三周---文件读写
  6. P1136 迎接仪式
  7. BootstrapValidator验证
  8. web中的cookie管理
  9. error C2471和error C1083
  10. 使用MemoryStream和FileStream