Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use c++ please ======== Purpose: This assignment will teach you about pointers, classes, data structures, and making good tests for yourself. Location: All of your

image text in transcribed

image text in transcribed

image text in transcribed

Use c++ please

======== Purpose: This assignment will teach you about pointers, classes, data structures, and making good tests for yourself. Location: All of your coding will be done in "you.cc". Don't modify main.cc. Objective: For this assignment you will implement a simple image recognition library. You must scan through an image to find all blue pixels and return the x,y coordinate of the center of all of them. Consider this image: https://tinyurl.com/bluecirc It has a red square, a purple polygon, and a blue circle. Your program should return the x,y coordinates of the center of the circle. x is horizontal, y is vertical. 0,0 is the top left corner of the image. Images are 3D arrays of color data. The x and y coordinates are the x and y coordinates of the image. The z axis is color. The first color is red, the second green, the third blue. You will be given a 1D array containing color data. These are all unsigned chars, with 0 meaning black and 255 meaning full color. Example. Suppose I give you a 3x3 pixel image (this is a very small image!) that has a single purple (255 red, 0 green, 255 blue) pixel in the bottom left corner. If I was to draw what this array would look like in 3D, it'd be something like this: Red Plane: 255 0 Green Plane: Blue Plane: 255 0 But of course it would be too easy to give you a data structure with the data organized as all this. All you are going to get is what *I* got when I started work on this assignment, which is a pointer to a 1D array holding all of that data in order. Read from left to right, like a book, and those numbers above look like this: Biue Plane: 255 0 But of course it would be too easy to give you a data structure with the data organized as all this. All you are going to get is what got when I started work on this assignment, which is a pointer to a ib array holding all of that data in order. Read from left to right, like a book, and those numbers above look like this: 255 0 0 0 0 0 0 0 0 0 0 0 0 0 255 0 Every three numbers (the width of the image in my example) is a new row. Every three times three numbers (the width x the height) is a new color. 1) You will be given a pointer to the start of this chunk of memory, the width, and the height. I recommend making a vector or something to store the data in, or write a function to be able to select the color data at a given x and y location. 2) Loop over the image and record the location of every blue pixel. "Blue" means the blue value at a pixel is between 236 and 255, and its red and green values at that point are both below 20. I recommend you find very small sample images to test your code on. This is an integral part of the "learning to be a programmer" process - finding good tests to test your code on. Here's one I found that might be helpful - https://tinyurl.com/bluerekt 3) Output to the standard output the (x, y) location of the center of all blue pixels in the image, like this: "The center point for blue in this image is: (49, 49) ". If there is no blue at all in the image, print: "No blue found." Sample run: Please enter a URL or file name to load: https://tinyurl.com/bluerekt Loaded image of size 100x100 The center point for blue in this image is: (49,49) Sample run #2: https://tinyurl.com/bluecirc Loaded image of size 600x600 The center point for blue in this image is: (465,130) include include using namespace std; //PODS struct Pixel { int x,y: void image search (unsigned char data, int width, int height) { vector blues; //YOU: Fill this vector with all the blue pixels, maybe //DELETEME- This prints all the values in data for (int i = 0; i include using namespace std; //PODS struct Pixel { int x,y: void image search (unsigned char data, int width, int height) { vector blues; //YOU: Fill this vector with all the blue pixels, maybe //DELETEME- This prints all the values in data for (int i = 0; i

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions