Assignment1 Pub
Assignment1 Pub
Assignment1 Pub
ShanghaiTech University
Assignment 1
Due: 23:59, November 12, 2023
Notes
• Please prepare your report with digital typesetting software (LaTeX, Microsoft Word, etc.). Hand-
written reports, including digital handwriting on iPad etc., will not be accepted.
• Please submit your assignment to Blackboard as a zip file with its name formatted as
DIP2023_HW1_ID_ChineseName.zip. The zip file should contain 3 things:
For each problem, you should provide a separate code file that corresponds to it, with its name like
p3.m (for Problem 3) or p6a.m (for Problem 6 (a)). Please make sure all paths in your codes are
relative paths, so that we can run your codes and get your results without any modification.
Policy on Plagiarism
This is an individual homework. You can discuss the ideas and algorithms, but:
• You cannot read, modify, and submit the codes of other students, nor allow other students to read,
modify, and submit your codes.
• You cannot directly use generative AI tools to produce codes for submission. While you may consult
generative AI for understanding the ideas and algorithms, the code you submit must be the result
of your own individual understanding and efforts.
We will utilize automated tools to check for plagiarism, and any violations will result in a zero score for
this assignment.
1
I. Writing Part
An image with intensities in the range [0, 1] has the PDF, pr (r), shown in the following figure. It is
desired to transform the intensity levels of this image so that they will have the specified pz (z) shown in
the figure. Assume continuous quantities, and find the transformation (expressed in terms of r and z)
that will accomplish this. (6 points)
(a) An image is filtered with a kernel whose coefficients sum to 1. Show that the sum of the pixel values
in the original and filtered images is the same. (4 points)
(b) An image is filtered with a kernel whose coefficients sum to 0. Show that the sum of the pixel values
in the filtered image is also 0. (4 points)
2
II. Coding Part
Please complete all the coding assignments using MATLAB. Make sure your results in the report are the
same as the results of your codes. You must implement the core code in each question without using
relevant build-in functions. For general operations, the following functions may be useful:
load, imread, im2double, uint8, imshow, zeros, size, montage, subplot, bar
You can type help FunctionName in Command Window of MATLAB for detailed help text for the
functionality specified by FunctionName.
Implement the function of cropped correlation and convolution, and compute A I B and A H B. The
matrices A and B have been provided for you in p3_matrix.m. Show results in your report. (4 + 4 points)
6 7 3 1 −7
−5 −4 0 4 −7 −3 5 −6
A=
2 −3 3 0 −8
, B = 5 8 −7 .
2 −7 1 9 −2 2 9 4
1 −8 3 −5 −1
Perform bit-plane slicing on the 8-bit picture einstein.tif. In your report, please show the original
image and the images for bit planes 8 through 1 in a 3 × 3 grid (see Figure 3.14 in DIP4e), with bit
plane 1 corresponding to the least significant bit. (8 points)
3
Problem 5: Sobel Operator
Apply the 3 × 3 Sobel kernels (x-direction and y-direction) on building.png. Since the Sobel kernels
are separable, please separate them into combinations of 1-D kernels and then apply them to the image
sequentially.
In your report, you need to show the separated Sobel kernels and the corresponding processed images,
and point out the functionality of each Sobel kernel based on your result. The pixel intensity of the result
images should be normalized to uint8 values within [0, 255]. (16 points)
Perform image sharpening on lena.tif using Laplacian and unsharpen mask (with k = 1) respectively.
(b) The image blurred using a Gaussian lowpass filter (you may select the kernel size k and variation σ
you think is best, but please implement the Gaussian kernel on your own) (3 points), the unsharpen
mask with its pixel intensity normalized to uint8 values within [0, 255] (3 points), and the result
image of unsharp masking with mask weight k = 1 (2 points).
4
Problem 7: Laplacian of Gaussian Filter
Implement LoG kernel with a kernel size of 15, and σ 2 = 1, 4, 10 respectively, then apply these kernels
on cameraman.tif respectively. The pixel intensity of all images should be normalized to uint8 values
within [0, 255]. Show your results in your report. (3 × 3 points)
(a) Compute the histogram of grain.tif (You cannot use built-in functions like hist or histogram).
Show the histogram in your report. (4 points)
(b) Perform histogram equalization on grain.tif. (You cannot use built-in functions like histeq). Show
the histogram equalized image and the histogram of equalized image in your report. (9 points)
(c) Perform adaptive histogram equalization (AHE) on grain.tif with a patch size of 301 × 301 and
a center patch size of 5 × 5 (you cannot use the built-in functions like adapthisteq). Show the
histogram equalized image and the histogram of equalized image in your report. (9 points)
5
Problem 9: Histogram Matching
Match the histogram of lena-RGB.tif to montains.png. Show the result image in your report. (9 points)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: