实验要求:

Objective:
To know how to implement image enhancement for color images by histogram processing. Note that the definition of histogram for color images differs from that of histogram for gray images.
Main requirements:
Ability of programming with C, C++, or Matlab.
Instruction manual:
(a) Download the dark-stream color picture in Fig. 6.35 (this image is labeled Fig. 6.35(05) in the image gallery for Chapter 6). Convert the image to RGB (see comments at the beginning of Project 06-01). Histogram-equalize the R, G, and B images separately using the histogram-equalization program and convert the image back to jpg format.
(b) Form an average histogram from the three histograms in (a) and use it as the basis to obtain a single histogram equalization intensity transformation function. Apply this function to the R, G, and B components individually, and convert the results to jpg. Compare and explain the differences in the jpg images in (a) and (b).

本实验是对彩色图像进行直方图均衡化处理。其中,我分了两种方式对彩色图像进行处理。一种是对图像的R、G、B三个彩色分量进行直方图均衡化,另一种是将图像从RGB颜色空间转换到HSI颜色空间,使用直方图均衡化单独处理亮度I分量,随后将图像从HSI空间转换回到RGB颜色空间。对比两种处理方法的结果。

实验代码:

%%
close all;
clc;
clear all;%%
img = imread('Fig6.35(5).jpg');
figure
subplot(1,3,1);
imshow(img);
title('original image');%% 对RGB3个通道的灰度值分别做直方图均衡化,然后再合为一幅新的图像
R = img(:, :, 1);
G = img(:, :, 2);
B = img(:, :, 3);A = histeq(R);
B = histeq(G);
C = histeq(B);img1 = cat(3, A, B, C);subplot(1,3,2);
imshow(img1);
title('histogram-equalization 1');%% 先将RGB格式的图像转换为HSI格式的图像,然后再对亮度I做直方图均衡化,紧接着转换成RGB格式的图像img_hsi = rgb2hsi(img);
img_hsi_i = img_hsi(:, :, 3);
img_hsi_I = histeq(img_hsi_i);
img_hsi(:, :, 3) = img_hsi_I;
img2 = hsi2rgb(img_hsi);subplot(1,3,3);
imshow(img2);
title('histogram-equalization 2');

补充:
程序中使用的一些函数,RGB和HSI颜色空间之间相互转换的程序:
hsi2rgb()函数:

function rgb = hsi2rgb(hsi)
%HSI2RGB Converts an HSI image to RGB.
%   RGB = HSI2RGB(HSI) converts an HSI image to RGB, where HSI is
%   assumed to be of class double with:
%     hsi(:, :, 1) = hue image, assumed to be in the range
%                    [0, 1] by having been divided by 2*pi.
%     hsi(:, :, 2) = saturation image, in the range [0, 1].
%     hsi(:, :, 3) = intensity image, in the range [0, 1].
%
%   The components of the output image are:
%     rgb(:, :, 1) = red.
%     rgb(:, :, 2) = green.
%     rgb(:, :, 3) = blue.%   Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins
%   Digital Image Processing Using MATLAB, Prentice-Hall, 2004
%   $Revision: 1.5 $  $Date: 2003/10/13 01:01:06 $% Extract the individual HSI component images.
H = hsi(:, :, 1) * 2 * pi;
S = hsi(:, :, 2);
I = hsi(:, :, 3);% Implement the conversion equations.
R = zeros(size(hsi, 1), size(hsi, 2));
G = zeros(size(hsi, 1), size(hsi, 2));
B = zeros(size(hsi, 1), size(hsi, 2));% RG sector (0 <= H < 2*pi/3).
idx = find( (0 <= H) & (H < 2*pi/3));
B(idx) = I(idx) .* (1 - S(idx));
R(idx) = I(idx) .* (1 + S(idx) .* cos(H(idx)) ./ ...cos(pi/3 - H(idx)));
G(idx) = 3*I(idx) - (R(idx) + B(idx));% BG sector (2*pi/3 <= H < 4*pi/3).
idx = find( (2*pi/3 <= H) & (H < 4*pi/3) );
R(idx) = I(idx) .* (1 - S(idx));
G(idx) = I(idx) .* (1 + S(idx) .* cos(H(idx) - 2*pi/3) ./ ...cos(pi - H(idx)));
B(idx) = 3*I(idx) - (R(idx) + G(idx));% BR sector.
idx = find( (4*pi/3 <= H) & (H <= 2*pi));
G(idx) = I(idx) .* (1 - S(idx));
B(idx) = I(idx) .* (1 + S(idx) .* cos(H(idx) - 4*pi/3) ./ ...cos(5*pi/3 - H(idx)));
R(idx) = 3*I(idx) - (G(idx) + B(idx));% Combine all three results into an RGB image.  Clip to [0, 1] to
% compensate for floating-point arithmetic rounding effects.
rgb = cat(3, R, G, B);
rgb = max(min(rgb, 1), 0);

