Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Project 6 Project 6 – Image manipulation CET 151 W19, revision 1.0 Due Apr 16, 9 pm 1 Introduction A grayscale image is represented by a computer as a two-dimensional matrix composed of individual...

1 answer below »
Project 6
Project 6 – Image manipulation
CET 151 W19, revision 1.0
Due Apr 16, 9 pm
1 Introduction
A grayscale image is represented by a computer as a two-dimensional matrix composed
of individual pixels (a single cell in the matrix). For a grayscale image, a pixel is a single
value on the range from 0 to XXXXXXXXXXbit unsigned integer, or uint8) where the value 0
epresents black and 255 represents white. The values in the middle of the range
epresent shades of gray.
A color image is similar to a grayscale image in that it is composed of individual pixels.
However, as there is more information to be encoded, each pixel now includes the
intensity of the three primary colors of light – red, blue, and green (RGB) – where each
color layer is known as a "channel." Thus, a color image is represented as a three-
dimensional matrix, where the dimensions are the height, width, and depth. Similar to the
intensity value of a grayscale pixel, the intensity value for each color channel for a color
pixel lies on a range from 0 to 255 (for uint8). Now, though, the number represents the
intensity of that particular channel’s color as a contribution to the composite pixel’s
color. For example, a uint8 value of 255 in the red channel matrix represents pure red at
full intensity. Below are some examples.

R255, G255, B XXXXXXXXXXR0, G255, B0 R0, G0, B0

In MATLAB, a color image is represented by a 3-D matrix, made up of three 2-D
matrices: one for each color channel. The third dimension is the color channel. Index 1 is
the red channel, index 2 is the green channel, and index 3 is the blue channel.
2 Project
For this project, you will create “filters” to manipulate an image matrix to produce certain
effects. In order to manipulate the image matrix of uint8, you need to first convert it
to a matrix of doubles with the double function.


Inversion: To apply an inversion filter to an image you must invert the individual
intensities for each respective channel. This is formally represented by the following
elationship:
?new= 255 − ?old    
where ?new represents the new intensity and ?old is the original intensity value. We subtract
from 255 as that is the maximum intensity in the range.


Grayscale: Converting a color image is essential for giving an authentically old look to
an image, or for convincing others of a MiPhone user’s artistic appreciation. To convert
an image to grayscale, you need to calculate a single intensity value to represent a pixel –
this intensity value is a combination of the individual RGB channel intensities as
specified by the mathematical relationship:
?GS = 0.299×?R XXXXXXXXXX×?G XXXXXXXXXX×?B
Where ?GS is the intensity value of the grayscale and ?R, ?G, and ?B represent the R, G, and
B channel intensities respectively. As a general note, this is one method to convert to
grayscale – others exist which rely on various parameters, from different coefficients to
using information specific to the image (min and max
ightness). For the purpose of our
application you should stick with the method specified above.


Dimming: Sometimes the
ightness of an image can be too much on the eyes and a
muter version of the picture can produce an improved visual experience. To dim a
picture, you need to scale the original range of 0 to 255 for the intensity to one that is
etween 0 and a new maximum value. (Note this is not the same as simply capping the
ightness values.)


Gaussian Blur: Where would we be without the blur filter? A simple blur can make
sharp objects in an image appear less dangerous, or introduce the illusion of motion –
which is a little frightening when it comes to cupcakes. In general, blu
ing is achieved
y spreading the color information in each pixel across its neighboring pixels. To perform
the blu
ing for our application, a square “window” matrix traverses the original image
matrix, calculating the weighted average of the pixels within that window and storing the
esult in the center pixel of the new image – this needs to be done independently for each
pixel and for each color channel. Pixels near the edges, where a full window would not
fit, do not get changed. Using a larger window causes blu
ed part of the image to
ecome blu
ier. The weights for a given window are determined using the Gaussian
distribution – hence the name Gaussian blur.
To obtain the values for the Gaussian weights, call the user-defined function
gaussWeights.p provided – do this from within the blurImage function. The
gaussWeights function takes two inputs: the original image matrix (because a
parameter within gaussWeights is based on its dimensions), and the number of
ows/columns in the window, N. As a check, the matrix returned by gaussWeights
should be the same size (NxN) as the window and all its elements should add up to one
(1).
3 Files provided
This program files are on canvas in the project6 folder.
4 Deliverables and grading
You need to write four functions. The function names and definition lines must be
invertImage.m
function [inverted] = invertImage(orig)
grayscaleImage.m
function [gray] = grayscaleImage(orig)

dimImage.m
function [dimmed] = dimImage(orig, new_max)

lurImage.m
function [blu
ed] = blurImage(orig, window_size)

Your functions should never display an image directly. In other words, your functions
should never call the imshow() or image() functions. You can view the output of
your functions by displaying the resulting images with Matlab commands such as:
imshow(uint8(invertImage(imagematrix)))
Turn in the Matlab functions by 9 pm on the due date.
This project is worth 80 points. Each filter function is 15 points for functionality and 5
points for readability and style.
You may assume non-degenerate inputs. Images tested will be uint8 images with 3 color
channels. You should not assume input images are square. In blurImage, window_size
will be smaller than the smallest dimension of the image.
Answered Same Day Apr 10, 2021

Solution

Kshitij answered on Apr 14 2021
127 Votes
newimage/dimImage.m
function [dimmed]=dimImage(orig,new_max)
pixelsToClip = orig > new_max;
orig(pixelsToClip) = new_max;
dimmed = orig;
end
newimage/dimmed.jpg
newimage/grayscaleImage.m
% Function will take a colour image as input and will return a grayscale image
function [gray] = grayscaleImage(orig)
img=imread(orig);
% Extract Red colour component to R, Green colour component to G
% and Blue colour component...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here