Introduction to Monochrome Images
A = imread('yacht.tif');
whosto display your variables. Notice under the "Class" column that the A matrix elements are of type uint8 (unsigned integer, 8 bits). This means that Matlab is using a single byte to represent each pixel. Matlab cannot perform numerical computation on numbers of type uint8, so we usually need to convert the matrix to a floating point representation. Create a double precision representation of the image using
B = double(A);. Again, type
whosand notice the difference in the number of bytes between A and B. In future sections, we will be performing computations on our images, so we need to remember to convert them to type double before processing them.
imagecommand works for both type uint8 and double images. The
colormapcommand specifies the range of displayed gray levels, assigning black to 0 and white to 255. It is important to note that if any pixel values are outside the range 0 to 255 (after processing), they will be clipped to 0 or 255 respectively in the displayed image. It is also important to note that a floating point pixel value will be rounded down ("floored") to an integer before it is displayed. Therefore the maximum number of gray levels that will be displayed on the monitor is 255, even if the image values take on a continuous range.
- Hand in two flipped images.
- Hand in the negative image.
- Hand in the image multiplied by factor of 1.5. What effect did this have?
Histogram of an Image
Hist(A)which will plot the histogram of image matrix A. You may use Matlab's
histfunction, however that function requires a vector as input. An example of using
histto plot a histogram of a matrix would be
reshapecommand is creating a row vector out of the image matrix, and the
histcommand plots a histogram with bins centered at [0:255].
Histfunction on the image. Label the axes of the histogram and give it a title.
output = pointTrans(input, T1, T2).
- Determine an equation for the graph in Figure 3, and use this in your function. Notice you have three input regions to consider. You may want to create a separate function to apply this equation.
- If your function performs the transformation one pixel at a time, be sure to allocate the space for the output image at the beginning to speed things up.
pointTransfunction to spread out the histogram using T1=70 and T2=180. Display the new image and its histogram. (You can open another figure window using the
figurecommand.) Do you notice a difference in the "quality" of the picture?
- Hand in your code for
- Hand in the original image and its histogram.
- Hand in the transformed image and its histogram.
- What qualitative effect did the transformation have on the original image? Do you observe any negative effects of the transformation?
- Compare the histograms of the original and transformed images. Why are there zeros in the output histogram?
B = gammCorr(A,gamma)
gammCorrfunction to correct the image for your monitor, and display the resultant image. Did it improve the quality of the picture?
- Hand in your code for
- Hand in the γ corrected image.
- How did the correction affect the image? Does this appear to be the correct value for γ ?
Image Enhancement Based on Filtering
Ndetermines the size of filter,
varis the variance, and
his the N×N filter. Notice that for this filter to be symmetrically centered around zero, N will need to be an odd number.
H = fftshift(fft2(h,32,32));
meshcommand. Plot it over the region[−π,π]×[−π,π], and label the axes.
medfilt2command). Use the syntax
Y = medianFilter(X);
image. Filter each of the noisy images with both the 7×7 Gaussian filter (σ2=1) and the 3×3 median filter. Display the results of the filtering, and place a title on each figure. (You can open several figure windows using the
figurecommand.) Compare the filtered images with the original noisy images. Print out the four filtered pictures.
- Hand in your code for
- Hand in the plot of |HGauss(ω1,ω2)|.
- Hand in the results of filtering the noisy images (4 pictures).
- Discuss the effectiveness of each filter for the case of additive white Gaussian noise. Discuss both positive and negative effects that you observe for each filter.
- Discuss the effectiveness of each filter for the case of "salt and pepper" noise. Again, discuss both positive and negative effects that you observe for each filter.
gaussFilterfunction from the "Smoothing Exercise" section, create a 5×5 Gaussian filter with σ2=1. Use Matlab to compute the frequency response of an unsharp mask filter (use your expression for Equation 11), using the Gaussian filter as h(i,j), α=5 and β=4. The size of the calculated frequency response should be 32×32. Plot the magnitude of this response in the range [−π,π]×[−π,π] using
mesh, and label the axes. You can change the viewing angle of the mesh plot with the
viewcommand. Print out this response.
imageto view the original and processed images. What effect did the filtering have on the image? Label the processed image and print it out.
- Hand in your derivation for the frequency response of the unsharp mask.
- Hand in the labeled plot of the magnitude response. Compare this plot to the highpass responses of Figure 10. In what ways is it similar to these frequency responses?
- Hand in the two processed images.
- Describe any positive and negative effects of the filtering that you observe. Discuss the influence of the α and β parameters.