PROJECT 03-01 : Image Enhancement Using Intensity Transformations

实验要求:

Objective

To manipulate a technique of image enhancement by intensity transformation or gray level transformation.

Main requirements:

Ability of programming with C, C++, or Matlab.

Instruction manual:

The focus of this project is to experiment with intensity transformations to enhance an image. Download Fig. 3.8(a) and enhance it using

(a) The log transformation of Eq. (3.2-2).

(b) A power-law transformation of the form shown in Eq. (3.2-3).

In (a) the only free parameter is c, but in (b) there are two parameters, c and r for which values have to be selected. As in most enhancement tasks, experimentation is a must. The objective of this project is to obtain the best visual enhancement possible with the methods in (a) and (b). Once (according to your judgment) you have the best visual result for each transformation, explain the reasons for the major differences between them.

实验代码:


clear all
clc
close all % read image
img_gray = imread('Fig4.28(a).jpg'); % img_gray = rgb2gray(img); figure(1)
subplot(1, 2, 1);
imshow(img_gray);
title('original'); % log transformation
t1 = log(1+double(img_gray)); % Description of mat2gray:
% I = mat2gray(A, [amin amax]) converts the matrix A to the intensity image
% I. The returned matrix I contains values in the range 0.0 (black) to 1.0
% (full intensity or white). amin and amax are the values in A that correspond
% to 0.0 and 1.0 in I. Values less than amin become 0.0, and values greater
% than amax become 1.0.
t2 = mat2gray(t1); % Description of im2uint8:
% im2uint8 takes an image as input and returns an image of class uint8.
% If the input image is of class uint8, the output image is identical to
% the input image. If the input image is not uint8, im2uint8 returns the
% equivalent image of class uint8, rescaling or offsetting the data as necessary.
img1 = im2uint8(t2); subplot(1, 2, 2);
imshow(img1);
title('log transformation'); % power-law transformation
figure(2)
% subplot(2, 5, 1);
imshow(img_gray);
title('original'); img_t1 = double(img_gray);
cnt = 1;
pow = 0.1; for pow = 0.1:0.2:0.9
img_t2 = im2uint8(mat2gray(img_t1.^pow));
cnt = cnt + 1;
figure(1+cnt);
% subplot(2, 5, cnt);
imshow(img_t2);
% title('power-law:\gamma=');
gamma = sprintf('power-law:gamma=%.1f', pow);
title(gamma);
end

运行结果:

首先是原图像与做对数变换后的结果对比,随后是幂率变换的结果。程序中已有详细注释。

PROJECT 03-02 [Multiple Uses] : Histogram Equalization

实验要求:

Objective

To manipulate a technique of image enhancement by histogram equalization.

Main requirements:

Ability of programming with C, C++, or Matlab.

Instruction manual:

(a) Write a computer program for computing the histogram of an image.

(b) Implement the histogram equalization technique discussed in Section 3.3.1.

(c) Download Fig. 3.8(a) and perform histogram equalization on it.

As a minimum, your report should include the original image, a plot of its histogram, a plot of the histogram-equalization transformation function, the enhanced image, and a plot of its histogram. Use this information to explain why the resulting image was enhanced as it was.

简单点来说,实验中我们要进行直方图均衡化,可以调用MATLAB工具箱中的histeq函数。

上代码:


clear all;
clc;
close all; %%
img = imread('Boat512.bmp');
subplot(2,2,1);
imshow(img); subplot(2,2,2);
imhist(img); img1 = histeq(img,256);
subplot(2,2,3);
imshow(img1); subplot(2,2,4);
imhist(img1);

运行结果:



进行直方图均衡化之后,我们可以很明显地看到图像的对比度增强了。

PROJECT 03-03 [Multiple Uses] :Arithmetic Operations

实验要求:

Objective
To know how to do arithmetic operations on an image and the functions of some arithmetic operations.
Main requirements:
Ability of programming with C, C++, or Matlab.
Instruction manual:
Write a computer program capable of performing the four arithmetic operations between two images. This project is generic, in the sense that it will be used in other projects to follow. (See comments on pages 112 and 116 regarding scaling). In addition to multiplying two images, your multiplication function must be able to handle multiplication of an image by a constant.

实验中我们要对图像做算术运算,观察结果。

实验代码:

%
clear all;
clc;
close all; %
% img = imread('peppers_color.jpg');
% size = size(img);
% if numel(size) >= 2
% img = rgb2gray(img);
% imwrite(img,'gray_img.jpg');
% end
% clear size; % 读取原图像
img = imread('gray_img.jpg');
subplot(4,3,1);
imshow(img);
title('image 1'); % 反转灰度
img1 = 255 - img;
subplot(4,3,2);
imshow(img1);
title('image 2'); % 图像相加
img2 = imadd(img, img1);
subplot(4,3,3);
imshow(img2);
title('add'); % 图像相减
subplot(4,3,4);
imshow(img2);
title('image 1'); subplot(4,3,5);
imshow(img);
title('image 2'); img3 = imsubtract(img2, img);
subplot(4,3,6);
imshow(img3);
title('subtract'); % 图像相乘
subplot(4,3,7);
imshow(img);
title('image 1'); subplot(4,3,8);
imshow(img1);
title('image 2'); img4 = immultiply(img, img1);
subplot(4,3,9);
imshow(img4);
title('multiply'); %% 图像相除
subplot(4,3,10);
imshow(img4);
title('image 1'); subplot(4,3,11);
imshow(img1);
title('image 2'); img5 = imdivide(img4, img1);
subplot(4,3,12);
imshow(img5);
title('divide');

