1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
andrew11 [14]
3 years ago
14

Implement

Engineering
1 answer:
kolbaska11 [484]3 years ago
6 0

Answer:

#include <iostream>

using namespace std;

// Pixel structure

struct Pixel

{

unsigned int red;

unsigned int green;

unsigned int blue;

Pixel() {

red = 0;

green = 0;

blue = 0;

}

};

// function prototype

int energy(Pixel** image, int x, int y, int width, int height);

// main function

int main() {

// create array of pixel 3 by 4

Pixel** image = new Pixel*[3];

for (int i = 0; i < 3; i++) {

image[i] = new Pixel[4];

}

// initialize array

image[0][0].red = 255;

image[0][0].green = 101;

image[0][0].blue = 51;

image[1][0].red = 255;

image[1][0].green = 101;

image[1][0].blue = 153;

image[2][0].red = 255;

image[2][0].green = 101;

image[2][0].blue = 255;

image[0][1].red = 255;

image[0][1].green = 153;

image[0][1].blue = 51;

image[1][1].red = 255;

image[1][1].green = 153;

image[1][1].blue = 153;

image[2][1].red = 255;

image[2][1].green = 153;

image[2][1].blue = 255;

image[0][2].red = 255;

image[0][2].green = 203;

image[0][2].blue = 51;

image[1][2].red = 255;

image[1][2].green = 204;

image[1][2].blue = 153;

image[2][2].red = 255;

image[2][2].green = 205;

image[2][2].blue = 255;

image[0][3].red = 255;

image[0][3].green = 255;

image[0][3].blue = 51;

image[1][3].red = 255;

image[1][3].green = 255;

image[1][3].blue = 153;

image[2][3].red = 255;

image[2][3].green = 255;

image[2][3].blue = 255;

// create 3by4 array to store energy of each pixel

int energies[3][4];

// calculate energy for each pixel

for (int i = 0; i < 3; i++) {

for (int j = 0; j < 4; j++) {

energies[i][j] = energy(image, i, j, 3, 4);

}

}

// print energies of each pixel

for (int i = 0; i < 4; i++) {

for (int j = 0; j < 3; j++) {

// print by column

cout << energies[j][i] << " ";

}

cout << endl;

}

}

// function prototype

int energy(Pixel** image, int x, int y, int width, int height) {

// get adjacent pixels

Pixel left, right, up, down;

if (x > 0) {

left = image[x - 1][y];

if (x < width - 1) {

right = image[x + 1][y];

}

else {

right = image[0][y];

}

}

else {

left = image[width - 1][y];

if (x < width - 1) {

right = image[x + 1][y];

}

else {

right = image[0][y];

}

}

if (y > 0) {

up = image[x][y - 1];

if (y < height - 1) {

down = image[x][y + 1];

}

else {

down = image[x][0];

}

}

else {

up = image[x][height - 1];

if (y < height - 1) {

down = image[x][y + 1];

}

else {

down = image[x][0];

}

}

// calculate x-gradient and y-gradient

Pixel x_gradient;

Pixel y_gradient;

x_gradient.blue = right.blue - left.blue;

x_gradient.green = right.green - left.green;

x_gradient.red = right.red - left.red;

y_gradient.blue = down.blue - up.blue;

y_gradient.green = down.green - up.green;

y_gradient.red = down.red - up.red;

int x_value = x_gradient.blue * x_gradient.blue + x_gradient.green * x_gradient.green + x_gradient.red * x_gradient.red;

int y_value = y_gradient.blue * y_gradient.blue + y_gradient.green * y_gradient.green + y_gradient.red * y_gradient.red;

// return energy of pixel

return x_value + y_value;

}

Explanation:

Please see attachment for ouput

You might be interested in
Sarah needs to create an architectural drawing for a museum building with an inclined surface. Which presentation view will be t
prohojiy [21]

Answer: auxiliary

Explanation: got it right

7 0
3 years ago
In C++ the declaration of floating point variables starts with the type name float or double, followed by the name of the variab
zubka84 [21]

Answer:

The given grammar is :

S = T V ;

V = C X

X = , V | ε

T = float | double

C = z | w

1.

Nullable variables are the variables which generate ε ( epsilon ) after one or more steps.

From the given grammar,

Nullable variable is X as it generates ε ( epsilon ) in the production rule : X -> ε.

No other variables generate variable X or ε.

So, only variable X is nullable.

2.

First of nullable variable X is First (X ) = , and ε (epsilon).

L.H.S.

The first of other varibles are :

First (S) = {float, double }

First (T) = {float, double }

First (V) = {z, w}

First (C) = {z, w}

R.H.S.

First (T V ; ) = {float, double }

First ( C X ) = {z, w}

First (, V) = ,

First ( ε ) = ε

First (float) = float

First (double) = double

First (z) = z

First (w) = w

3.

Follow of nullable variable X is Follow (V).

Follow (S) = $

Follow (T) = {z, w}

Follow (V) = ;

Follow (X) = Follow (V) = ;

Follow (C) = , and ;

Explanation:

4 0
3 years ago
HfrrghhJbfrfefefft nbgyjjiutrwdgju
Tasya [4]

Answer:

hshdhriwjajaldh skshdjdywuusg

Explanation:

null

4 0
3 years ago
Fictional Corp is looking at solutions for their new CRM system for the sales department. The IT staff already has a fairly heav
Oksi-84 [34.3K]

Answer:

SaaS

Explanation:

Software as a service (SaaS) is also called software on demand, it involves a third party that centrally hosts the software and provides it to the end user.

All aspects of hosting is handled by the third party: application, data, runtime, middleware, operating system, server, virtualization, storage and networking are all handled by the provider.

This is an ideal software service for Fictional corp, as there will be no need to hire additional IT staff to maintain the new CRM software.

3 0
3 years ago
When you multiply monomials with the same variables, you multiply the coefficients and add the exponents!
RideAnS [48]

Answer: ok

Explanation:

this isn't a question?

3 0
3 years ago
Other questions:
  • An old refrigerator consumes 247 W of power. Assuming that the refrigerator operates for 19 hours everyday, what is the annual o
    15·2 answers
  • function summedValue = SummationWithLoop(userNum) % Summation of all values from 1 to userNum summedValue = 0; i = 1; % Write a
    11·1 answer
  • What does this map show about the Viking civilization?
    7·2 answers
  • The 10 foot wide circle quarter gate AB is articulated at A. Determine the contact force between the gate and the smooth surface
    10·1 answer
  • During an experiment conducted in a room at 25°C, a laboratory assistant measures that a refrigerator that draws 2 kW of power h
    13·1 answer
  • In water and wastewater treatment processes a filtration device may be used to remove water from the sludge formed by a precipit
    10·1 answer
  • Describe the engineering design process in your own words.
    6·2 answers
  • When an output gear is larger than the input gear the greater ratio is greater than 1 T or F​
    9·1 answer
  • Un material determinado tiene un espesor de 30 cm y una conductividad térmica (K) de 0,04 w/m°C. En un instante dado la distribu
    13·1 answer
  • What is the creative process that helps you overcome writer's block called?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!