数字图像处理实验(5):Proj03-01 ~ Proj03-06
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.9img_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運行結(jié)果:
首先是原圖像與做對數(shù)變換后的結(jié)果對比,隨后是冪率變換的結(jié)果。程序中已有詳細(xì)注釋。
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.
簡單點來說,實驗中我們要進(jìn)行直方圖均衡化,可以調(diào)用MATLAB工具箱中的histeq函數(shù)。
上代碼:
運行結(jié)果:
進(jìn)行直方圖均衡化之后,我們可以很明顯地看到圖像的對比度增強了。
實驗要求:
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.實驗中我們要對圖像做算術(shù)運算,觀察結(jié)果。
實驗代碼:
實驗結(jié)果:
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的濾波器模板,對圖像進(jìn)行空間濾波。程序中調(diào)用MATLAB的fspecial函數(shù)生成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');實驗結(jié)果:
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).
使用拉普拉斯算子對圖片進(jìn)行空間濾波。
實驗代碼:
實驗結(jié)果:
可以看出使用拉普拉斯算子可以突出邊緣,將其與原圖像疊加便能增強邊緣。左邊的是使用fspecial生成拉普拉斯算子,右邊的是直接輸入的拉普拉斯算子模板,即:
實驗要求:
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).
非銳化掩蔽,使用前面實驗的程序來實現(xiàn)增強濾波。
直接上程序:
% 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實驗結(jié)果:
總結(jié)
以上是生活随笔為你收集整理的数字图像处理实验(5):Proj03-01 ~ Proj03-06的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数字图像处理实验(4):PROJECT
- 下一篇: 杭电ACM刷题(1):1002,A +