实验结果:

PROJECT 03-04 [Multiple Uses] : Spatial Filtering

实验要求:

Objective

To understand what is special filtering and how the parameters of the filtering mask affect the output of filters..

Main requirements:

Ability of programming with C, C++, or Matlab.

Instruction manual:

Write program to perform spatial filtering of an image (see Section 3.5 regarding implementation). You can fix the size of the spatial mask at 3 x 3, but the coefficients need to be variables that can be input into your program. This project is generic, in the sense that it will be used in other projects to follow.

使用3 x 3的滤波器模板,对图像进行空间滤波。程序中调用MATLAB的fspecial函数生成3 x 3滤波器模板。

%
close all;
clc;
clear all; %
img = imread('Fig5.10(a).jpg');
subplot(1,3,1);
imshow(img);
title('original'); % 均值滤波
% h = fspecial('average', hsize) returns an averaging filter h of size hsize.
% The argument hsize can be a vector specifying the number of rows and columns
% in h, or it can be a scalar, in which case h is a square matrix. The default
% value for hsize is [3 3].
h = fspecial('average',[3,3]); % 均值滤波器
img1 = imfilter(img, h);
subplot(1,3,2);
imshow(img1);
title('average filter'); % 中值滤波
% B = medfilt2(A) performs median filtering of the matrix A using the default
% 3-by-3 neighborhood.
img2 = medfilt2(img);
subplot(1,3,3);
imshow(img2);
title('median filter');

实验结果:

PROJECT 03-05 : Enhancement Using the Laplacian

实验要求:

Objective:

To further understand the well-known technique of Laplacian and how it works on an image.

Main requirements:

Ability of programming with C, C++, or Matlab.

Instruction manual:

(a) Use the programs developed in Projects 03-03 and 03-04 to implement the Laplacian enhancement technique described in connection with Eq. (3.7-5). Use the mask shown in Fig. 3.39(d).

(b) Duplicate the results in Fig. 3.40. You will need to download Fig. 3.40(a).

使用拉普拉斯算子对图片进行空间滤波。

实验代码:

%
close all;
clc;
clear all; %
img = imread('moon.jpg');
subplot(3, 1, 1);
imshow(img);
title('original'); %
h = fspecial('laplacian', 0.2);
img1 = imfilter(img, h);
subplot(3, 2, 3);
imshow(img1);
title('default laplacian'); %
w = [-1, -1, -1; -1, 8, -1; -1, -1, -1];
% 'replicate', 图像大小通过复制外边界的值来扩展
img2 = imfilter(img, w, 'replicate');
subplot(3, 2, 4);
imshow(img2);
title('mask'); %
img3 = img + img1;
subplot(3, 2, 5);
imshow(img3);
title('output1'); %
img4 = img + img2;
subplot(3, 2, 6);
imshow(img4);
title('output2');

实验结果:



可以看出使用拉普拉斯算子可以突出边缘,将其与原图像叠加便能增强边缘。左边的是使用fspecial生成拉普拉斯算子,右边的是直接输入的拉普拉斯算子模板,即:

w = [-1, -1, -1; -1, 8, -1; -1, -1, -1];
PROJECT 03-06 :Unsharp Masking

实验要求:

Objective:

To further understand image enhancement technique of unsharp masking and how it works on an image.

Main requirements:

Ability of programming with C, C++, or Matlab.

Instruction manual:

(a) Use the programs developed in Projects 03-03 and 03-04 to implement high-boost filtering, as given in Eq. (3.7-8). The averaging part of the process should be done using the mask in Fig. 3.34(a).

(b) Download Fig. 3.43(a) and enhance it using the program you developed in (a). Your objective is to choose constant A so that your result visually approximates Fig. 3.43(d).

非锐化掩蔽,使用前面实验的程序来实现增强滤波。

直接上程序:

%
close all;
clc;
clear all; %
img = imread('test.png');
figure(1);
subplot(2,2,1);
imshow(img);
title('original'); cnt = 1;
for alpha = [0.1 0.4 0.9]
h = fspecial('laplacian', alpha);
img_temp =imfilter(img, h);
img_out = img + img_temp;
cnt = cnt + 1;
subplot(2,2,cnt);
imshow(img_out);
title(['\alpha = ', num2str(alpha)]); % subplot(1, 2, 1);
% imshow(img_temp);
% title(['\alpha = ', num2str(alpha)]);
% subplot(1, 2, 2);
% imshow(img_out);
% title('output');
end

实验结果:

