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
High strength steels are being used to reduce weight on cars. Explain why using a high strength steel would allow you to reduce
gulaghasi [49]

Engaging the frequently tough requirements of vehicle safety, weight reduction for combustible economy, and manufacturability has influenced the steel industry to create a unique variety of 'super steels' for the automobiles of the future.

<h3><u>Explanation</u>:</h3>

• That steel, though, is far more advanced than the materials of just a few years ago.

• At the forefront of these is Advanced High Strength Steel, AHSS, developed by World Auto Steel’s member companies, which is demonstrating to be something of a vision in automobile production.  

• The standard engineering trade-off in steel preference involves considering the need for ultimate strength against flexibility and work-ability – stronger steels tend to be stiffer and less ductile, making them more difficult to develop into cars and more laborious to weld.

• AHSS can retain greatest of the ductility and work-ability of lower grades of steel, while offering much greater strength.

• Where a typical mild steel might have a tensile strength of 300MPa, AHSS can exceed 1500MPa while retaining a highest elongation of 25%, compared to about 40% for mild steel. The intrigue is in the micro-structure, containing a martensite, bainite, austenite phase rather than ferrite, pearlite, or cementite.

4 0
3 years ago
Why is the face of the claw on a claw hammer usually a smooth curve? Why isn't it straight or some other shape?
GarryVolchara [31]

Answer:

The face of the claw on the claw hammer is usually a smooth curve so as to improve the ease with which nails are removed when removing nails because as the nail held between the V shaped split claw is being pulled out from the wood, it slides more and more towards cheek, reducing the distance of the nail from the cheek which is the fulcrum, thereby increasing the mechanical advantage because the location of the hand on the grip remains unchanged

Explanation:

7 0
3 years ago
If a master cylinder piston applies pressure to a brak piston that has twice as much square area what will be the force from the
sp2606 [1]

Explanation:

Pressure = force/area

Pressure stays the same.

If the area is doubled the force is doubled.

5 0
4 years ago
T
solniwko [45]

Answer:

Common Uses: Boxwood is well-suited for carving and turning, and the tree's diminutive size restricts it to smaller projects. Some common uses for Boxwood include: carvings, chess pieces, musical instruments (flutes, recorders, woodwinds, etc.), rulers, handles, turned objects, and other small specialty items.If you want a small, compact, low-growing shrub to form a hedge that serves as an accent or border along your walkway, fence line or planting beds, dwarf boxwood varieties are the best pick. The "Dwarf English" boxwood (Buxus sempervirens “Suffruticosa”) creates a border hedge approximately 1 to 2 feet in height.

Explanation:

3 0
3 years ago
How much work is required to move an electron from the positive terminal to the negative terminal of a 12 V battery? (Knight 21.
Ray Of Light [21]

Answer:

work which is required to move an electron from the positive terminal to the negative terminal is

-4μJ

W = -4μJ

Explanation:

Work required to move the charge

W = qΔV

initial point V₁ = 150V

Final point V₂ = -50V

W = q(V₂ -V₁)

= 20 × 10⁹(-50 - 150)

W = -4μJ

work which is required to move an electron from the positive terminal to the negative terminal is

-4μJ

6 0
3 years ago
Other questions:
  • A material condition used to indicate that a specified geometric tolerance applies at each increment of size of a feature within
    15·1 answer
  • A refrigerator removes heat from a refrigerated space at 0°C at a rate of 2.2 kJ/s and rejects it to an environment at 20°C. wha
    15·1 answer
  • An air standard cycle with constant specific heats is executed in a closed pistoncylinder system and is composed of the followin
    10·1 answer
  • If the power factor is corrected to 0.95 lagging, keeping the receiving end MVA constant, what will be the new voltage regulatio
    6·1 answer
  • PLEASE HELP ME ASAP AND PLEASE answer correctly. If I said that it is 70 degrees Fahrenheit today (21 degrees Celsius), is that
    12·2 answers
  • After the 2015 AFC Championship football game between the New England Patriots and the Indianapolis Colts, it was alleged that t
    10·1 answer
  • Nitrogen enters a steady-flow heat exchanger at 150 kPa, 10°C, and 100 m/s, and it receives heat as it flows through it. Nitroge
    15·1 answer
  • Carbon nanotubes can be a considered toxic agent due to: (a)- Its ability to produce toxic gases (b)Its ability to penetrate ski
    8·1 answer
  • An AM signal having a carrier frequency of 460 kHz is to be mixed with a local oscillator signal at a frequency of 1135 kHz. Wha
    11·1 answer
  • A furniture manufacturer purchases a drill press machine enabled with 5G and edge computing capabilities to keep the machine ope
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!