1. 程式人生 > >MATLAB例項1-直方圖均衡化

MATLAB例項1-直方圖均衡化

clc;
clear all;

img = imread('20171206-213721022-RGB.bmp');  
[nHeight, nWidth, nDim] = size(img);  
r = img(:, :, 1);  
g = img(:, :, 2);  
b = img(:, :, 3);  
% 呼叫直方圖均衡化函式分別對 R G B 分量進行直方圖均衡化  
R = histeq(r);  
G = histeq(g);  
B = histeq(b);  
newimg = cat(3, R, G, B);  
imshow(newimg);  
imwrite(newimg,'20171206-213721022-RGB_histeq.bmp');
  
figure(1);  
subplot(1, 2, 1), imshow(img);  
title('均衡化之前的影象');  
subplot(1, 2, 2), imshow(newimg);  
title('均衡化之後的影象');