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
Can you think of a product that you love even though it may not work perfectly? Why do you love it?
Nadya [2.5K]

Answer: Can you think of a product that you love even though it may not work perfectly? Why do you love it?

Explanation: headphone even if they half broken like the ones i have one rn cus i can block my classmates out by blasting my music loudly in the headphones

6 0
3 years ago
Design brief of circuit diagram
Lemur [1.5K]

A design brief should highlight the problem and specifications for the solution.

<h3>What is an electrical circuit?</h3>

An electrical circuit can be defined as an interconnection of different electrical components, in order to create a pathway for the flow of electric current (electrons) due to a driving voltage.

<h3>The components of an electrical circuit.</h3>

Generally, an electrical circuit comprises the following electrical components:

  • Resistors
  • Capacitors
  • Batteries
  • Transistors
  • Switches
  • Wires

<h3>What is a design brief?</h3>

A design brief can be defined as a short statement which is written to describe the need of an individual or business, and what type of solution will meet that need (problem) through the design of an electrical circuit.

This ultimately implies that, a design brief should highlight the problem and specifications for the solution.

Read more on design brief here: brainly.com/question/17848745

#SPJ1

5 0
2 years ago
Need answers for these please ​
Step2247 [10]

Answer:

Following are given the answers one-by-one with explanation:

(a) 8 records

As records are the horizontal rows of data and we have 8 of them.

(b) 5 fields

As fields are vertical columns of data and we have 5 of them.

(c)E3000

As by sorting Makers_names in ascending order the last one would be Rany and by sorting Processor_type we have two option with Rany that are B1500 and E3000. We can see that E3000 will come at the end.

(d) Computer_type

As only two choices (Laptop and PC )  are being used under the column computer_type so it can be amended to contain Boolean data.

(e) format check

This will check that the field should contain one alphabet (capital letter) followed by 4 digits each.

i hope it will help you!

7 0
3 years ago
This is an essential safety procedure that protects workers from injury while working on or near electrical circuits and equipme
Mice21 [21]

Answer:

Option B

Lockout/ Tagout

Explanation:

lockout and tagout is a safety procedure used in most industries and work places. This ensures that during any maintenance work, that dangerous machines are properly shut off and not able to be started up again prior to the completion of maintenance or repair work.

The procedure includes:

1. Turns off and disconnects the machinery or equipment from its energy source(s) before performing service or maintenance.

2. The authorized employee(s) either lock or tag the energy-isolating device(s) to prevent the release of hazardous energy.

8 0
4 years ago
Liquid water enters an adiabatic piping system at 15°C at a rate of 8kg/s. If the water temperature rises by 0.2°C during flow d
Gennadij [26K]

Answer:

23 W/K

Explanation:

Entropy of water at 15°C is 224.5 J/kg/K.

Entropy of water at 15.2°C is approximately 227.4 J/kg/K (interpolated).

The increase in entropy is therefore:

227.4 J/kg/K − 224.5 J/kg/K = 2.9 J/kg/K.

So the rate of entropy generation is:

2.9 J/kg/K × 8 kg/s = 23.2 W/K

Rounded to two significant figures, the rate is 23 W/K.

3 0
3 years ago
Other questions:
  • A network address of 172.16.0.0 /12 has been given. Which of the following accurately describes this network? (select one or mor
    9·1 answer
  • Psychologist who uses behavioral approach to therapy would probably try which of the following
    13·2 answers
  • The purification of hydrogen gas is possible by diffusion through a thin palladium sheet. Calculate the number of kilograms of h
    15·1 answer
  • A banked highway is designed for traffic moving at v = 88 km/h. The radius of the curve r = 314 m. show answer No Attempt 50% Pa
    5·2 answers
  • Consider a metal single crystal oriented such that the normal to the slip plane and the slip direction are at angles of 43.1 deg
    6·1 answer
  • What is the Thermodynamic (Absolute) temperature scale?
    13·1 answer
  • (a) If 5 x 10^17 phosphorus atoms per cm3 are add to silicon as a substitutional impurity, determine the percentage of silicon a
    5·1 answer
  • The passage says that the president's guests "believed the rest at the 'Little
    13·1 answer
  • Define the term 'Computer​
    8·2 answers
  • In order to write a good problem statement, you need to identify the following components of the problem.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!