# Image Processing in Python

Τεχνίτη Νοημοσύνη και Ρομποτική

6 Νοε 2013 (πριν από 4 χρόνια και 6 μήνες)

80 εμφανίσεις

Image Processing in Python

Please download the new image and the Python files that I have placed on the server and delete any previous

Scale
-
space is an important paradigm for feature extraction in images. Scale
-
space allows
for multi
-
scale
analysis with the guarantee that feature maximums do not migrate across scales. Our approach is to compute
spatial derivatives of the image and larger and larger scales. We do this by convolving the image with
derivatives of Gaussians with
successively larger widths. Integration across scales is usually done by taking the
maximum response across the scales at each pixel location.

Convolving an image with a Gaussian kernel is
equivalent to multiplying the Fourier spectrum by a Gaussian, as w
e did in class.

In the file python_class_chapman.py I have written a routine (hw1) which implements a scale
-
space filtering
technique for vascular images introduced by Frangi et al. (Lecture Notes in Computer Science 1496).
The code
differentiates vascula
r (tubular) structures from background using the curvature (second derivative) of the pixel
intensities.
The code provides examples of a variety of tools we looked at in class. I have also added some lines
which use Python Imaging Library objects.

The code

reads in an image, applies the filter and then thresholds the
image to get a binary mask of the vasculature. It also creates a binary mask of the vasculature in the
unprocessed image for comparison.

The homework consists of a simple exploration.

You will

have to do some modifications of the code, but they
are all minor. All the necessary documentation is in the Numpy manual and the PIL manual that come as PDF
files in the distribution.

1.

Determine what the minimum (maximum?) number

of scales that should be used to get a good
enhancement of the vasculature. What happens to the image if you use very large scales?

2.

As implemented the filter uses an exponential growth function for sigma. Change this to a linear
growth function and compar
e the results.

3.

Reverse the grayscale of the image by subtracting the image from its maximum value.
(
MLab.max(img.flat) returns the maximum value of img. If you don’t use the flat option on img, it
won’t give you what you want.
)
What needs to be changed in
the filter to make it work on the reversed
image? Remember that the curvature
s

a ridge
and a valley have

a different sign.

4.

Apply noise to the image. Generate Gaussian noise with zero mean and a standard deviation
specified by you. What level of noise degra
des the filter response? Would you say that the filter was
robust in the presence of noise

5.

Generate and save images showing the intermediate steps of the filter (for example the kxx image
which is the second derivative computed in the x direction). Save th
e images as jpegs with a quality
factor of 80%.

Scale
-
space applications can eat up a lot of memory
, and I didn’t try to code it efficiently
. If you don’t have
sufficient memory to process the 512x512 image, subsample
the variable data

down to 256x256 imm
ediately
after generating
it with the img.get_all() command. You can do this with the slicing as we did in class. An
example can be seen in the ClassImageUtils.py file.

Feel free to email me (
chapmanbe@upmc.edu
)

with any questions you might have.