|
| NOTE: Problems should be done in MATLAB. Type
up your solutions for each one including: (1) The answer to any questions
posed, (2) any resulting images (include in document), and (3) the name
of any function(s) (testfunc.m, threshold.m, etc.) you used.
Zip or tar your document with your source code (m-files) into a file called [Lastname_FirstInitial_Lab1.zip/tar] and email it to mcchang@lems.brown.edu with the subject "EN161 Lab1". One more thing: make sure your code works when you send it to me. I should be able to reproduce your results. |
| Overview:
This should be a fairly easy introduction to handling and manipulating images with MATLAB. To view online help with MATLAB, use help [command] where command is the funciton you want help with, or type helpdesk. If this is foreign to you, come get help [B&H 317 or email: mcchang@lems.brown.edu ], I am happy to answer any questions. |
| Data:
Here are the images you will need for this lab. To save an image off the internet, right-click on the image and choose "save image as" and save it to your local computer.
|
| Viewing Images:
To load an image into MATLAB, you should use imread(). Save this image to the computer you are on and load it into MATLAB. To display a matrix/image you are working on, use imshow(). To write the image to a file, use imwrite(). In summary, you will need to load an image into MATLAB, which treats the image as a large matrix. Perform your tasks on the image/matrix, and view the results use imshow(), then when you are finished, use imwrite to write your data to an image, which you can put into the document you hand in. Example code:
DATA = imread('quart.jpg'); imshow(DATA); imwrite(DATA, 'myfile.jpg');
|
| Problem 1:
Using the quart.jpg image, threshold it to make any non-quarter area black. To do this, you will need to check each pixel in the image, and if it is over To (where To is the threshold you have chosen) set the pixel's intensity to 0, otherwise, set to 255. You will need to play with To to find its optimal value. You will probably want to pass it into the function as a parameter. Sample Code:
|
| Problem 2:
Using the snowman.jpg image, perform bilevel thresholding. i.e. set all pixels with intensity between I0 and I1 to 255 and set all pixels less than I0 to 0 and all pixels greater than I1 to 0. The snowman is the region of interest, you are thresholding for (where bob is, should be all white and the rest should be black). |
| Problem 3:
Invert the quarters image to get a full image like this section: ![]() Hint: Make sure pixel intensities are not negative, you may need to shift up the intensities to ensure this does not happen. |
| Problem 4:
Increase the brightness of the original image by 10% or decrease the brightness of the original by 10% by adding/subtracting a value (I0=25) from each pixel intensity. Try different values of I0. |
| Problem 5:
The current image has 256 possible values of pixel intensity, reduce this to 8 levels. Make some observations about the quantization levels and image quality. Do this by grouping intensity regions, i.e. set the intensity of all pixels with current intensity between 0-31 to 16, between 32-63 to 48, 64-95 to 80,...etc. How would you do this for 16 levels? |
| Problem 6:
Reduce the sampling of the quarters image by half, by skipping every other element: loop: for i from 1 to width in steps of 2 for j from 1 to height in steps of 2 outputimage (i, j) = inputimage(i, j) how would you reduce the resolution by a factor of 5? |