Thread: Help on reading correctly the image...

  1. #1
    Registered User
    Join Date
    Jul 2020
    Posts
    9

    Help on reading correctly the image...

    Hi to all!I have in c a sobel filter detction code that runs correctly.I want to transform the arrays from 2D to 1d and get the same result but the output image is wrong....To mention that i am new to C language.Any help woud be precious.

    Original Code....

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <math.h>
    #include <string.h>
    
    
    #include "Image.h"    
        
    RGBQUAD image[2048][2048];          // Image as input
    
    
    int main(int  argc, char *argv[])
    {
      char *filename = 0;
      FILE *fp;
      FILE *wp;
      int width, height;
      int i, j, x, y, T;
      BitmapFileHeader bmfh;
      BitmapInfoHeader bmih;    
      unsigned char ee_image[2048][2048];
    
    
      // Reading inputs: bayer image and threshold
      if (argc == 3){
        filename = argv[1];
        T = atoi(argv[2]);
      } else{ 
        printf("Give a bmp image and a threshold as input\n");
        exit(0); 
      }
          
      // Opening the file: using "rb" mode to read this *binary* file
      printf("Opening filename: %s\n", filename);
      fp = fopen(filename, "rb");
    
    
      // Reading the file header and any following bitmap information...
      fread(&bmfh, sizeof(BitmapFileHeader), 1, fp);
      fread(&bmih, sizeof(BitmapInfoHeader), 1, fp);
    
    
      printf("Header Info\n");
      printf("--------------------\n");
      printf("Size:%i\n", bmfh.bfSize);
      printf("Offset:%i\n", bmfh.bfOffBits);
      printf("--------------------\n");
      printf("Size:%i\n", bmih.biSize);
      printf("biWidth:%i\n", bmih.biWidth);
      printf("biHeight:%i\n", bmih.biHeight);
      printf("biPlanes:%i\n", bmih.biPlanes);
      printf("biBitCount:%i\n", bmih.biBitCount);
      printf("biCompression:%i\n", bmih.biCompression);
      printf("biSizeImage:%i\n", bmih.biSizeImage);
      printf("biXPelsPerMeter:%i\n", bmih.biXPelsPerMeter);
      printf("biYPelsPerMeter:%i\n", bmih.biYPelsPerMeter);
      printf("biClrUsed:%i\n", bmih.biClrUsed);
      printf("biClrImportant:%i\n", bmih.biClrImportant);
      printf("--------------------\n");
      
      // Reading the pixels of input image
      width  = bmih.biWidth; if (width%4 != 0) width += (4-width%4);
      height = bmih.biHeight;
      for (y=0; y<height; y++) 
        for (x=0; x<width; x++){
          image[x][y].rgbBlue = fgetc(fp);    
          image[x][y].rgbGreen = fgetc(fp);
          image[x][y].rgbRed = fgetc(fp);
      }
    
    
      fclose(fp);
    
    
     
     
      // Converting from RGB to Grayscale
      int gray_image[width][height];
      memset(gray_image, 0, width*height*sizeof(int));
      
      for (y=0; y<height; y++) 
        for (x=0; x<width; x++){
          gray_image[x][y] = 0.2989*image[x][y].rgbRed + 0.5870*image[x][y].rgbGreen + 0.1140*image[x][y].rgbBlue;
      }
     
    
    
    
    
      // mask for x direction
      double S1[3][3] = {{-1, 0, 1}, 
                         {-2, 0, 2}, 
                         {-1, 0, 1}}; 
      // mask for y direction
      double S2[3][3] = {{-1, -2, -1}, 
                         {0, 0, 0}, 
                         {1, 2, 1}};  
    
    
     
      // Scanning the image
      for (x=1; x<width-1; x++)
        for (y=1; y<height-1; y++){
    
    
          double Gx = S1[0][0]*gray_image[x-1][y-1] + S1[0][1]*gray_image[x-1][y] + S1[0][2]*gray_image[x-1][y+1] + 
                      S1[1][0]*gray_image[x][y-1]   + S1[1][1]*gray_image[x][y]   + S1[1][2]*gray_image[x][y+1]   +
                      S1[2][0]*gray_image[x+1][y-1] + S1[2][1]*gray_image[x+1][y] + S1[2][2]*gray_image[x+1][y+1];
    
    
          double Gy = S2[0][0]*gray_image[x-1][y-1] + S2[0][1]*gray_image[x-1][y] + S2[0][2]*gray_image[x-1][y+1] + 
                      S2[1][0]*gray_image[x][y-1]   + S2[1][1]*gray_image[x][y]   + S2[1][2]*gray_image[x][y+1]   + 
                      S2[2][0]*gray_image[x+1][y-1] + S2[2][1]*gray_image[x+1][y] + S2[2][2]*gray_image[x+1][y+1];
          
          double e = sqrt(Gx*Gx + Gy*Gy);
    
    
          // Thresholding
          if (e <= T) ee_image[x][y] = 0;
          if (e > T)  ee_image[x][y] = 255;
          
      } // End of image scanning 
     
    
    
    
    
      // Calculating the border pixels with replication
      for (y=1; y<height-1; y++){
        ee_image[0][y] = ee_image[1][y];
        ee_image[width-1][y] = ee_image[width-2][y];
      }
      for (x=0; x<width; x++){
        ee_image[x][0] = ee_image[x][1];
        ee_image[x][height-1] = ee_image[x][height-2];
      }
     
    
    
      printf("The edges of the image have been detected with Sobel and a Threshold: %d\n", T); 
       
      // Constructing output image name
      char dst_name[80];
      // Converting input threshold to string
      char str_T[3];
      sprintf(str_T, "%d", T);
    
    
      strcpy(dst_name, "Sobel_");
      strcat(dst_name, str_T);
      strcat(dst_name, ".bmp");
    
    
      // Writing new image
      wp = fopen(dst_name, "wb");
      fwrite(&bmfh, 1, sizeof(BitmapFileHeader), wp);
      fwrite(&bmih, 1, sizeof(BitmapInfoHeader), wp);
    
    
      for (y=0; y<height; y++) 
        for (x=0; x<width; x++){
          fputc(ee_image[x][y], wp);
          fputc(ee_image[x][y], wp);
          fputc(ee_image[x][y], wp);                
      }
    
    
      fclose(wp);
    
    
    }


    And my code...




    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <math.h>
    #include <string.h>
    
    
    #include "Image.h"
    image[2048*2048];         // Image as input
    
    
    int main(int  argc, char *argv[])
    {
      char *filename = 0;
      FILE *fp;
      FILE *wp;
      int width, height;
      int i, j, x, y, T;
      BitmapFileHeader bmfh;
      BitmapInfoHeader bmih;
      unsigned char ee_image[2048*2048];
    
    
      // Reading inputs: bayer image and threshold
      if (argc == 3){
        filename = argv[1];
        T = atoi(argv[2]);
      } else{
        printf("Give a bmp image and a threshold as input\n");
        exit(0);
      }
    
    
      // Opening the file: using "rb" mode to read this *binary* file
      printf("Opening filename: %s\n", filename);
      fp = fopen(filename, "rb");
    
    
      // Reading the file header and any following bitmap information...
      fread(&bmfh, sizeof(BitmapFileHeader), 1, fp);
      fread(&bmih, sizeof(BitmapInfoHeader), 1, fp);
    
    
      printf("Header Info\n");
      printf("--------------------\n");
      printf("Size:%i\n", bmfh.bfSize);
      printf("Offset:%i\n", bmfh.bfOffBits);
      printf("--------------------\n");
      printf("Size:%i\n", bmih.biSize);
      printf("biWidth:%i\n", bmih.biWidth);
      printf("biHeight:%i\n", bmih.biHeight);
      printf("biPlanes:%i\n", bmih.biPlanes);
      printf("biBitCount:%i\n", bmih.biBitCount);
      printf("biCompression:%i\n", bmih.biCompression);
      printf("biSizeImage:%i\n", bmih.biSizeImage);
      printf("biXPelsPerMeter:%i\n", bmih.biXPelsPerMeter);
      printf("biYPelsPerMeter:%i\n", bmih.biYPelsPerMeter);
      printf("biClrUsed:%i\n", bmih.biClrUsed);
      printf("biClrImportant:%i\n", bmih.biClrImportant);
      printf("--------------------\n");
    
    
      // Reading the pixels of input image
      width  = bmih.biWidth; if (width%4 != 0) width += (4-width%4);            //Logika edw den diabazei swsta....
      height = bmih.biHeight;
      for (y=0; y<height; y++)
        for (x=0; x<width; x++){
          image[x*y]= fgetc(fp);
          image[x*y]= fgetc(fp);
          image[x*y] = fgetc(fp);
      }
    
    
      fclose(fp);
    
    
      // Converting from RGB to Grayscale
      int gray_image[width*height];
      memset(gray_image, 0, width*height*sizeof(int));
    
    
      for (y=0; y<height; y++)
        for (x=0; x<width; x++){
          gray_image[x*width+y] = 0.2989*image[x*width+y] + 0.5870*image[x*width+y] + 0.1140*image[x*width+y];
      }
    
    
      //-------------------------------------------------------------
      // Edge Detection with Sobel
      //-------------------------------------------------------------
    
    
      // Sobel kernels
      // mask for x direction
      double S1[3][3] = {{-1, 0, 1},
                         {-2, 0, 2},
                         {-1, 0, 1}};
      // mask for y direction
      double S2[3][3] = {{-1, -2, -1},
                         {0, 0, 0},
                         {1, 2, 1}};
    
    
      // Scanning the image
      for (x=1; x<width-1; x++)
        for (y=1; y<height-1; y++){
    
    
          double Gx = S1[0][0]*gray_image[(x-1)*(y-1)] + S1[0][1]*gray_image[(x-1)*(y)] + S1[0][2]*gray_image[(x-1)*(y+1)] +
                      S1[1][0]*gray_image[x*(y-1)]   + S1[1][1]*gray_image[x*width+y]   + S1[1][2]*gray_image[x*(y+1)]   +
                      S1[2][0]*gray_image[(x+1)*(y-1)] + S1[2][1]*gray_image[(x+1)*y] + S1[2][2]*gray_image[(x+1)*(y+1)];
    
    
          double Gy = S2[0][0]*gray_image[(x-1)*(y-1)] + S1[0][1]*gray_image[(x-1)*(y)] + S1[0][2]*gray_image[(x-1)*(y+1)] +
                      S2[1][0]*gray_image[x*(y-1)]   + S1[1][1]*gray_image[x*width+y]   + S1[1][2]*gray_image[x*(y+1)]   +
                      S2[2][0]*gray_image[(x+1)*(y-1)] + S1[2][1]*gray_image[(x+1)*y] + S1[2][2]*gray_image[(x+1)*(y+1)];
    
    
          double e = sqrt(Gx*Gx + Gy*Gy);
    
    
          // Thresholding
          if (e <= T) ee_image[x*width+y] = 0;
          if (e > T)  ee_image[x*width+y] = 255;
    
    
      } // End of image scanning
    
    
      // Calculating the border pixels with replication
      for (y=1; y<height-1; y++){
        ee_image[0*y] = ee_image[1*y];
        ee_image[(width-1)*y] = ee_image[(width-2)*y];
      }
      for (x=0; x<width; x++){
        ee_image[x*0] = ee_image[x*1];
        ee_image[x*(height-1)] = ee_image[x*(height-2)];
      }
    
    
      printf("The edges of the image have been detected with Sobel and a Threshold: %d\n", T);
    
    
      // Constructing output image name
      char dst_name[80];
      // Converting input threshold to string
      char str_T[3];
      sprintf(str_T, "%d", T);
    
    
      strcpy(dst_name, "Sobel_");
      strcat(dst_name, str_T);
      strcat(dst_name, ".bmp");
    
    
      // Writing new image
      wp = fopen(dst_name, "wb");
      fwrite(&bmfh, 1, sizeof(BitmapFileHeader), wp);
      fwrite(&bmih, 1, sizeof(BitmapInfoHeader), wp);
    
    
      for (y=0; y<height; y++)                        // kai edw den vgazei swsta tin eikona
        for (x=0; x<width; x++){
          fputc(ee_image[x*y], wp);
          fputc(ee_image[x*y], wp);
          fputc(ee_image[x*y], wp);
      }
    
    
      fclose(wp);
    
    
    }

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    422
    C 2D arays don't work very well when you don't know the dimensions at compile time.

    So what you normally do is this.
    a) get width and height at runtime, eg from an image file.
    b) call pixel *image = malloc(width * height * sizeof(pixel)) to allocate memory for the image.
    c) access via image[y*width+x] to read or write to a pixel.

    If you go to my website you will find many image loading and saving routines in the Baby X Resource compiler project, which might be helpful.
    I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
    Visit my website for lots of associated C programming resources.
    https://github.com/MalcolmMcLean


  3. #3
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,784
    At a glance, you're not calculating the offsets into your array correctly... [x*y] isn't correct... it would normally be something like [x + y * width]

    Check lines 68-70 and 164-166. Also check lines 84, 109-117, and 123-124 as well (x * width + y seems sideways and should, more rationally, be x + y * width)

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,163
    > unsigned char ee_image[2048][2048];
    Another thing to watch out for is your stack usage.

    Your familiar OS usually restricts stack usage to between 1MB and 8MB.
    You just burned 4MB in a single line of code.

    At some point, you would want to move away from fixed sized arrays, and instead malloc the memory you need based on analysing the image header of the input file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jul 2020
    Posts
    9
    Quote Originally Posted by Hodor View Post
    At a glance, you're not calculating the offsets into your array correctly... [x*y] isn't correct... it would normally be something like [x + y * width]

    Check lines 68-70 and 164-166. Also check lines 84, 109-117, and 123-124 as well (x * width + y seems sideways and should, more rationally, be x + y * width)
    Hi and thanks all of you for your replies.
    I made the changes you mentioned but still the output inmage is only gray without edge detection of the original.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,912
    What is your current code?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    Jul 2020
    Posts
    9
    After reccomendation the code is...
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <math.h>
    #include <string.h>
    
    #include "Image.h"
    
    image[2048*2048];           // Image as input
    
    int main(int  argc, char *argv[])
    {
      char *filename = 0;
      FILE *fp;
      FILE *wp;
      int width, height;
      int i, j, x, y, T;
      BitmapFileHeader bmfh;
      BitmapInfoHeader bmih;
      unsigned char ee_image[2048*2048];
    
      // Reading inputs: bayer image and threshold
      if (argc == 3){
        filename = argv[1];
        T = atoi(argv[2]);
      } else{
        printf("Give a bmp image and a threshold as input\n");
        exit(0);
      }
    
      // Opening the file: using "rb" mode to read this *binary* file
      printf("Opening filename: %s\n", filename);
      fp = fopen(filename, "rb");
    
      // Reading the file header and any following bitmap information...
      fread(&bmfh, sizeof(BitmapFileHeader), 1, fp);
      fread(&bmih, sizeof(BitmapInfoHeader), 1, fp);
    
      printf("Header Info\n");
      printf("--------------------\n");
      printf("Size:%i\n", bmfh.bfSize);
      printf("Offset:%i\n", bmfh.bfOffBits);
      printf("--------------------\n");
      printf("Size:%i\n", bmih.biSize);
      printf("biWidth:%i\n", bmih.biWidth);
      printf("biHeight:%i\n", bmih.biHeight);
      printf("biPlanes:%i\n", bmih.biPlanes);
      printf("biBitCount:%i\n", bmih.biBitCount);
      printf("biCompression:%i\n", bmih.biCompression);
      printf("biSizeImage:%i\n", bmih.biSizeImage);
      printf("biXPelsPerMeter:%i\n", bmih.biXPelsPerMeter);
      printf("biYPelsPerMeter:%i\n", bmih.biYPelsPerMeter);
      printf("biClrUsed:%i\n", bmih.biClrUsed);
      printf("biClrImportant:%i\n", bmih.biClrImportant);
      printf("--------------------\n");
    
      // Reading the pixels of input image
    width  = bmih.biWidth; if (width%4 != 0) width += (4-width%4);
    height = bmih.biHeight;
     
     for (y=0; y<height; y++)
        for (x=0; x<width; x++){
          image[x + y * width] = fgetc(fp);
          image[x + y * width] = fgetc(fp);
          image[x + y * width] = fgetc(fp);
    
    
    
      }
    
      fclose(fp);
    
      // Converting from RGB to Grayscale
      int gray_image[width*height];
      memset(gray_image, 0, width*height*sizeof(int));
    
      for (y=0; y<height; y++)
        for (x=0; x<width; x++){
          gray_image[x + y * width] = 0.2989*image[x + y * width] + 0.5870*image[x + y * width] + 0.1140*image[x + y * width];
      }
    
      // Sobel kernels
      // mask for x direction
      double S1[3][3] = {{-1, 0, 1},
                         {-2, 0, 2},
                         {-1, 0, 1}};
      // mask for y direction
      double S2[3][3] = {{-1, -2, -1},
                         {0, 0, 0},
                         {1, 2, 1}};
    
      // Scanning the image
      for (x=1; x<width-1; x++)
        for (y=1; y<height-1; y++){
    
          double Gx = S1[0][0]*gray_image[(x-1)*(y-1)] + S1[0][1]*gray_image[(x-1)*(y)] + S1[0][2]*gray_image[(x-1)*(y+1)] +
                      S1[1][0]*gray_image[x*(y-1)]   + S1[1][1]*gray_image[x + y * width]   + S1[1][2]*gray_image[x*(y+1)]   +
                      S1[2][0]*gray_image[(x+1)*(y-1)] + S1[2][1]*gray_image[(x+1)*y] + S1[2][2]*gray_image[(x+1)*(y+1)];
    
          double Gy = S2[0][0]*gray_image[(x-1)*(y-1)] + S1[0][1]*gray_image[(x-1)*(y)] + S1[0][2]*gray_image[(x-1)*(y+1)] +
                      S2[1][0]*gray_image[x*(y-1)]   + S1[1][1]*gray_image[x + y * width]   + S1[1][2]*gray_image[x*(y+1)]   +
                      S2[2][0]*gray_image[(x+1)*(y-1)] + S1[2][1]*gray_image[(x+1)*y] + S1[2][2]*gray_image[(x+1)*(y+1)];
    
          double e = sqrt(Gx*Gx + Gy*Gy);
    
          // Thresholding
          if (e <= T) ee_image[x + y * width] = 0;
          if (e > T)  ee_image[x + y * width] = 255;
    
      } // End of image scanning
    
      // Calculating the border pixels with replication
      for (y=1; y<height-1; y++){
        ee_image[0*y] = ee_image[1*y];
        ee_image[(width-1)*y] = ee_image[(width-2)*y];
      }
      for (x=0; x<width; x++){
        ee_image[x*0] = ee_image[x*1];
        ee_image[x*(height-1)] = ee_image[x*(height-2)];
      }
    
      printf("The edges of the image have been detected with Sobel and a Threshold: %d\n", T);
    
      // Constructing output image name
      char dst_name[80];
      // Converting input threshold to string
      char str_T[3];
      sprintf(str_T, "%d", T);
    
      strcpy(dst_name, "Sobel_");
      strcat(dst_name, str_T);
      strcat(dst_name, ".bmp");
    
      // Writing new image
      wp = fopen(dst_name, "wb");
      fwrite(&bmfh, 1, sizeof(BitmapFileHeader), wp);
      fwrite(&bmih, 1, sizeof(BitmapInfoHeader), wp);
      for (y=0; y<height; y++)
        for (x=0; x<width; x++){
          fputc(ee_image[x + y * width], wp);
          fputc(ee_image[x + y * width], wp);
          fputc(ee_image[x + y * width], wp);}
    
      fclose(wp);
    
    }

    The initial code is at first post.

  8. #8
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,784
    The first thing I'd do is try and narrow down where the bug(s) might be. For example, leave out the edge detection and see if the grey image is written properly. To do this, make line 81 (currently blank) #ifdef 0 and line 123 #endif (i.e. "comment out" the entire edge detection part) and see what the output looks like.

  9. #9
    Registered User
    Join Date
    May 2012
    Posts
    422
    GY should be calculated using S2, not a mixture of S2 and S1.

    To debug this, comment out your edge detection code, then make the output totally black, then totally white.
    That rules out a bug in the conversion code.
    Then write the input greyscale directly to the output. That rules out abug in your input.

    Then put a diagnostic printf() in the edge detection code. What are the values, and why are they always below threshold?
    I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
    Visit my website for lots of associated C programming resources.
    https://github.com/MalcolmMcLean


  10. #10
    Registered User
    Join Date
    Jul 2020
    Posts
    9
    My problem is how i can transform the code...
    Code:
    / Reading the pixels of input image
      width  = bmih.biWidth; if (width%4 != 0) width += (4-width%4);
      height = bmih.biHeight;
      for (y=0; y<height; y++) 
        for (x=0; x<width; x++){
          image[x][y].rgbBlue = fgetc(fp);    
          image[x][y].rgbGreen = fgetc(fp);
          image[x][y].rgbRed = fgetc(fp);
      }
      // Converting from RGB to Grayscale
      int gray_image[width][height];
      memset(gray_image, 0, width*height*sizeof(int));
    
    
      for (y=0; y<height; y++)
        for (x=0; x<width; x++){
          gray_image[x][y] = 0.2989*image[x][y].rgbRed + 0.5870*image[x][y].rgbGreen + 0.1140*image[x][y].rgbBlue;
      }


    to code with 1D array and without rgbBlue etc...
    Last edited by stzog; 07-30-2020 at 12:00 PM.

  11. #11
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,163
    > width = bmih.biWidth; if (width%4 != 0) width += (4-width%4);
    This is wrong.

    If you have a width of 9 pixels, and 3 bytes per pixel, you have 27 bytes of pixel data per row.

    It is the number of bytes per row which is rounded up to a multiple of 4, not the number of pixels.

    So after reading 9 pixels (for a row), you need to throw away exactly 1 byte (27 + 1 = 28, which is a multiple of 4).

    You don't round your width of 9 up to 12 and proceed to read a further three pixels worth of data.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  12. #12
    Registered User
    Join Date
    Jul 2020
    Posts
    9
    Hi guys!I have the following code
    Code:
    include <stdio.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <math.h>
    #include <string.h>
    #define SIZE 2048*2048
    
    
    #define SIZE 2048*2048*4
    unsigned char image[2048*2048*4];           // Image as input
    
    
    int main(int argc, char *argv[])
    {
        unsigned char *gray_image[2048*2048];
    unsigned char *ee_image[2048*2048];
    
    
    	char *filename = 0;
    
    
      FILE *fp;
    
    
      FILE *wp;
    
    
     int width=2048;
     int height=2048;
     int j, x, y, T;
    
    
     // Reading inputs: bayer image and threshold
      if (argc == 3){
        filename = argv[1];
        T = atoi(argv[2]);
      } else{
        printf("Give a bmp image and a threshold as input\n");
        exit(0);
      }
    
    
     // Opening the file: using "rb" mode to read this *binary* file
      printf("Opening filename: %s\n", filename);
      fp = fopen(filename, "rb");
    
    
      // initializationn part: read the input rgba file
    How do i read and get the values of RGB for the first pixel of image?

  13. #13
    Registered User
    Join Date
    Feb 2019
    Posts
    717

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 03-17-2017, 12:49 PM
  2. how use ISTream with image correctly?
    By joaquim in forum C++ Programming
    Replies: 0
    Last Post: 07-20-2016, 12:06 PM
  3. GDI++ - Image: how get the frame time delay correctly?
    By joaquim in forum Game Programming
    Replies: 0
    Last Post: 03-24-2016, 12:17 PM
  4. Not reading a file correctly?
    By tmac619619 in forum C Programming
    Replies: 1
    Last Post: 11-13-2012, 02:10 AM
  5. Am I reading User input into Arrays correctly?
    By threwup in forum C Programming
    Replies: 9
    Last Post: 02-10-2011, 07:49 PM

Tags for this Thread