
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Exercise 26 Programming Task: This exercise introduces Object Oriented Programming with. Python. The goal is to write classes to apply a filter kernel to an ...
Typology: Study notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Exercises for Introduction to Pattern Recognition (IntroPR) Lennart Husvogt Work sheet 11, 11.01.
Python. The goal is to write classes to apply a filter kernel to an image in single and multi-scale filtering. You can find an introduction to OOP in Python here https: //docs.python.org/3.5/tutorial/classes.html.
Write a class Filter that allows to filter an image using a filter kernel. Add methods set image(img) and set kernel(kernel). Calling filter() should filter the image. Since applying the filter kernel close to the image borders may yield undefined results, ignore image pixels when the kernel might cover out-of-image areas. The result should be saved in filtered image. Use the constructor init to define a default filter kernel.
Write a class MRFilter that performs image filtering at different image scales. The filtered images should be saved in the list filtered images. Override the method filter() from the base class but call the base class version of it for filtering. You can use super(self. class , self).method() to call a method from a base class. The source image should be scaled down by a factor of 2 after each iteration.