Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My code so far: #include #include #include #include #include #include #include #include using namespace std; bool check(int x, int y, int s){ if (x>=s ||

image text in transcribedimage text in transcribed

image text in transcribed

My code so far:

#include #include #include #include #include #include #include #include

using namespace std;

bool check(int x, int y, int s){ if (x>=s || y>=s) { return true; }else{ return false; } }

class Count_Pixels { public: vector count_pixels_in_regions(vector > &image, vector, pair > > ®ions); };

int main(){ Count_Pixels pixel_count[]; Count_Pixels image[]; pixel_count[0,0] = image[0,0]; int n = 0; int m = 0;

for (int i=0;i

Anything would help, I'm very lost.

Introduction Given a rectangular region (n x m) in a black and white image, it is easy to count how many pixels are on (1) via a straightforward algorithm that runs in time O(nm) steps. If we want to do this for a number (k) of rectangular regions in a single image, we can save time by preprocessing the image. In particular, if we have k regions, each of size n xn, the straightforward algorithm would take O(k: nn) steps. As described below, we can preprocess the entire n x m image so that counting the number of pixels in the k regions takes only O(n m + k) steps. With this approach, the preprocessing takes O(n.m) steps and computing the pixel count for the k regions taking only O(k) steps, irrespective of the size of the individual regions. Counting White Pixels via Preprocessing Given a black and white (1=white, 0 = black) image of size n x m, it is relatively straight- forward to count how many pixels are on (1) in the region from the origin (pixel 0,0) to any given pixel (i, j). In fact, we can compute all of these values using the following algorithm. pixel_count [0,0] = image [0,0]; for (int i=0;i >. The test harness will also read in a file containing information about a number of regions in the image, and it will store this information in a vector vector, pair > >. Your program (class) will output a vector containing the sum of the on pixels in each region using the approach described above. The prototype for your class is as follows: class Count_Pixels { public: vector count_pixels_in_regions (vector > & image, vector, pair > > ®ions); }; You may add other private or public member functions and data to your class, but do not change the prototype give above. Implement your class using the fast (pre-processing based) algorithm described above. Try to make your code as fast as possible<><>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MFDBS 91 3rd Symposium On Mathematical Fundamentals Of Database And Knowledge Base Systems Rostock Germany May 6 9 1991

Authors: Bernhard Thalheim ,Janos Demetrovics ,Hans-Detlef Gerhardt

1991st Edition

3540540091, 978-3540540090

More Books

Students also viewed these Databases questions

Question

Which of the following data declarations is invalid?

Answered: 1 week ago

Question

What is American Polity and Governance ?

Answered: 1 week ago

Question

What is Constitution, Political System and Public Policy? In India

Answered: 1 week ago

Question

What is Environment and Ecology? Explain with examples

Answered: 1 week ago