COSC 4323 Digital Image Processing In this project, you will perform each of the
ID: 3912679 • Letter: C
Question
COSC 4323 Digital Image Processing
In this project, you will perform each of the following transformations:
1. cropping
2. resize
3. convert to negative
4. convert to gray scale
5. brightness adjustment
6. contrast adjustment
7. nonlinear brightness adjustment
8. color/hue adjustment
9. horizontal flip
10. vertical flip
11. image rotation
12. affine transformation
13. projective transformation
14. Gaussian blur
15. motion blur
16. artistic effects
You should choose some digital images and perform one transformation on one image. You should choose a particular image best suited to illustrate the effect of that transformation. You don’t have to choose all 16 different images for these tasks, but apparently you cannot just use one image and illustrate all the transformations. Choose photographs that are rich in colors, instead of simple graphics like logos. You may lose points if the image of choice is not appropriate to illustrate the transformation.
You can use any image editing software like Adobe Photoshop, GIMP, PixelMath, or any software of your choice. Programming languages are not required but you can use any programing language of your choice to enhance the project, like MATLAB, Java, OpenCV with C++, Python, etc.
Include the before and after images for each transformation in your report.
Explanation / Answer
As per your requirement i have written code which fulfill all your requirements please follow it step by step. and i have written in MATLAB
clear all
close all
clc
%% THE IMAGE CROP
contentofimage=imread('peppers.png');
% Here we are going to crop image, let specifies crop rectangle
imagecroped = imcrop(contentofimage,[75 68 130 112]);
% Actually here we are going to display original image and later cropped image.
subplot(1,2,1)
imshow(contentofimage)
title('Original Image')
subplot(1,2,2)
imshow(imagecroped)
title('Cropped Image')
suptitle('CROP THE IMAGE');
%% AN IMAGE RESIZE
contentofimage2 = imread('autumn.tif');
% Actually here we will resize the image, specifying scale factor and the interpolation method.
imageresize = imresize(contentofimage2, 0.25, 'nearest');
% Here we will display the original and the resized image.
figure
subplot(1,2,1)
imshow(contentofimage2)
title('Original Image')
subplot(1,2,2)
imshow(imageresize)
title('Resized Image')
suptitle('RESIZE AN IMAGE');
%% TO NEGATIVE CONVERT
contentofimage3=imread('cameraman.tif');
% Here we will crop image and specifying crop rectangle
imageofnegative = imcomplement(contentofimage3);
% Here we will display original image and neg image.
figure
subplot(1,2,1)
imshow(contentofimage3)
title('Original Image')
subplot(1,2,2)
imshow(imageofnegative)
title('Negative Image')
suptitle('CONVERT TO NEGATIVE');
%% ADJUSTMENT BRIGHTNESS
contentofimage4=imread('saturn.png');
% Actually here we will adjust contrast of the RGB image and specifying contrast limits.
imagebrightness = imadjust(contentofimage4,[.2 .3 0; .6 .7 1],[]);
% Here we are going to display original image and bright image.
figure
subplot(1,2,1)
imshow(contentofimage4)
title('Original Image')
subplot(1,2,2)
imshow(imagebrightness)
title('Brightness Adjusted Image')
suptitle('BRIGHTNESS ADJUSTMENT');
%% adjustment contrast
contentofimage4=imread('pout.tif');
% Adjust the contrast of the image by histogram equilization.
imagecontrast = histeq(contentofimage4);
% Display original image and contrast adjusted image.
figure
subplot(1,2,1)
imshow(contentofimage4)
title('Original Image')
subplot(1,2,2)
imshow(imagecontrast)
title('Contrast Adjusted Image')
suptitle('CONTRAST ADJUSTMENT');
%% BRIGHTNESS ADJUSTMENT NON-LINEAR
contentofimage4=imread('saturn.png');
% Actually here we will adjust the contrast of the RGB image, specifying contrast limits.
imagebrightness = imadjust(contentofimage4,[],[],0.5);
% Display original image and new image.
figure
subplot(1,2,1)
imshow(contentofimage4)
title('Original Image')
subplot(1,2,2)
imshow(imagebrightness)
title('Brightness Adjusted Image')
suptitle('NON-LINEAR BRIGHTNESS ADJUSTMENT');
%% ADJUSTMENT HUE
hueFactor=0.1;
contentimage5 = imread('peppers.png');
imageOfHSV = rgb2hsv(contentimage5);
imageOfHSV(:,:,1) = imageOfHSV(:,:,1) * hueFactor;
imageofadjustedhue = hsv2rgb(imageOfHSV);
% Here we will display original image and hue adjusted image.
figure
subplot(1,2,1)
imshow(contentimage5)
title('Original Image')
subplot(1,2,2)
imshow(imageofadjustedhue)
title('Hue Adjusted Image')
suptitle('HUE ADJUSTMENT');
%% AN IMAGE HORIZONTALLY FLIP
contentimage6 = imread('office_4.jpg');
imageflipped = flipdim(contentimage6,2);
% Actually we are going to display original image and Flipped image.
figure
subplot(1,2,1)
imshow(contentimage6)
title('Original Image')
subplot(1,2,2)
imshow(imageflipped)
title('Horizontally Flipped Image')
suptitle('FLIP AN IMAGE HORIZONTALLY');
%% AN IMAGE VERTICALLY FLIP
contentimage6 = imread('office_4.jpg');
imagevflipped = flipdim(contentimage6,1);
% Here we will display original image and Flipped image.
figure
subplot(1,2,1)
imshow(contentimage6)
title('Original Image')
subplot(1,2,2)
imshow(imagevflipped)
title('Vertically Flipped Image')
suptitle('FLIP AN IMAGE VERTICALLY');
%% THE IMAGE ROTATE
imagerotated = imrotate(contentofimage,45,'bilinear','crop');
% Display original image and rotated image.
figure
subplot(1,2,1)
imshow(contentofimage)
title('Original Image')
subplot(1,2,2)
imshow(imagerotated)
title('Rotated Image')
suptitle('ROTATE THE IMAGE');
%% BLUR GAUSSIAN
contentimage7 = imread('cameraman.tif');
% Here we will do Filter the image with a Gaussian filter with standard deviation of 2.
blurI = imgaussfilt(contentimage7, 2);
% Here we will display original image and blurred image.
figure
subplot(1,2,1)
imshow(contentimage7)
title('Original Image')
subplot(1,2,2)
imshow(blurI)
title('Gaussian Blurred Image')
suptitle('GAUSSIAN BLUR');
%% BLUR MOTION
% Here we will create a motion filter and use it to blur the image. Display the blurred image.
H = fspecial('motion',20,45);
mblurimage = imfilter(contentimage7,H,'replicate');
% Here we will display original image and blurred image.
figure
subplot(1,2,1)
imshow(contentimage7)
title('Original Image')
subplot(1,2,2)
imshow(mblurimage)
title('Motion Blurred Image')
suptitle('MOTION BLUR');
%% EFFECT ARTISTIC
imgfl(:,:,1)=contentofimage(:,:,1)';
imgfl(:,:,2)=contentofimage(:,:,2)';
imgfl(:,:,3)=contentofimage(:,:,3)';
imgfl=imrotate(imgfl,-90);
imageeffect1=imgfl;
red=imgfl(:,:,1);
green=imgfl(:,:,2);
blue=imgfl(:,:,3);
imgfl(:,:,1)=blue;
imgfl(:,:,3)=red;
imageeffect2=imgfl;
% Here we will display original image and Flipped image.
figure
subplot(1,3,1)
imshow(contentofimage)
title('Original Image')
subplot(1,3,2)
imshow(imageeffect1)
title('Effect 1')
subplot(1,3,3)
imshow(imageeffect2)
title('Effect 2')
suptitle('ARTISTIC EFFECT');
%% TRANSFORMATION PROJECTIVE
% Here we will create a 2-D geometric transformation object.
formtransformation = affine2d([1 0 0; .5 1 0; 0 0 1]);
imageprojected= imwarp(contentofimage3,formtransformation);
% Here we will display original image and projected image.
figure
subplot(1,2,1)
imshow(contentofimage3)
title('Original Image')
subplot(1,2,2)
imshow(imageprojected)
title('Wrapped Image')
suptitle('Projective Transformation');
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.