Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language is C. Please write the functions below, they use the Quad struct. #include imgUtils.c /** * This is the structure we are going to

Language is C. Please write the functions below, they use the Quad struct.

#include "imgUtils.c"

/** * This is the structure we are going to use to store each individual node of * the BST. Remember that each Quad corresponds to a rectangular area on the * image: * * (tx,ty) w * x------------------------- * | | * | | * | | * | | * h | Quad | * | key = tx+(ty*sx) | * | | * | | * | | * | | * -------------------------x * (tx + w, ty + h) * */ typedef struct quad { int tx, ty; // The (x,y) coordinates of the top-left pixel in the quad int w; // How many pixels wide the quad is int h; // How many pixels high the quad is

int sx; // Width of the original image, this is needed for the key. // This *MUST* be the same for all nodes in the BST

int key; // A unique identifier (remember we discussed BST nodes // should have unique keys to identify each node). The // key identifier here will be created as: // key = tx + (ty * sx) // This means that only one quad can start at a specific // pixel.

int wsplit; // 1 if this quad is supposed to be split along the width // 0 if this quad is supposed to be split along the height

/** * TODO: Complete the definition of the Quad struct */

} Quad;

void drawOutline(Image *im, Quad *root, unsigned char col) { /** * Given an image 'im' and a BST rooted at 'root', traverse through each quad * and draw an outline for it. The outline consists of the outermost pixels * of the Quad (ie, the top and bottom rows, and the leftmost and rightmost * columns). * * Make sure that these outlines are of the input colour 'col' that is passed * in. The colour of the remaining pixels should not be changed. * * TODO: Implement this function */

return; }

///////////////////////////////////////////////////////////////////////////////

void save_Quad(Image *im, Quad *root) { /** * Given an image 'im' and a BST rooted at 'root', traverse through each * quad, and set all the pixels in the corresponding area to the expected * colour of the quad computed by your function get_colour(). * * Make sure you index into the pixels array correctly and change the colour * in the image itself. * * TODO: Implement this function */

return; }

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions