Lab - Laplacian Pyramids

Computer Vision (CSCI 4220U)

Faisal Qureshi

Faculty of Science, UOIT

http://vclab.science.uoit.ca


Consider the following python file called lpyr.py that loads and displays an image.

lpyr.py

# Python 2.7

import argparse
import cv2
import numpy as np
from matplotlib import pyplot as plt

def process_img(imgfile):
    print 'Opening ', imgfile
    img = cv2.imread(imgfile)
    cv2.imshow('img', img)
    print 'print any key'
    cv2.waitKey(0)

    // Complete this function
    //
    // This function converts the image into grayscale
    // and constructs a Laplacian pyramid from this image.
    // The smallest size of the image in the pyramid is 
    // determined by minsize argument
    lpyr = make_lpyr(img, minsize=128)
    for i in lpyr:
        cv2.imshow('lpyr', i)
        print 'press any key'
        cv2.waitKey(0)

    cv2.destroyAllWindows()

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Laplacian pyramids.')
    parser.add_argument('imgfile', help='Image file')
    args = parser.parse_args()

    process_img(args.imgfile)

Implement make_lpyr() method, which constructs a Laplacian pyramid for the input image. It first converts the passed image into grayscale.

What to submit

Submit lpyr.py via Blackboard.