rgb2hsi()函数:

function hsi = rgb2hsi(rgb)
%RGB2HSI Converts an RGB image to HSI.
%   HSI = RGB2HSI(RGB) converts an RGB image to HSI. The input image
%   is assumed to be of size M-by-N-by-3, where the third dimension
%   accounts for three image planes: red, green, and blue, in that
%   order. If all RGB component images are equal, the HSI conversion
%   is undefined. The input image can be of class double (with values
%   in the range [0, 1]), uint8, or uint16.
%
%   The output image, HSI, is of class double, where:
%     hsi(:, :, 1) = hue image normalized to the range [0, 1] by
%                    dividing all angle values by 2*pi.
%     hsi(:, :, 2) = saturation image, in the range [0, 1].
%     hsi(:, :, 3) = intensity image, in the range [0, 1].%   Copyright 2002-2004 R. C. Gonzalez, R. E. Woods, & S. L. Eddins
%   Digital Image Processing Using MATLAB, Prentice-Hall, 2004
%   $Revision: 1.5 $  $Date: 2005/01/18 13:44:59 $% Extract the individual component images.
rgb = im2double(rgb);
r = rgb(:, :, 1);
g = rgb(:, :, 2);
b = rgb(:, :, 3);% Implement the conversion equations.
num = 0.5*((r - g) + (r - b));
den = sqrt((r - g).^2 + (r - b).*(g - b));
theta = acos(num./(den + eps));H = theta;
H(b > g) = 2*pi - H(b > g);
H = H/(2*pi);num = min(min(r, g), b);
den = r + g + b;
den(den == 0) = eps;
S = 1 - 3.* num./den;H(S == 0) = 0;I = (r + g + b)/3;% Combine all three results into an hsi image.
hsi = cat(3, H, S, I);

程序运行结果:

