CS 659 Image Processing


Dr. Frank Shih
CS 659 Image Processing
Homework #1
Covering Lectures 1, 2, 3 and Familiarize with Matlab Image Processing Toolkit
NOTES: Submit only the homework “solution” (do not include these homework questions) in
Microsoft Word format to http://njit2.mrooms.net/ before the above deadline. Absolutely, no late
submission is accepted. Write the answers in your own words individually. Any plagiarism will
post a “ZERO” score or cause a “FAIL” grade. The course requires Matlab programming. You can
download the Matlab software from the NJIT website: http://ist.njit.edu/software/download.php. If
you download it off campus, you will need to install VPN license software before downloading (See
ist.njit.edu for download instruction). Remember to choose the newest student version with your
own OS, and after starting MATLAB, request Product Key to activate it.
Notes:
1. In MATLAB window, choose “Preferences”. Click “Image Processing” selection. In the “Border
Style”, choose “Tight” instead of “Loose”. Click “OK”.
2. When the resulting image is shown in another window, click “Edit” and choose “Copy Figure”.
Then go to word file, paste the image into your file.
3. Submit your answer in a Microsoft Word file. Do not include the questions; just provide the
required answers in the file.
4. Totally, there are 5 questions. Each question is 20 points. Grading policy checks the correctness
and completion of showing resulting images, Matlab codes, and text responses.
5. Required images: barbara.jpg, Lena.jpg, cameraman.jpg, lena_256.bmp
Check List:
1. Listen my lecture videos on Moodle: Lectures 1, 2, 3.
2. Download Matlab in your PC and learn how to write its code for processing images.
3. Use internet resources to learn details. Read “barbara.jpg” by imread and show it by imshow.
4. Learn how to show image size and how to convert a color image into grayscale by rgb2gray.
5. Learn to use for-loop to cut out the central rectangle 300x300 of the image and the other
remaining pixels are set to be 32 using cut.m.
Script file: cut.m
fa=imread('barbara.jpg');
for i=1:576
for j=1:720
fc(i,j)=32;
end
end
for i=139:438
for j=211:510
Dr. Frank Shih
fc(i,j)=fa(i,j);
end
end
imshow(fc/255)
6. Read a youtube video on Matlab Image Processing Basic at:
https://www.youtube.com/watch?v=3St0byWYcEI
1.1 (20 points)
(a) Use a cell phone or digital camera to take your face photo and display it.
(b) Use Matlab to crop the above photo into a small image showing only your face skin portion.
(c) Continue to convert the cropped color image into grayscale and show it.
(d) Show the histogram of the above cropped grayscale image.
1.2 (20 points)
(a) Change the grayscale image 'barbara_gray.jpg' into a binary image, which has only two values: 0
and 1. Let the gray level greater than 50 be 1 (white) and otherwise be 0 (black). Give the
Matlab code and show the binary image.
(b) Select the gray level which is greater than 200 or smaller than 100 to be 1 (white) and otherwise
be 0 (black). Give the Matlab code and show the binary image.
(c) How to choose a suitable threshold value is a difficult job. Use the global image threshold by
Otsu's method: graythresh, and use the function im2bw to change the grayscale image into a
binary image by the Otsu’s threshold value. Show the binary image. What is the Otsu’s
threshold value between 0 and 1? What is the equivalent Otsu’s threshold value between 0 and
255?
1.3 (20 points)
(a) Read the 512 x 512 Lena image as F and crop its lower-right quadrant (row from 257 to 512 and
column from 257 to 512) into a 256 x 256 “Lena_256” image as P. Write P into a new image file
by imwrite(P, 'Lena_256.jpg', 'jpeg'). Show the cropped image 'Lena_256.jpg'.
(b) Read the cropped Lena_256 image as P and add 80 to each pixel and show the image using
imshow(P+80)
(c) Use imadd to add 80 to P. Q=imadd(P,80); figure, imshow(Q). Is this image same as the
previous one?
(d) Multiply P by 2. R=P*2; figure, imshow(R).
(e) Divide P by 3. S=P/3; figure, imshow(S).
(f) Read the 256 x 256 “cameraman.jpg” into I and add both “Lena_256” and “cameraman.jpg”
together by J=imadd(P, I). Show the combined image.
Dr. Frank Shih
1.4 (20 points)
(a) Read the following image: lena_256.bmp which is 256 ? 256 resolution. Use program to
decrease the resolution to 128 ? 128 and 64 ? 64. Show the above three images. An example of
Matlab code: x=imread('lena_256.bmp'); x2=imresize(x,1/2); x3=imresize(x2, 1/2);
Provide your source code and show the three images.
(b) Display all above three images as 256 ? 256. In other words, the image of 128 128 will be
resized with the parameter 2 rather than 1/2. All the pixels are repeated to produce an image
with the same size as the original. In Matlab, we can use: m2=imresize(imresize(x,1/2),2);
m3=imresize(imresize(x2,1/2),4); Provide your source code and show the three images.
(c) Read lena_256.bmp, convolve the image with the mask
and show that it
performs averaging operation which results in blurring of the image. Also analyze the impact of
increasing the size of the mask to
; that is, the mask is. Provide
your source code and show the three images. Note: use MATLAB functions “ones” to generate
the matrix and use “conv2” to do the convolution.
1.5 (20 points)
(a) Refer to Lecture Module 1, Topic: Image Transforms, Powerpoint Slide, pages 15&16. Hand
calculate to perform the linear convolution between these two matrices x(m,n) and h(m,n) given
below. Let the outside boundary pixels be zeros. You need to expand the boundary of x(m,n) to
obtain all non-zero values in the result. Let the upper-left pixel of x(m,n) and h(m,n) be the origin.
You need show step-by-step hand calculation process.
(b) Similarly to (a), but hand calculate to perform the linear correlation.
(c) Using MATLAB functions, conv2 and xcorr2, to perform the linear convolution and correlation.
(d) Convolution in spatial domain is equal to multiplication in the frequency domain. Prove this by
a MATLAB code. Show the code and resulting images.
1 2 3
( , ) 4 5 6 ( , ) 3 4 5
7 8 9
x m n h m n
Survey Questions:
(a) Describe your previous BS/MS major and educational background.
(b) Describe your technical programming skills and languages used. Do you know Matlab
Dr. Frank Shih
programming? If not, you can start learning it by yourself from related books.
(c) State your previous courses, working experiences, and research projects that are relevant to
image processing applications if you had before.

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/wxyst/p/10353940.html