首页 > > 详细

辅导 Assignment 2 Digital Image Processing辅导 留学生Python程序

Assignment 2

Digital Image Processing

1 Filtering in the Frequency Domain (40pts)

a) (10pts) Apply the 2-D DFT to the image below using cv2.dft(), then visualize the Fourier power spectrum and the phase angle. The skeleton code is provided in assi-gnment2 1.py; you need to fill the missing parts (i.e., lines 19-22) and show the results in your report.

(You may need to refer: https://opencv24-python-tutorials.readthedocs.io/en/latest/\py_tutorials/py_imgproc/py_transforms/py_fourier_transform/py_fourier_transform.html)

b) (10pts) Please explain what the phase angle and the power spectrum refer to (obtained in a)), and how frequency components are related to image contents.

c) (20pts) Please use the skeleton code assignment2 1.py to finish the following tasks:

• Filter out the high-frequency parts of image (include both spectrum and phase an-gle) obtained in a) using an ideal low-pass filter with a cutoff frequency 30. Then, transform. the new frequency map back into the spatial domain using cv2.idft(). (you need to fill in lines 48-58.)

• Filter out the low-frequency parts of image (include both spectrum and phase an-gle) obtained in a) using an ideal high-pass filter with a cutoff frequency 30. Then, transform. the new frequency map back into the spatial domain using cv2.idft(). (you need to fill in lines 60-64.)

In you report, you should show the two processed images in the spatial domain and explain their differences. Based on your observation, please explain whether ideal filters are good filters in practice?

2 Image Degradation and Restoration (30pts)

a) (5pts) Use the pepper-salt noise to degrade the image below. (probability of salt noise: 0.25, probability of pepper noise: 0.25; the code is provided in assignment2 2.py, you need to fill in lines 22-30.)

b) (10pts) In this part, we try to restore the image degraded by the pepper-salt noise obtained in a) using two different types of filters.

• The arithmetic mean filter with a kernel size 7 × 7. (you need to fill in lines 46-56)

• The median filter with a kernel size 7 × 7. (you need to fill in lines 60-69)

In your report, it should contain two images restored by different filters. Besides, com-parisons between different restored images are required. (the skeleton code is provided in assignment2 2.py.)

c) (15pts) Suppose we have a degradation system that can blur images using a low-pass gaussian filter (the gaussian low-pass filter is given in the gaussian low pass.npy). Please restore the corresponding degraded image below using the inverse filtering. In your report, you need to display results with different cutoff radius (i.e., 40 and 110), and explain the differences. (you need to fill in line 101, and change the cutoff radius in line 87; the skeleton code is provided in assignment2 2.py.) As shown below, you have three optional solutions to calculate Fˆ(u, v) and you can choose one of them. Note that you will get bonus points if you try more than one solution in your report.

3 Data Compression (30pts)

a) (20pts) In our computer system, each character will occupy 1 bytes (8 bits). Given a string ’AAABBCCCCCCCDDDAAAAA’, please use the Huffman coding to compress it.

1) Construct the Huffman tree and determine the code for each symbol. For this question, you can hand-draw the tree construction process and take a photo to include in your document. (10pts)

2) Calculate the required bits before and after applying Huffman coding, and find the compression ratio. (10pts)

b) (10pts) Please use the provided code assignment2 3.py to compress a 512 × 512 RGB image (’1.bmp’). You can try adjusting the quantization tables (lines 29-55) to obtain a compressed file (’1.gpj’) with different sizes. Then, you can decompress the compressed file to obtain the newly recovered image. Describe your adjustment process and your findings.

Note: the source code should be attached with your submission.







联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!