1.
A pixel is the smallest controllable element of a picture represented on the screen. Images are comprised of numerous individual pixels, and each pixelβs color sample has three numerical RGB (red, green, blue) components to represent the color of that pixel. The intensity value of each RGB component ranges from 0 to 255, where 0 is no intensity and 255 is highest intensity. Write the
struct definition for Pixel, which has values for each component r, g, and b.
Solution.
Below is one way to implement the program. We declare the Pixel struct and create the instance variables in order.
#include <iostream>
#include <vector>
using namespace std;
struct Pixel {
int r;
int g;
int b;
};
