COMP 4500-Computer Vision and Image Processing Project- SQU .

1. Lab Objectives:  Performing image enhancement using different type of intensity transformations.  Obtaining the histogram of an image. 2. Theory The first part of this experiment will deal with enhancement. The principal objective of enhancement is to process an image so that the result is more suitable than the original image for a specific application. The enhancement approaches utilized in this experiment are used for the sake of general-purpose contrast manipulation. These approaches are referred to as point processing (because they manipulate still-pixel images). Image enhancement is a very basic image processing task that defines us to have a better subjective judgment over the images. And Image Enhancement in spatial domain (that is, performing operations directly on pixel values) is the very simplistic approach. Enhanced images provide better contrast of the details that images contain. Image enhancement is applied in every field where images are ought to be understood and analyzed, For example, Medical Image Analysis, Analysis of images from satellites, etc. Image Negatives: assume the gray level range is [0, L-1]: S = L-1-r [Type here] COMP4500 FACULTY OF ENGINEERING – SOHAR UNIVERSITY This expression results in reversing of the gray level intensities of the image thereby producing a negative like image. The output of this function can be directly mapped into the gray scale look-up table consisting values from 0 to L-1. Useful for enhancing white and gray details embedded in black regions. Log Transformations: S = c log(1+r) – Where c is a constant and it is assumed that r≥0. – Stretch low gray levels and compress high gray level. Power-Law Transformations: S = c rγ – where c and γ are positive constants Histogram The second part of this experiment will deal with the histogram of a digital image. For a gray-level image in the range [0, L-1], the histogram is a discrete function: h(rk) = nk Where rk is the kth gray level and nk is the number of pixels in the image having level rk. It is a common practice to normalize the histogram by dividing each of its values by the total number of pixels in the image, denoted by n. Thus a normalized histogram is given by: p(rk) = nk/n [Type here] COMP4500 FACULTY OF ENGINEERING – SOHAR UNIVERSITY Exercises : Download the provided images from SULMS in order to perform these exercises and make sure that the images are stored in the workspace. Before writing the program please run the following command: pkg load image Exercise1: Image Negatives 1. Write the following code in a MATLAB m-file: %img_neg.m close all; clear all; I=imread(‘image_1.jpg’); I=im2double(I); for i=1:size(I,1) for j=1:size(I,2) I1(i,j)=1-I(i,j); end end subplot(121),imshow(I),title(‘original image’) subplot(122),imshow(I1),title(‘enhanced image (image negative)’) Comment on your results. Exercise2: Power-Law Transformations %power_tr.m close all; clear all; clc; I=imread(‘image_2.tif’); I=im2double(I); c=input(‘Enter the value of the constant c=’); g=input(‘Enter the value of gamma g=’); for i=1:size(I,1) for j=1:size(I,2) I3(i,j)=c*I(i,j)^g; end end subplot(121), imshow(I),title(‘original image’) subplot(122), imshow(I3),title(‘power-low transformation’) [Type here] COMP4500 FACULTY OF ENGINEERING – SOHAR UNIVERSITY 2. Change the values of c and gamma (at least 3 values each), and comment on your results. [Type here] COMP4500 FACULTY OF ENGINEERING – SOHAR UNIVERSITY Exercise3: Image Histogram %hist_ex.m close all; clear all; i=imread(‘lena_color_256.tif’); I=rgb2gray(i); m=im2bw(i,1); %Black subplot (1,2,1),imhist(I),title(‘Gray Image’); subplot (1,2,2),imhist(m),title(‘Binary Image’) comment on your results. Exercise4: Histogram Equalization clc close all clear all f = imread(‘image_4.tif’); g = histeq(f); subplot (2,2,1),imshow(f),title(‘original image’) subplot (2,2,2),imhist(f),title(‘original Image Histogram’),ylim(‘auto’) subplot (2,2,3),imshow(g),title(‘Image after Histogram Equalization’) subplot (2,2,4),imhist(g),title(‘Histogram Equalization’),ylim(‘auto’) comment on your results. [Type here] COMP4500 FACULTY OF ENGINEERING – SOHAR UNIVERSITY Exercise5: Image enhancement using subtraction clc; close all; clear all; I=imread(‘image_5.tif’); I1=imread(‘Image_6.tif’); if length(size(I))>2 %length must be 2(gray) I=rgb2gray(I); end if length(size(I1))>2 I1=rgb2gray(I1); end I2=I-I1; I3=histeq(I2); subplot(221),imshow(I),title(‘First Image’); subplot(222),imshow(I1),title(‘Second Image’); subplot(223),imshow(I2),title(‘Difference Image’); subplot(224),imshow(I3),title(‘Enhanced Difference Image’); comment on your results. Exercise6: Image Enhancement using averaging clc close all clear all I=imread(‘image_7.jpg’); if length(size(I))>2 I=rgb2gray(I); end I=im2double(I); for i=1:8 N=imnoise(I,’gaussian’); %Gaussian white noise eval([‘In’ num2str(i) ‘ =N;’]) % eval(EXPRESSION) evaluates the MATLAB code %in the string EXPRESSION.(In1=N); end Ia2=(In1+In2)/2; Ia4=(Ia2+In3+In4)/4; Ia6=(Ia4+In5+In6)/6; Ia8=(Ia6+In7+In8)/8; subplot(321),imshow(I),title(‘Original Image’); subplot(322),imshow(N),title(‘noisy Image’); subplot(323),imshow(Ia2),title(‘Approx. due to 2 images’) subplot(324),imshow(Ia4),title(‘Approx. due to 4 images’) subplot(325),imshow(Ia6),title(‘Approx. due to 6 images’) subplot(326),imshow(Ia8),title(‘Approx. due to 8 images’) Comment on your results. [Type here] COMP4500 FACULTY OF ENGINEERING – SOHAR UNIVERSITY Lab tasks: 1. Enhance your image jpg( black and white image) using the three intensity transformations described above. Let c =1 always. Use different values of γ (0.3, 0.4, 0.6, 1.0, 3.0, and 5.0) for each image. 2. Comment on the results you have got. 3. Redo excursive 3 and 4 using your image 4. Redo excursive 6 using salt and paper noise. [Type here]