亮度变换函数:

1、imadjust(f,[low_in high_in],[low_out

high_out],gamma)

gamma = 1时是线性映射,gamma < 1时高亮度区域被压缩,gamma

> 1时低亮度区域被压缩。

2、imcomplement(f)

求取图像的反片

3、对数变换

用于傅里叶频谱取值范围较大,其中高值部分占优,从而导致频谱中低亮度值可视细节丢失,通过对数变换可以将动态范围降低,从而便于我们处理,公式为:log(1

+ double(f));

4、对比度拉伸函数

公式为:g = 1 / (1 + (m ./ (double(f) +

eps)).^E),其中m是均值,E控制斜率,一般取4;

书中将以上变换整理到一个函数中,代码如下:

function g = intrans(f, varargin)

%INTRANS Performs intensity (gray-level) transformations.

% G = INTRANS(F, 'neg')

computes the negative of input image F.

%

% G = INTRANS(F, 'log', C,

CLASS) computes C*log(1 + F) and

% multiplies the result by

(positive) constant C. If the last two

% parameters are omitted, C

defaults to 1. Because the log is used

% frequently to display Fourier

spectra, parameter CLASS offers the

% option to specify the class

of the output as 'uint8' or

% 'uint16'. If parameter CLASS

is omitted, the output is of the

% same class as the

input.

%

% G = INTRANS(F, 'gamma', GAM)

performs a gamma transformation on

% the input image using

parameter GAM (a required input). %

% G = INTRANS(F, 'stretch', M,

E) computes a contrast-stretching

% transformation using the

expression 1./(1 + (M./(F +

% eps)).^E). Parameter M must be in the range [0, 1]. The

default

% value for M is

mean2(im2double(F)), and the default value for E

% is 4.

%

% For the 'neg', 'gamma', and

'stretch' transformations, double

% input images whose maximum

value is greater than 1 are scaled

% first using

MAT2GRAY. Other images are converted to double

first

% using

IM2DOUBLE. For the 'log' transformation, double

images are

% transformed without being

scaled; other images are converted to

% double first using

IM2DOUBLE.

%

% The output is of the same

class as the input, except if a

% different class is specified

for the 'log' option.

% Copyright 2002-2004 R. C.

Gonzalez, R. E. Woods, & S. L. Eddins

% Digital Image Processing

Using MATLAB, Prentice-Hall, 2004

% $Revision: 1.7

$ $Date: 2003/10/13 00:45:53 $

% Verify the correct number of inputs.

error(nargchk(2, 4, nargin))

% Store the class of the input for use later.

classin = class(f);

% If the input is of class double, and it is outside the

range

% [0, 1], and the specified transformation is not 'log', convert

the

% input to the range [0, 1].

if strcmp(class(f), 'double') & max(f(:))

> 1 & ...

~strcmp(varargin{1}, 'log')

f = mat2gray(f);

else % Convert to double, regardless of class(f).

f = im2double(f);

end

% Determine the type of transformation specified.

method = varargin{1};

% Perform the intensity transformation

specified. switch method

case 'neg'

g = imcomplement(f);

case 'log'

if length(varargin) ==

1 c = 1;

elseif length(varargin) ==

2 c = varargin{2};

elseif length(varargin) ==

3

c = varargin{2};

classin = varargin{3};

else

error('Incorrect number of inputs for the log option.')

end

g = c*(log(1 +

double(f)));

case 'gamma'

if length(varargin)

< 2

error('Not enough inputs for the gamma option.')

end

gam = varargin{2};

g = imadjust(f, [ ], [ ],

gam);

case 'stretch'

if length(varargin) == 1

% Use defaults.

m = mean2(f); E =

4.0; elseif length(varargin) ==

3

m = varargin{2}; E = varargin{3};

