Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a c++ program: Download Tamu-commerce_logo-pixels.zip from Doc Sharing sec

ID: 3762202 • Letter: W

Question

Write a c++ program:

Download Tamu-commerce_logo-pixels.zip from Doc Sharing section of this course. This zip file includes Logo_red.txt,Logo_green.txt, Logo_blue.txt files, which are color layer of our university's spirit logo, Lion. The image has size of 86x86 pixels. A pixel is unit size in image, and composed of 3 bytes (red, green, blue).

You responsibilities includes followings:

Define and initialize a 3D array to keep RGB pixels structured.

Read pixels from three different files into your 3D array (you read the data from file number-by-number).

Find average values for each layer R (red), G (green), B (blue) (Array[i][j][0] + Array[i][j][1]  + Array[i][j][2] ) /3, which is called intensity of a pixel. In the notation of Array[i][j][c], c is the color band, i anc j are location of the pixel.

Find maximum and minimum intensity pixels of the image. Also, print out those pixel addresses of min an max values. Intensity is average of R, G, and B values. In case of multiple minimum and maximum values, you should show all of the pixel locations.

List address (x, y location) of pixels meeting if pixel's Red value is less than pixel's Blue value.

Constrains: You need to read each source file just once.

Logo_blue Notepad File Edit Format View Help 173 102 123 153 102 173 107 165 115 173 165 173 153 173 165 107 123 173 123 115 173 173 107 107 173 123 181 153 153 102 213 213 173 123 115 123 153 123 107 107 100 123 123 123 123 123 123 107 108 100 173 132 123 123 123 123 102 153 165 213 173 173 173 115 108 115 123 123 123 123 123 110 107 123 115 189 106 123 116 173 165 132 102 123 115 108 115 115 153 123 123 123 123 123 123 123 123 123 110 100 108 116 173 213 102 132 165 181 173 153 132 107 213 173 107 64 123 123 123 123 115 8:49 PM 11/12/2015 Search the web and Windows

Explanation / Answer

Hi,

please find the code below to store the RGB in 3D array

  #include <iostream>  #include <jerror.h>  #include <jpeglib.h>  using namespace std;  int main()  {  FILE *pic = fopen( "image.jpeg", "rb+" );      if ( pic == NULL )      {          return 0;      }    struct jpeg_decompress_struct info;  struct jpeg_error_mgr err;    info.err = jpeg_std_error( &err );       jpeg_create_decompress( &info );    jpeg_stdio_src( &info, pic );      jpeg_read_header( &info, true );    jpeg_start_decompress( &info );    int w = info.output_width;  int h = info.output_height;  int n = info.num_components;  type = GL_RGB;        if(n == 4) type = GL_RGBA;    data_size = x * y * 3;  jdata = (unsigned char *)malloc(data_size);  for (;info.output_scanline < info.output_height;)      {      rowptr[0] = (unsigned char *)jdata + 3*info.output_width*info.output_scanline;       jpeg_read_scanlines(&info, rowptr, 1);  }    int picture[w][h][n];  for(int i=0;i<w;i++)          for(int j=0;j<h;j++)                  for(int z=0;z<n;z++)                          picture[i][j][z]=/*dont know what to do with this or how to save the bytes as values 0-255*/;     jpeg_finish_decompress( &info );   fclose(pic);  free (jdata);    return 1;  }  
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote