Question: *PLEASE provide MATLAB code with commented explanations. *The file needed is included here http://www.filedropper.com/lighthouse_8 as lighthouse.mat as well as in the instructions *Your time and
*PLEASE provide MATLAB code with commented explanations.
*The file needed is included here "http://www.filedropper.com/lighthouse_8" as lighthouse.mat as well as in the instructions
*Your time and effort is appreciated. Thank you.
The objective of this assignment is to introduce digital images as a signal type for examining the effects of sampling, aliasing and reconstruction. We will show how the continuous-time to discrete-time sampling and the discrete-time to continuous-time reconstruction processes are carried out for digital images.
A. Digital Images An image can be represented as a function (1, 2) of two continuous variables representing the horizontal (1) and vertical (2) coordinates of a point in space.1 For monochrome images, the signal (1, 2) would be a scalar function of the two spatial variables. Monochrome images are displayed using black and white and shades of gray, so they are called grayscale images. In this lab, we will consider sampled gray-scale still images. A sampled gray-scale still image would be represented as a two-dimensional array of numbers of the form [, ] = (1, 2), 1 and 1
where 1 and 2 are the sampling periods (sample spacings) in the horizontal and vertical directions. In MATLAB, we can represent an image as a matrix, so it would consist of rows and columns. The matrix entry at (, ) is the sample value [, ]called a pixel (short for picture element). An important property of light images, such as photographs, is that their values are always non-negative and finite in magnitude; i.e., 0 [, ] max <
This is because light images are formed by measuring the intensity of reflected or emitted light which must always be a positive finite quantity.
B. Matlab Function to Display Images You can load the image needed for this lab from "http://www.filedropper.com/lighthouse_8" and download lighthouse.mat file. Any file with the extension *.mat is in MATLAB format and can be loaded via the load command. After loading, use the command whos to determine the name of the variable that holds the image and its size. In MATLAB, images can be displayed using the imshow function.
C. Get Test image In order to probe your understanding of image display, do the following simple displays: a) Load and display the 326426 lighthouse image from lighthouse.mat. The command load lighthouse will put the sampled image into the array xx. Use whos to check the size of xx after loading. b) Use the colon operator to extract the 200th row of the lighthouse image, and make a plot of that row as a 1-D discrete-time signal. xx200 = xx(200,:);
Observe the range of signal values. Which values represent white and which ones black? Can you identify the region where the 200th row crosses the fence?
D. Sampling of Images Images that are stored in digital form on a computer have to be sampled images because they are stored in an array (i.e., a matrix). The sampling rate in the two spatial dimensions was chosen at the time the image was digitized (in units of samples per inch if the original was a photograph). For example, the image might have been sampled by a scanner where the resolution was chosen to be 300 dpi (dots per inch).2 If we want a different sampling rate, we can simulate a lower sampling rate by simply throwing away samples in a periodic way. For example, if every other sample is removed, the sampling rate will be halved (in our example, the 300 dpi image would become a 150 dpi image). Usually this is called sub-sampling or downsampling.
Down-sampling throws away samples, so it will shrink the size of the image. This is what is done by the following scheme: xp = xx(1:p:end,1:p:end); when we are downsampling by a factor of p.
a)One potential problem with down-sampling is that aliasing might occur. This can be illustrated in a dramatic fashion with the lighthouse image stored in the variable xx. Now down-sample the lighthouse image by a factor of 2. What is the size of the down-sampled image? Notice the aliasing in the downsampled image. Describe how the aliasing appears visually. Which parts of the image show the aliasing effects most dramatically? You might try zooming in on a very small region of both the original and downsampled images. E. Reconstruction of Images When an image has been sampled, we can fill in the missing samples by doing interpolation. For these reconstruction experiments, use the lighthouse image, down-sampled by a factor of 3 (similar to what you did in Section D). You will have to generate this by loading in the image from lighthouse.mat to get the image which is in the array called xx. A down-sampled lighthouse image should be created and stored in the variable xx3. The objective will be to reconstruct an approximation to the original lighthouse image, the approximation being of size 326426, from the smaller down-sampled image.
a) The simplest interpolation would be reconstruction with a square pulse which produces a zeroorder hold. Here is a method that works for a one-dimensional signal (i.e., one row or one column of the image), assuming that we start with a row vector xr1, and the result is the row vector
xr1hold. xr1 = (-2).^(0:6); L = length(xr1); nn = ceil((0.999:1:4*L)/4); %<-- Round up to the integer part xr1hold = xr1(nn);
Plot the vector xr1hold to verify that it is a zero-order hold version derived from xr1. Explain what values are contained in the indexing vector nn. If xr1hold is treated as an interpolated version of xr1, then what is the interpolation factor? Your report should include an explanation for this part, but plots are optionaluse them if they simplify the explanation. b) Now return to the down-sampled lighthouse image, and process all the rows of xx3 to fill in the missing points. Use the zero-order hold idea from part (a) of this section, but do it for interpolation factor of 3. Call the result xholdrows. Display xholdrows as an image, and compare it to the downsampled image xx3; compare the size of the images as well as their content.
c) Now process all the columns of xholdrows to fill in the missing points in each column and call the result xhold. Compare the result (xhold) to the original image lighthouse. Provide your code for parts (b) and (c).
1 The variables 1 and 2 do not denote time, they represent spatial dimensions. Thus, their units would be inches or some other unit of length.
2 For this example, the sampling periods would be $ = & = 1/300 inches.
3The Sampling Theorem applies to digital images, so there is a Nyquist Rate that depends on the maximum spatial frequency in the image.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
