matlan输入图像 分别生成输入图像的R、G、B三通道直方图 对上一步每个通道的直方图,使用经过m值限定后的直方图分布范围来计算新的曝光值 利用曝光值计算分割点X_a,将每个直方图分割成两个子直方图
时间: 2024-05-30 19:15:42 浏览: 44
Matlab代码:
% 读入图像
img = imread('test.jpg');
% 分离三通道
img_R = img(:,:,1);
img_G = img(:,:,2);
img_B = img(:,:,3);
% 计算三通道直方图
hist_R = imhist(img_R);
hist_G = imhist(img_G);
hist_B = imhist(img_B);
% m值限定直方图分布范围
m = 0.05;
hist_R_new = histeq(img_R, hist_R, [m, 1-m]);
hist_G_new = histeq(img_G, hist_G, [m, 1-m]);
hist_B_new = histeq(img_B, hist_B, [m, 1-m]);
% 计算新的曝光值
exposure_R = find(hist_R_new == max(hist_R_new));
exposure_G = find(hist_G_new == max(hist_G_new));
exposure_B = find(hist_B_new == max(hist_B_new));
% 计算分割点X_a
X_a_R = exposure_R / 255;
X_a_G = exposure_G / 255;
X_a_B = exposure_B / 255;
% 分割直方图
hist_R_low = hist_R_new(1:round(X_a_R*255));
hist_R_high = hist_R_new(round(X_a_R*255)+1:end);
hist_G_low = hist_G_new(1:round(X_a_G*255));
hist_G_high = hist_G_new(round(X_a_G*255)+1:end);
hist_B_low = hist_B_new(1:round(X_a_B*255));
hist_B_high = hist_B_new(round(X_a_B*255)+1:end);
阅读全文