数字图像处理实验(16):PROJECT 06-03,Color Image Enhancement by Histogram Processing相关推荐

  1. 数字图像处理实验(总计23个)汇总

    以下这些实验中的代码全部是我自己编写调试通过的,到此,最后进行一下汇总. 数字图像处理实验(1):PROJECT 02-01, Image Printing Program Based on Half ...

  2. 数字图像处理实验三图像增强

    一.实验目的 (1)了解图像增强的目的及意义,加深对图像增强的 感性认识,巩固所学的图像增强的理论知识和相 关算法. (2)熟练掌握直方图均衡化和直方图规定化的计算过 程. (3)熟练掌握空域滤波中常 ...

  3. 数字图像处理实验四图像频域增强

    一.实验目的 (1)了解图像增强的目的及意义,加深对图像增强的感性认识,巩固所学的图像增强的理论知识和相关算法. (2)熟练掌握低通.高通.带通.同态滤波器的使用方法,明确不同性质的滤波器对图像的影响 ...

  4. 实验1 数字图像处理的MATLAB基础,《数字图像处理(实验部分)》实验1_数字图像处理中MATLAB使用基础...

    <数字图像处理(实验部分)>教案 实验一:数字图像处理中MATLAB使用基础实验 一. MATLAB软件安装 二. 进入MATLAB运行环境 三. MATLAB编程基础 3.1.变量 预定 ...

  5. 数字图像处理——实验一 Python中数字图像处理的基本操作

    数字图像处理--实验一 Python中数字图像处理的基本操作 一.实验目的 二.实验主要仪器设备 三.实验原理 3.1 数字图像的表示和类别 3.2 opencv-python图像文件格式 四.实验内 ...

  6. 数字图像处理matlab实验对图像复原,数字图像处理实验07图像的复原处理

    数字图像处理实验 一.数字图像处理实验 实验七 图像的复原处理 一.实验目的 熟悉几种在实际应用中比较重要的图像复原技术,学会用MATLAB复原函数对退化图像进行复原处理. 二.实验内容 1.用点扩散 ...

  7. 数字图像处理实验——Python语言实现

    数字图像处理实验--Python语言实现 实验一:数字图像处理入门 实验二:直方图均衡 实验三:线性平滑和锐化--掩模法 实验四:非线性平滑--中值滤波 实验五:非线性锐化--梯度法 GitHub地址 ...

  8. 数字图像处理实验5图像复原

    一.实验目的 (1)了解图像复原的目的及意义,加深对图像复原理论的认识. (2)掌握维纳滤波复原基本原理. (3)掌握约束最小二乘方复原方法. (4)掌握盲解卷积复原方法 二.实验内容  (1)维纳滤 ...

  9. matlab数字图像实验报告,数字图像处理实验报告(matlab)

    数字图像处理实验报告(matlab) 学院:自动化学院 班级:电081班 姓名:李林树 学号:40850099 2011年10月 实验一 直方图均衡化 一. 实验目的: 1. 熟悉图像数据在计算机中的 ...

最新文章

  1. 怎样在多线程中使用JNI?
  2. CoordinatorLayout
  3. 在WPF应用程序中利用IEditableObject接口实现可撤销编辑的对象
  4. 用ABAP来实现柱状图和饼状图的输出
  5. 生物信息学(Bioinformatics)
  6. 【啊哈!算法】之二、插入排序
  7. 超硬核 ICML’21 | 如何使自然语言生成提速五倍,且显存占用减低99%
  8. Java环境配置(linux安装jdk8)
  9. jdbc mysql url写法_MySQL第04篇:JDBC
  10. TableViewCell的折展(Masonry)
  11. java 生成kml 文件
  12. 微信公众号-推送模板消息
  13. mysql链接is not allow_解决Mysql远程连接出错不允许访问 ERROR 1130:Host is not allow...
  14. eclipse安装tomcat时只有locahost,不显示server name
  15. shuipFCMS二次开发记录一
  16. HDU - 6769
  17. mac记事本写html,MAC 记事本的选择
  18. [md] 如何做一个心状枕头
  19. 整体变分法信号去噪_家里wifi信号差?给小白的无线排查操作指南
  20. 关于mysql:Can‘t connect to MySQL server on ‘localhost:3306‘ (XX) + 关于navicat:client does not supp...

热门文章

  1. https协议 ppt 下载卷_做PPT被版权吓得心颤颤?教你如何搞到靠谱素材
  2. 数据结构实验之图论七:驴友计划(最短路Floyd/Dijkstra)
  3. qt opencv cmake配置 单纯小白
  4. 【自动驾驶】7. MDC常用术语、DDS、SOME/IP
  5. Caffe学习系列(12):训练和测试自己的图片
  6. elasticsearch 第三篇(安装篇)
  7. 美团酒店Node全栈开发实践
  8. Hadoop自带的一些程序示例
  9. 数字图像处理:第十七章 纹理分析
  10. Starting MySQL.. ERROR! The server quit without updating PID file (/usr/local/mysql/data/vm10-0-0-19