数字图像处理实验(5):Proj03-01 ~ Proj03-06 标签: 图像处理matlab 2017-04-30 10:39 184人阅读的更多相关文章

  1. 数字图像处理实验(总计23个)汇总 标签: 图像处理MATLAB 2017-05-31 10:30 175人阅读 评论(0)

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

  2. 数字图像处理实验(17):PROJECT 06-04,Color Image Segmentation 标签: 图像处理MATLAB 2017-05-27 21:13

    实验报告: Objective: Color image segmentation is a big issue in image processing. This students need to ...

  3. Python web前端 01 HTML常用标签

    Python web前端 01 HTML常用标签 一.HTML创建项目 file ---->new project -----> 输入项目名------>创建文件夹 new dicr ...

  4. iOS系列 基础篇 06 标签和按钮 (Label & Button)

    iOS系列 基础篇 06 标签和按钮 (Label & Button) 目录: 标签控件 按钮控件 小结 标签和按钮是两个常用的控件,下面咱们逐一学习. 1. 标签控件 使用Single Vi ...

  5. http://www.liangxiansen.cn/2017/04/06/consul/

    Consul 使用手册 | 一个梦 http://www.liangxiansen.cn/2017/04/06/consul/ 基于Consul的分布式锁实现 https://mp.weixin.qq ...

  6. php图像处理(thinkphp框架有相对强大的图像处理功能)

    php图像处理(thinkphp框架有相对强大的图像处理功能) 一.总结 1.php处理图像:php处理图像需要安装外库(gd库) 2.gd库函数可以非常完美的操作图像:安装好库之后,这个库里面的函数 ...

  7. 085 01 Android 零基础入门 02 Java面向对象 01 Java面向对象基础 02 构造方法介绍 04 构造方法调用

    085 01 Android 零基础入门 02 Java面向对象 01 Java面向对象基础 02 构造方法介绍 04 构造方法调用 本文知识点:构造方法调用 说明:因为时间紧张,本人写博客过程中只是 ...

  8. 024 01 Android 零基础入门 01 Java基础语法 03 Java运算符 04 关系运算符

    024 01 Android 零基础入门 01 Java基础语法 03 Java运算符 04 关系运算符 本文知识点:Java中的关系运算符 关系运算符

  9. 016 01 Android 零基础入门 01 Java基础语法 02 Java常量与变量 10 布尔类型和字符串的字面值

    016 01 Android 零基础入门 01 Java基础语法 02 Java常量与变量 10 布尔类型和字符串的字面值 本文知识点:字面值 关于字面值的概念,需要注意:很多地方,我们可能就把字面值 ...

随机推荐

  1. Python3.6.0安装

    1.安装 具体详情请参考下图: 双击安装包:   勾选“add  python 3.6 to PATH”这样可以自动生成环境变量,选择“Customize installation”自定义安装. 2. ...

  2. 2018.7.27 wireless charger TX evaluation kit based on STWBC-EP

    1 introduced 我们需要设计一个无线充电方案: 功能需求:通用的无线充电平台 参数要求:8-10W step1: 找寻资料  http://www.ti.com/sitesearch/doc ...

  3. spring学习-3

    spring的自动装配 spring IOC容器可以自动装配bean,只需要在bean的autowire属性指定自动装配的模式. 模式: 1.byType:根据类型自动装配.根据bean的类型和当前b ...

  4. 「2017 山东三轮集训 Day7」Easy

    一棵带边权的树,多次询问 $x$ 到编号为 $[l,r]$ 的点最短距离是多少 $n \leq 100000$ sol: 动态点分治,每层重心维护到所有点的距离 查询的时候在管辖这个点的 log 层线 ...

  5. Linux 下如何调试 Python?

    一般开发者都是在 IDE 中进行程序的调试,当然,有 IDE 的话,当然首选 IDE 进行调试. 但是,有时我们的业务场景,限制只能在 Linux 命令行模式进行调试. 这时该怎么办呢? 今天,就给大 ...

  6. Azure RBAC管理ASM资源

    上一篇文章介绍了Azure基于ARM的RBAC,给不同的用户分配不同的权限. 但目前在国内使用的大部分用户还是以ASM的资源为主.比如:VM.Storage.Network.WebAPP.SQL Az ...

  7. 推荐几个MySQL大牛的博客

    1.淘宝丁奇 http://dinglin.iteye.com/ 2.周振兴@淘宝 花名:苏普 http://www.orczhou.com/ 3. 阿里云数据库高级专家彭立勋为 MariaDB Fo ...

  8. HDU4006(小根堆)

    The kth great number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Oth ...

  9. Lib之过?Java反序列化漏洞通用利用分析

    转http://blog.chaitin.com/ 1 背景 2 Java反序列化漏洞简介 3 利用Apache Commons Collections实现远程代码执行 4 漏洞利用实例 4.1 利用 ...

  10. SA读书笔记1

    SA的基本任务: 帐户: 为新用户增设帐号,将不再活动的帐号删除,帐号存活期事务(忘记密码等).把用户的主目录放在什么位置.在哪些机器上创建帐号. 硬件:识别并使用新硬件.对于虚拟化:设备可能要安装在 ...