INT 302: Image Processing
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Lab 1 – INT 302: Image Processing
Late Submission Policy: 5% of the total marks available for the assessment shall be deducted from the assessment mark for each working day after the submission date, up to a maximum of five working days.
Learning Outcomes
Students completing the module should be able to:
B. Compare various techniques used in digital image processing and assess their strengths and weaknesses.
C. Analyze the application areas of different image processing techniques, such as image enhancement, image transformation, image compression, and morphological operations.
Download the files of lab1-Material.zip from the Learning Mall, unzip the file into a folder lab1- Material, which contains “cameraman.tif”, and “lenna512.bmp”.
Tasks:
Given any grayscale image “cameraman.tif,” complete pixel neighborhood analysis and implement a simple neighborhood-based image operation, with in-depth theoretical explanation and result visualization.
Output the coordinates and grayscale values of the three pixels in the command window.
(b) Define the function getNeighbors(I, x, y, method), where: Inputs: grayscale image I, target pixel coordinates (x,y), method (optional parameter, default='nan', alternative='replicate'). Outputs: 4-neighborhood (coordinate/grayscale matrix), 8- neighborhood (coordinate/grayscale matrix) of the target pixel (3’)
Function logic: When method='nan', mark missing neighborhood pixels as NaN; when method='replicate', use the target pixel's grayscale value to fill missing neighborhood pixels (replication padding).
Replication padding logic: For a boundary pixel (1,1), its upper/left neighborhood pixels are filled with the value of (1,1)
Output the neighborhood coordinates and grayscale values in the MATLAB command window
Visualize results: Display the original image and three subplots (marked with p, q, r and ,their neighborhoods). Mark rules: target pixel (red circle), 4-neighborhood (green ,square), diagonal neighborhood in 8-neighborhood (blue triangle). Add legends, titles, and coordinate labels for each subplot.
(d) Based on the 8-neighborhood function, implement a simple 3×3 neighborhood average filtering function ‘neighborhoodAverageFilter(I)’: (1’)
Traverse each pixel in the image, replace the pixel's grayscale value with the average of its 8-neighborhood pixels (use replicate method for boundary pixels)
(e) Compare and analyze the experimental results in detail:
(1) Analyze the differences in neighborhood pixel quantity and grayscale value distribution among non-boundary pixel p, edge boundary pixel q, and corner pixel r under both nan and replicate methods and explain the advantages and disadvantages of the two padding methods. (3’)
(2) Combined with the results of neighborhood average filtering, explain how pixel neighborhood relationships support local image operations (e.g., filtering). Taking edge detection as another example, describe the role of 4-neighborhood/8- neighborhood in gradient calculation for edge detection. (3’)
|
Image |
nearest |
bilinear |
bicubic |
|
PSNR (dB) |
|
|
|
In this task, we use the monochrome image Lenna (i.e., lenna512.bmp ) to do the following sub tasks, and let’s call this reference image Lenna as im.
a) Add Gaussian white noise with zero mean and variance 25 to the image im and display the noisy image. Name it as im_wn. Please write one function to generate this image instead of calling matlab function directly (you can use Matlab function to generate Gaussian random numbers, e.g., randn()). (8’)
b) Add salt & pepper noise with noise density 15% to the image im and display the noisy image. Name it as im_SP. Please write one function to generate this image instead of calling matlab function directly (you can use Matlab function to generate uniform random numbers, e.g., rand()). (8’)
c) Add one new noise image by combination of both Gaussian noise and salt &pepper noise. Firstly, you randomly select 15% positions of the original image to change thepixel value, Second, you randomly set a Gaussian value for this selected position. The Gaussian distribution is the same as the task (a), i.e., zero mean and variance 25. Please write one function to generate this image. (8’)
d) Apply the median filter with a 3X3 window and a 5X5 window on the image im_SP (you can use Matlab function medfilt2). Display and evaluate the PSNR of the obtained images. For each window size, comment on how effectively the noise is reduced while sharp edges and features in the image are preserved. (8’)
e) Implement the mean filter 3X3 to filter the image im_SP by yourself (you are not allowed to use Imfilter and fspecial directly). Compute the PSNR and display the filtered image. You can use zero padding for the boundary pixels. (8’)
f) As you experimented with the mean and median algorithms, what different “performance” did you notice? Which one is better for removing salt & pepper noise? and why? (10’)
Lab Report
Write a short report which should contain a concise description of your results and observations. Include listings of the Matlab scripts that you have written. Describe each of the images that you were asked to display.
Answer each question completely:
– Do not attach the code at the end of the report, just put the useful code under each question– The results maybe contain some figures, please add some index and title of each figure
Submission before 2026-04-02 11:59pm.
– Electrical version to LM with a ZIP of all files
• Rar file name: INT302-Lab1-Name-studentID. zip• One file with same file name of zip File: Report ( with studentID, name, Lab title on the homepage)• One folder: codes and other materials. (I can run it directly)
80%-100% Essentially complete and correct work.
60%-79% Shows understanding, but contains a small number of errors or gaps.
40%-59% Clear evidence of a serious attempt at the work, showing some understanding, but with important gaps.
20%-39% Scrappy work, bare evidence of understanding or significant work omitted.
<20% No understanding or little real attempt made.
2026-03-31