1. Learn
  2. /
  3. Courses
  4. /
  5. Biomedical Image Analysis in Python

Exercise

Detect edges (1)

Filters can also be used as "detectors." If a part of the image fits the weighting pattern, the returned value will be very high (or very low).

In the case of edge detection, that pattern is a change in intensity along a plane. A filter detecting horizontal edges might look like this:

weights = [[+1, +1, +1],
           [ 0,  0,  0],
           [-1, -1, -1]]

For this exercise, create a vertical edge detector and see how well it performs on the hand x-ray (im).

Instructions

100 XP
  • Create a 3x3 array of filter weights that detects when intensity changes from the left to right. Use only the values 1, 0 and -1.
  • Convolve im with the edge detector.
  • Plot the horizontal edges with the seismic colormap. Use vmin=-150 and vmax=150 to control adjust your colormap scale.
  • Add a colorbar and render the results.