Documente Academic
Documente Profesional
Documente Cultură
AbstractThe present report lists the procedure, programs, Here, filename is a string containing the complete name of the
demonstrations, performances, responses, justifications and the image file (including any applicable extension). For example,
results obtained. Also include conclusions, observations, and the command line
literature Consulted according to the course requirements.
Index TermsMatlab, digital image processing >> i= imread(rice.tif);
I. I NTRODUCTION reads the Portable Network Graphics (PNG) image rice into
image array i.
Digital image processing methods are divided into two
main areas of application: improvement of pictorial infor- Images are displayed on the MATLAB desktop using func-
mation for human interpretation; And image data processing tion imshow, which has the basic syntax:
for storage, transmission and representation for autonomous
machine perception. To meet the objectives of these areas imshow(f, G)
of knowledge it is important to start knowing basic aspects where f is an image array, and G is the number of intensity
about how to represent and perform mathematical operations levels used to display it. If G is omitted, it defaults to 256
in digital images. This document shows the development of levels. Using the syntax:
some MATLAB scripts designed for the visualization and
manipulation of digital images covering the following topics of imshow(f, [low high])
interest: Levels of intensity, zoom and shrinkage, average for
displays as black all values less than or equal to low, and as
reduction of noise, negative, reflexion and rotation of images.
white all values greater than or equal to high. The values in
II. L AB P ROCEDURES between are displayed as intermediate intensity values using
the default number of levels. For these reason, the command
A. Reading and viewing images proposed in the assigment
Figure 1 is generated by running the MATLAB script imshow(f, [0 100])
code32.m in the attachments.
overexpose the original rice.png showed in figure 2.
Fig. 4: Image Resizing Note that in the case of using bilinear interpolation, the
imresize function automatically applies a low-pass filter to
the image (whose default size is 11 11), slightly blurring
neighbor, bilinear, or higher order interpolations). When using it before the image is interpolated. This helps to reduce the
the imresize function, a scale factor larger than 1 will produce effects of aliasing during resampling.
an image larger than the original, and a scale factor smaller
than 1 will result in an image smaller than the original. III. I MAGE AVERAGING
Figure 4a contain the original image and that Which is after
Noise reduction is achieved by adding the corresponding
the operation of sub-sample the image to a size of 32 x 32
pixel values of all the noisy images and then dividing them
pixels. In contrast, figure 4b shows re-scaling process of the
with the number of noisy images to get the averaged intensity.
32 x 32 to the original size (1024x1024 px).
If the noise at each pixel is uncorrelated then it gets canceled
out during averaging. Better results can be obtained as the
To write code to enlarge or reduce an image by a certain
number of noisy images are increased As shown in the
factor (e.g., a factor of 32 in both directions), we need to
following mathematical demonstration:
deal with the problem of removing pixels (in the case of
shrinking) by subsampling the original image by a factor of
Consider a noisy image g(x, y) formed by the addition of
32 in both dimensions, that is, skipping every other pixel
noise n(x, y) to an original image f (x, y),
along each row and column. Conversely, for the task of
enlarging the image by a factor of 32 in both dimensions, we
g(x, y) = f (x, y) + n(x, y) (2)
would opt for copying each original pixel to an n n block in
the output image. These simple interpolation schemes (pixel where the assumption is that at every pair of coordinates
removal and pixel duplication, respectively) are fast and easy (x, y) the noise is uncorrelated and has zero average value.The
to understand, but suffer from several limitations, such as the objective of the following procedure is to reduce the noise
following: content by adding a set of noisy images, { gi (x, y) } as
follows:
The blockiness effect that may become noticeable when
M M M
enlarging an image. 1 X 1 X 1 X
The possibility of removing essential information in the g= gi = fi + ni (3)
M i=1 M i=1 M i=1
process of shrinking an image.
The difficulty in extending these approaches to arbitrary, . Then
noninteger, resizing factors.
M M
1 X 1 X
E{g} = E{fi } + E{ni } (4)
Other simplistic methods such as using the mean (or M i=1 M i=1
But all the fi are the same image, so E{fi } = f . Also, it subplot to place each of the nine images (the original along
is given that the noise has zero mean, so E{ni } = 0 then it with the eight calculated above) into nine different subplots
follows that within the same figure as showed in figure 5. For more details,
please refer to code36.m script in the attachments.
E{g} = f (5)
On the other hand, It is known from random-variable theory
that the variance of the sum of uncorrelated random variables
is the sum of the variances of those variables (Papoulis
[1991]). Because it is given that the elements of f are constant
and the n are uncorrelated, then
1
g2 = f2 + [ 2 + n2 2 + ... + n2 M ] (6)
M 2 n1
The first term on the right side is 0 because the elements
of f are constants. The various n2 i are simply samples of the
noise, which is has variance n2 .Thus, n2 i = n2 and we have:
M 2 1 2
g2 = = (7)
M2 n M n
where E{g} is the expected value of g, and g2 and n2 are
the variances of g and n respectively, all at image coordinates
(x, y). The standard deviation (square root of the variance) at
any point in the average image is:
1
g = n (8)
M
As M increases, equation 7 and 8 indicate that the variabil-
Fig. 5: cameraman bit plane slicing
ity (as measured by the variance or the standard deviation)
of the pixel values at each location (x, y) decreases. Because
Note that the higher-order bits (especially the top four)
E{g} = f , this means that g approaches f as the number of
contain the majority of the visually significant data. The other
noisy images used in the averaging process increases.
bit planes contribute to more subtle details in the image.
IV. B IT P LANE S LICING Separating a digital image into its bit planes is useful for
For the next discussion we use cameramanimage, the analyzing the relative importance played by each bit of the
grayscale image is 8-bit (unsigned integer), then we can image, a process that aids in determining the adequacy of the
determine the first bit (least-significant bit and so is right most number of bits used to quantize each pixel.
bit in the 8-bit pixel) by using bitand operation as follows:
V. I MAGE F LIPPING
singleBitImg = bitand(cameraManImg, mask); Flipping an image upside down or leftright can be easily
accomplished re-organizing the rows and columns of the
In the above, we are applying a mask of 1 (or, in binary, matrices that represent the image channels. For example,
00000001) which will zero all but the first bit from each pixel HF = I(:, end : 1 : 1, :) performs a horizontal flip while
in our image. We can then plot the pixel1Img and move to the V F = I(end : 1 : 1, :, :) do it vertically. Figures 6 and 7
second bit. Since the binary 00000001 zeroed all bits but the represents the output of the Matlab script code37.m in the
first, then we want to zero all bits but the second, so we need attachments for two different images (grayscale,RGB).
a binary mask of 00000010. We can easily get this using the
VI. I MAGE ROTATION
bitshift function which shifts the bits to the left (or right). In
this case, we want to shift the bits of our mask one bit to the In this section, we discuss about how to rotate an image
left. without using built in MATLAB functions. You can find the
MATLAB implementation in script code38.m in the attach-
mask = 1; ments. The script was designed based on the next pseudocode:
mask = bitshift(mask,1);
1) Find the midpoints of the image.
singleBitImg = bitand(cameraManImg, mask);
2) Convert each pixel coordinate to polar coordinate.
3) Convert the angle which is in radians into degree.
We can do the same for the remaining six bits, shifting the 4) Add the degree value to be rotated to the value obtained
mask one bit to the left on each iteration of a loop. We use in the above step.
45 degrees. Figure 8 shows a problem called aliasing. Its
the same reason that we see jagged staircases on lines drawn
on low resolution screens at angles other than horizontal and
vertical. Raster screens are digital, and pixel boundaries are
at quantized locations. Also, multiplying by sines and cosines
on the integer coordinates of the source image gives real
number results, and these have to be rounded back to integers
again to be plotted. Sometimes this number rounding means
the same destination location is addressed more than once,
and sometimes certain pixels are missed completely. When
the pixels are missed, the background shows through. This is
why there are holes.There are a variety of solutions for this
problem. One of them is interpolate the pixel value using the
nearest neighbor like its showing in figure 9.
R EFERENCES
[1] afael Gonzalez and Richard Woods. Digital image processing. Prentice
Hall, 2001.
[2] afael Gonzalez and Richard Woods. Digital image processing using
Matlab. Prentice Hall, 2004.
[3] ARQUES, Oge. Practical image and video processing using MATLAB.
John Wiley Sons, 2011.