|
| 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 rfabbri ((at))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 function you want help with, or type helpdesk. If this is foreign to you, come get help [B&H 317 or email: rfabbri ((at))lems.brown.edu ], I am happy to answer any questions. This lab will also give you a chance to become familiar with the digital camera. Use your digital camera (or come by the lab (B&H317) to set up a time to use the lab's digital camera) to take a few pictures, and upload them to the computer. You will use the images in this lab. |
| 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? |
| Problem 7:
Take two pictures that you took with the digital camera and load them into matlab. Use the function rgb2gray to covert them to grayscale. You will also have to change the class of the image from uint8 to double in order to perform operations with the data. You will then have to change it back in order to view it with imshow. For example: myImage = imread('myPhoto.jpg');
...perform operations with doubleImage...
finalImage = uint8(processedImage);
Perform the following operations on the two images: ADDITION, SUBTRACTION, MULTIPLICATION, and DIVISION (The images must be exactly the same size, use .* and ./ instead of * and / for multiply and devide). Include the original images as well as the resulting images in your report and be sure to indicate which image goes with which operation. If you want, you can control the contribution of each image in the operation. For example: Addition: C = A + k * B, where k is a single value.
[note: make sure that the resulting intensities are within the correct range, if they are not, rescale the values or just cap them to 255 or 0]. |
| Problem 8:
Perform the following operations on the binary images A and B: AND, OR and XOR. [Remember, instead of 0 and 1, the binary values of the image are 255 and 0, that is 0-->255 and 1-->0]. |