# Q4 - new data structure using O(n) memory that will allow...

This preview shows page 1. Sign up to view the full content.

Question 4. Integral Images In image processing, a frequent operation is to compute the average image value (intensity) or some other statistic over a rectangular sub-region of the image. The region of interest can be specified by 4 integer parameters: top, bottom, left and right. Not knowing the sub-region in advance, a naïve method would require O(n) time to compute this average, where n is the number of pixels in the image. One could speed this up by precomputing the average for all possible sub-regions: how much memory would this require? Instead, we implement a class called IntegralImage , which will allow the average over an arbitrary rectangular sub-image to be computed in O(1) time, using only O(n) memory. To do this, you will complete two methods. The constructor method IntegralImage will accept an input integer image and will construct a
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: new data structure using O(n) memory that will allow fast computation of sub-image averages. If the input array is not rectangular, IntegralImage will throw an InvalidImageException . The query method meanSubImage will return the average of a specified sub-image in O(1) time. Image indices outside the valid range should be clipped. For example, top = -10 should be interpreted as top = 0, and bottom = 105 should be interpreted as bottom = 99 if the image is only 100 pixels in height. If the specified sub-image is empty, meanSubImage will throw an InvalidSubImageIndexException . Here is a test program testIntegralImage that provides a test case. You should, however, test your program using a broader range of test cases. Pay particular attention to boundary conditions....
View Full Document

## This note was uploaded on 10/28/2010 for the course CSE 2011 taught by Professor Someone during the Summer '10 term at York University.

Ask a homework question - tutors are online