else error('Incorrect number

of inputs for the stretch option.')

end

g = 1./(1 + (m./(f +

eps)).^E);

otherwise

error('Unknown enhancement

method.')

end

% Convert to the class of the input image.

g = changeclass(classin, g);

5、直方图均衡化

histeq(f,nval),其中nval为输出图像的灰度级数,默认为64;

6、直方图规定化

直方图均衡化可以提高图像的对比度,但对于图像灰度值过于集中于0值区域时,灰度变换函数是灰度直方图的累加和的曲线,此时曲线在低值区域会出现陡峰,因此把灰度级低端过于集中的像素映射到灰度级的高端,并不能提高图像的对比度。

直方图规定化将解决该问题,期望的直方图应在灰度级有较小的几种范围,在保留图像直方图大体形状,其函数为:

histeq(f,p)

p为期望直方图,其原理和直方图均衡化一样,只不过直方图均衡化的期望直方图为等于1的直线,而直方图规定化是一个任意的曲线而已,在实际中期望直方图可以通过双峰高斯函数来估计,书中提供双峰函数的生成代码:

function p = twomodegauss(m1, sig1, m2, sig2, A1, A2, k)

%TWOMODEGAUSS Generates a two-mode Gaussian function.

% P = TWOMODEGAUSS(M1, SIG1,

M2, SIG2, A1, A2, K) generates a

% two-mode, Gaussian-like

function in the interval [0,1]. P is a

% 256-element vector normalized

so that SUM(P) equals 1. The mean

% and standard deviation of the

modes are (M1, SIG1) and (M2,

% SIG2), respectively. A1 and

A2 are the amplitude values of the

% two modes. Since the output is normalized, only the relative

% values of A1 and A2 are

important. K is an offset value that

% raises the "floor" of the

function. A good set of values to try

% is M1=0.15, S1=0.05, M2=0.75,

S2=0.05, A1=1, A2=0.07, and

% K=0.002.

% Copyright 2002-2004 R. C.

Gonzalez, R. E. Woods, & S. L. Eddins

% Digital Image Processing

Using MATLAB, Prentice-Hall, 2004

% $Revision: 1.6

$ $Date: 2003/10/13 00:54:47 $

c1 = A1 * (1 / ((2 * pi) ^ 0.5) * sig1);

k1 = 2 * (sig1 ^ 2);

c2 = A2 * (1 / ((2 * pi) ^ 0.5) * sig2);

k2 = 2 * (sig2 ^ 2);

z = linspace(0, 1, 256);

p = k + c1 * exp(-((z - m1) .^ 2) ./ k1) + ...

c2 *

exp(-((z - m2) .^ 2) ./ k2);

p = p ./ sum(p(:));

function p = manualhist

%MANUALHIST Generates a two-mode histogram interactively.

% P = MANUALHIST generates a

two-mode histogram using

% TWOMODEGAUSS(m1, sig1, m2,

sig2, A1, A2, k). m1 and m2 are the

% means of the two modes and

must be in the range [0,1]. sig1 and

% sig2 are the standard

deviations of the two modes. A1 and A2 are

% amplitude values, and k is an

offset value that raised the

% "floor" of

histogram. The number of elements in the

histogram

% vector P is 256 and sum(P) is

normalized to 1. MANUALHIST

% repeatedly prompts for the

parameters and plots the resulting

% histogram until the user

types an 'x' to quit, and then it returns

% the last histogram

computed.

%

% A good set of starting values

is: (0.15, 0.05, 0.75, 0.05, 1,

% 0.07,

0.002).

% Copyright 2002-2004 R. C.

Gonzalez, R. E. Woods, & S. L. Eddins

% Digital Image Processing

Using MATLAB, Prentice-Hall, 2004

% $Revision: 1.7

$ $Date: 2003/10/13 00:49:57 $

% Initialize.

repeats = true;

quitnow = 'x';

% Compute a default histogram in case the user quits

before

% estimating at least one histogram.

p = twomodegauss(0.15, 0.05, 0.75, 0.05, 1, 0.07, 0.002);

% Cycle until an x is input.

while repeats s = input('Enter m1, sig1, m2,

sig2, A1, A2, k OR x to quit:','s');

if s == quitnow

break

end

% Convert the input string to

a vector of numerical values and

% verify the number of

inputs.

v = str2num(s);

if numel(v) ~= 7

disp('Incorrect number of inputs')

continue

end

p = twomodegauss(v(1), v(2),

v(3), v(4), v(5), v(6), v(7));

% Start a new figure and scale

the axes. Specifying only xlim

% leaves ylim on auto.

figure, plot(p)

xlim([0 255])

end

图像处理怎么学matlab,Matlab数字图像处理学习(1)-亮度变换相关推荐

  1. 【基于MATLAB的数字图像处理】大作业·综合图像处理平台

    系列文章目录 ·[基于MATLAB的数字图像处理]第一章·绪论 ·[基于MATLAB的数字图像处理]第二章·视觉系统与图像处理系统 ·[基于MATLAB的数字图像处理]第三章·基本图像变换 ·[基于M ...

  2. java数字图像处理开题报告,基于MATLAB的数字图像处理算法研究与仿真开题报告...

    基于MATLAB的数字图像处理算法研究与仿真开题报告 毕 业 设 计 (2013 届) 题 目基于 MATLAB 的数字图像 处理算法研究与仿真 学 院 物理电气信息学院 专 业 通信工程 年 级 0 ...

  3. 基于MATLAB的数字图像处理的设计与实现 转

    基于MAT [摘要]数字图像处理是一门新兴技术,随着计算机硬件的发展,数字图像的实时处理已经成为可能,由于数字图像处理的各种算法的出现,使得其处理速度越来越快,能更好的为人们服务.数字图像处理是一种通 ...

  4. 基于MATLAB的数字图像处理系统

    基于MATLAB的数字图像处理系统 摘要:数字图像处理技术是20世纪60年代发展起来的一门新兴学科,随着图像处理理论和方法的进一步完善,使得数字图像处理技术在各个领域得到了广泛应用,并显示出广阔的应用 ...

  5. 基于MATLAB的数字图像处理系统设计

    一.课题背景 MATLAB 作为国内外流行的数字计算软件,具有强大的图像处理功能,界面简洁,操作直观,容易上手,而且是图像处理系统的理想开发工具. 笔者阐述了一种基于MATLAB的数字图像处理系统设计 ...

  6. 【基于MATLAB的数字图像处理】第四章·图像增强

    系列文章 ·[基于MATLAB的数字图像处理]第一章·绪论 ·[基于MATLAB的数字图像处理]第二章·视觉系统与图像处理系统 ·[基于MATLAB的数字图像处理]第三章·基本图像变换 ·[基于MAT ...

  7. 【基于MATLAB的数字图像处理】第三章·基本图像变换

    系列文章 ·[基于MATLAB的数字图像处理]第一章·绪论 ·[基于MATLAB的数字图像处理]第二章·视觉系统与图像处理系统 ·[基于MATLAB的数字图像处理]第三章·基本图像变换 ·[基于MAT ...

  8. 基于MATLAB的数字图像处理系统GUI界面设计

    基于MATLAB的数字图像处理系统GUI界面设计 图像读入 从图形文件中读入图像 imread Syntax: A = imread(filename, fmt) filename:指定的灰度或彩色图 ...

  9. matlab将图像用傅里叶旋转,用matlab实现数字图像处理几个简单例子.doc

    用matlab实现数字图像处理几个简单例子.doc 实验报告实验一 图像的傅里叶变换(旋转性质)实验二 图像的代数运算实验三 filter2 实现均值滤波实验四 图像的缩放朱锦璐04085122实验一 ...

  10. 数字图像处理与python实现_数字图像处理学习(2)—— 图像直方图均衡与图像匹配(python实现)...

    数字图像处理学习(2)-- 直方图均衡与图像匹配 1. 直方图均衡(Histogram Equalization) 1.1 直方图均衡化概念 1.2 直方图均衡实现简单思路 1.3 直方图均衡实现代码 ...

最新文章

  1. log4j.logger java_java – Log4JLogger的根本原因是找不到还是不可用?
  2. winform下载网页源码
  3. Eclipse新建工程编译R cannot be resolved to a variable问题
  4. LiveData学习
  5. AI时代学习新的技术,方向为计算机视觉--欢迎来我的简书blog拔草
  6. http://channel9.msdn.com/Events/MIX
  7. python 打印三维数据_Python中的面向对象编程(二):数据隐藏和对象打印
  8. javascript 函数传参
  9. windows server 2008 安装及VS2008和VS 2008 SP1安装
  10. H3C交换机设置与无线控制器时间同步
  11. 联想微型计算机怎么连接电源,终于认识联想电脑主板与机箱电源安装方法
  12. 利用Python计算农历日期
  13. Android异常 Eclipse编译应用时出现 com.android.dx.cf.iface.parseexception
  14. 【Web3】什么是Web3?一个新的去中心化网络,或是最新的营销流行语
  15. 关于战棋对战化的设想和实现
  16. Android 短视频编辑开发之摄像头预览实时美颜(三)
  17. 学好c语言对php的帮助,学好c语言可以干什么?
  18. 微软首席数字官亲述微软自己的数字化转型故事
  19. 学生管理系统设计与实现(C++实现)
  20. 全球顶级白帽子:美女、通缉犯、公务员

热门文章

  1. QNX Hypervisor管理程序
  2. 使用Apache TVM将机器学习编译为WASM和WebGPU
  3. 选择最合适的预测性维护传感器
  4. 目标检测coco数据集点滴介绍
  5. 2021年大数据Flink(二十八):Flink 容错机制 自动重启策略和恢复
  6. [JAVA EE] JPA 技术实践:完成增、删、改、查操作
  7. Java 参数后面跟三个... 的作用
  8. Kotlin 创建对象
  9. Android SDK Manager 的介绍
  10. RabbitMQ 入门系列(7)— 如何保证 RabbitMQ 高可用性