Object Oriented Programming in Python (New Sheet), Study notes of Object Oriented Programming

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

2021/2022

Uploaded on 08/05/2022

nguyen_99
nguyen_99 🇻🇳

4.2

(80)

1K documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Exercises for
Introduction to Pattern Recognition (IntroPR)
Lennart Husvogt
Work sheet 11, 11.01.2016
Object Oriented Programming in Python (New Sheet)
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 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.

Partial preview of the text

Download Object Oriented Programming in Python (New Sheet) and more Study notes Object Oriented Programming in PDF only on Docsity!

Exercises for Introduction to Pattern Recognition (IntroPR) Lennart Husvogt Work sheet 11, 11.01.

Object Oriented Programming in Python (New Sheet)

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 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.