【1】直方图

直方图x轴表示:“像素值的范围0~L-1”,y轴表示“像素值的分布概率0~1”;

如果直方图分布不均衡,那么图像的质量和视觉效果必然受损;

读取图像和获取图像的直方图Matlab代码:

function [ output_args ] = histogramblanced(graph)
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
I = imread(graph);
figure;
imshow(I); title('source');
figure;
imhist(I); title('Histogramblanced');
end

控制台调用函数即可;

一、直方图的均衡化

直方图的均衡化是指直方图灰度的均衡化,通过某种灰度映射使得输入图像转换为在每一灰度级上都有近似相同的像素点数的输出图像,即输出的直方图是均匀的

用matlab直接调用直方图均衡化的函数[J, T] = histeq(' '), J是变换后的图像, T是变换矩阵


二、直方图的匹配(规定化处理)

就是说我有一个直方图的标准,然后把源图像也采用该标准进行变换;

源代码如下:

%将图像graph匹配成matchgraph

function [ output_args ] = histomatch(graph, matchgraph)
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
src = imread(graph);
dst = imread(matchgraph);
%获取matchGrapgh的直方图
hgram1 = imhist(src);
hgram2 = imhist(dst);
%规定化处理
[J, T] = histeq(src, hgram1);
figure;
subplot(2,2,1);
imshow(src);
title('原图');
subplot(2,2,2);
imhist(src);
title('原图的直方图');
subplot(2,2,3);
imshow(J);
title('规定化图像');
subplot(2,2,4);
 imhist(dst);
title('规定的直方图');
end


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值