分享几种matlab灰度图均衡/提高对比度的方法

所用matlab版本为2015b

1 灰度图线性变换

i=imread('songshu.jpg');
i=im2double(rgb2gray(i));
[m,n]=size(i);
%增加对比度
Fa=1.25;Fb=0;
s=Fa.*i+Fb/255;
figure(1),subplot(221),imshow(s);
title('k=1.25.b=0');
figure(2),subplot(221),[H,x]=imhist(s,64);
stem(x,(H/m/n),'.');
title('k=1.25,b=0');

%减小对比度
Fa=0.5;Fb=0;
s=Fa.*i+Fb/255;
figure(1),subplot(222),imshow(s);
title('k=0.5.b=0');
figure(2),subplot(222),[H,x]=imhist(s,64);
stem(x,(H/m/n),'.');
title('k=0.5,b=0');

%线性亮度增加
Fa=1.25;Fb=50;
s=Fa.*i+Fb/255;
figure(1),subplot(223),imshow(s);
title('k=1.25.b=50');
figure(2),subplot(223),[H,x]=imhist(s,64);
stem(x,(H/m/n),'.');
title('k=1.25,b=50');

%底片显示
Fa=-1;Fb=255;
s=Fa.*i+Fb/255;
figure(1),subplot(224),imshow(s);
title('k=-1.b=255');
figure(2),subplot(224),[H,x]=imhist(s,64);
stem(x,(H/m/n),'.');
title('k=-1,b=255');

2灰度拉伸

用最黑和最白亮度的相除值,白色越亮,黑色越暗

i=imread('songshu.jpg');
i=rgb2gray(i);
L=imadjust(i,[],[50/255;150/255]);
J=imadjust(L,[50/255;150/255],[20/55;230/255]);
subplot(221),imshow(L),title('low contrast');
subplot(222),imhist(L),title('low contrast');
subplot(223),imshow(J),title('gray stretch');
subplot(224),imhist(J),title('gray stretch');

3 灰度图像均衡

可使低对比度的灰度图对比度提高

i=imread('songshu.jpg');
i=rgb2gray(i);
LC=imadjust(i,[],[50/255;150/255]);%将全图的元素缩到50-150
figure(1),subplot(221),imshow(LC);
title('low contrast');
figure(1),subplot(222),imhist(LC);
title('low contrast');
HE1=histeq(LC);
figure(1),subplot(223),imshow(HE1);
title('histeq img');
figure(1),subplot(224),imhist(HE1);
title('histeq img');
  • 11
    点赞
  • 79
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值