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
Copper is generally considered easy to weld because of its high thermal conductivity: (a) true or (b) false?
inn [45]

Answer:

b)False

Explanation:

Those material have high thermal it is very difficult to weld because due to high thermal conductivity it transmit the heat in to the surrounding and can not reach a particular temperature required to melt the material.And when material does not melt then there is no possibility to weld the material.

So from above we can say that it is very difficult to weld the copper material due to high thermal conductivity.Generally welding of copper done by usiong gas welding technique.

So our option b is right.

8 0
3 years ago
Oil enters a counterflow heat exchanger at 600 K with a mass flow rate of 10 kg/s and exits at 200 K. A separate stream of liqui
Elis [28]

Answer:

The minimum mass flow rate for the water is 14.39kg/s

Explanation:

In this question, we are asked to calculate the minimum mass flow rate for the water in kg/s.

Please check attachment for complete solution and step by step explanation

7 0
3 years ago
A) Gravity attracts horizontally downwards the weight of any object such a building or a part of building. (True / False)
PtichkaEL [24]

Answer:

  1. True
  2. True
  3. False
  4. True

Explanation:

  • True
  • True
  • False
  • True

3 0
3 years ago
In a 1D compression test with double drainage, the pore pressure readings are practically zero after 8 minutes for a clay sample
frosja888 [35]

Answer:

The duration of the consolidation process for the same clay is 32 min

Explanation:

for clay 1:

t1=0

H1=thickness=2 cm

for the clay 2:

t2=?

H2=2 cm

The time factor is equal to:

T=(\frac{Cv}{d^{2} })t

where Cv is the coefficient of consolidation

(\frac{Cvt}{d^{2} })_{1}=  (\frac{Cvt}{d^{2} })_{2}

if Cv is constant, we have:

(\frac{t1}{(\frac{H1}{2}) ^{2} })_{1}=(\frac{t2}{H2^{2} })_{2}\\\frac{0}{(\frac{2}{2})^{2})  }=\frac{t2}{2^{2} }

Clearing t2:

t2=32 min

3 0
3 years ago
What type of steel would a motor vehicle body be manufactured from?​
Delvig [45]

Answer:

Stainless steel

Explanation:

Hope I answered your question.

8 0
3 years ago
Other questions:
  • A wood pipe having an inner diameter of 3 ft. is bound together using steel hoops having a cross sectional area of 0.2 in^2. The
    12·1 answer
  • Steam enters a well-insulated turbine operating at steady state at 4 MPa with a specific enthalpy of 3015.4 kJ/kg and a velocity
    5·1 answer
  • What is tcp in network?
    13·1 answer
  • Which of the following is an acronym for a recently introduced type of vehicle that has a high fuel economy rating?A.SUVB.AQIC.H
    6·1 answer
  • The cylindrical aluminum air tank below is to be rated for 300 psi and it must comply with the ASME Boiler Code which requires a
    5·2 answers
  • An incompressible fluid flows along a 0.20-m-diameter pipe with a uniform velocity of 3 m/s. If the pressure drop between the up
    15·1 answer
  • A steady state filtration process is used to separate silicon dioxide (sand) from water. The stream to be treated has a flow rat
    5·1 answer
  • Suppose the cylinder had a mass of 20 kg and started at a height of 2,000 m. If the initial temperature of the water was 25 °C,
    8·2 answers
  • (SI units) Molten metal is poured into the pouring cup of a sand mold at a steady rate of 400 cm3/s. The molten metal overflows
    9·1 answer
  • which of the following is not a general education elective area? group of answer choices humanities/fine arts social/behavioral
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!