首页 > > 详细

讲解Python、Python编程辅导、辅导Python

Introduction
This final assignment for the course focuses on implementing a number of the binary image 
processing and analysis routines that have been explained in the course lectures. You may complete
the assignment using either python/(i.e. as in the previous assignment) or in matlab. 
Matlab
In order to do the assignment in matlab it is advisable to have access to the image processing 
toolbox, and in particular the necessary routines to loading images, viewing images, etc.
Python
In order to do the assignment in python it is advisable to have scipy installed, and in particular 
scipy.ndimage which provides an implementation of the labelling algorithm. It is also 
beneficial to have access to matplotlib, and in particular matplotlib.pyplot.imshow 
for visualising the result of the labelling process.
Q1. For the first part of this assignment you should learn to generate test images for questions 2 and
3 below. The type of images required are binary images containing one or more objects. Using what
you have learned in lectures determine the set of steps required to produce the image on right image
from the left image. 
The example grayscale image below is provided from the course webpage (pens.tif).  
Hint: 
If you are using python you should be aware that when you load the pens image although it looks 
grayscale, it will be represented as a 3­channel color image. Given this it is best to first convert it to 
a single channel grayscale image which you can do using the following command:
G = cv2.cvtColor(X,cv2.COLOR_BGR2GRAY); 
Q2. Matlab's image processing toolbox provides the bwlabel function to perform. blob labelling 
on an input image. In python the equivalent funcitonality is provided by 
scipy.ndimage.measurements.label 
A useful approach to visualising the result of the matlab bwlabel algoritm is to use imagesc.
For python's scipy.ndimage.measurements.label you can use matplotlib.pyplot.imshow.
In order to obtain a better understanding of the labelling process, use the pseudo­code provided in 
lectures to implement your own labelling function. Validate it's operation on your thresholded pen 
image from question 1. Your labelling function should take as input a binary image, and return as 
output a both a labelled image and the number of labelled objects found within the image.
Q3. Develop two functions, object_area and object_position, which take as input a 
labelled image and an object label and output the relevant information (i.e. area or position) for the 
corresponding object.
Q4. Finally, demonstrates the methods above by writing a driver routine that takes the pens.tif 
image as input and displays the position of each of the pens in the image by displaying the image 
and overlaying a point on top of each pen. An example output is shown at the top of the next page.
Submission: You should submit your solution via the moodle upload link for the assignment. Your 
solution should be uploaded as a zip file with all of your code and a readme.txt file that provides an 
explanation of the relationship of each file to the questions in the assignment. Each code file should 
be commented to a level that would be required for someone to understand the workings of your 
solution. 
If you have any questions regarding the assignment please feel free to contact me @ 
 or call to my office (office 115, Eolas Building).
 

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

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