to find a red dot in bmp file.....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ranjitneo
    New Member
    • Nov 2006
    • 13

    to find a red dot in bmp file.....

    hi all....

    there is a bmp file which has a black background and has a red blot(dot) in the middle(i cant exactly say).....how can i find the coordinates of the red dot....
    any code ll be appreciated....

    Thanks
    Ranjit
  • sivadhas2006
    New Member
    • Nov 2006
    • 142

    #2
    Hi Ranjit,

    You have a bitmap right.
    Can I know the type of the bitmap?

    The following are the bitmap types.

    1. Monochrome.
    2. 16 Color.
    3. 256 Color and
    4. 24 bit.

    Note: For each type we want to fetch the pixel values differently.

    Regards,
    M.Sivadhas.

    Comment

    • ranjitneo
      New Member
      • Nov 2006
      • 13

      #3
      hi...

      the bitmap is of 24 bits......(640x 480-bmp)


      Thanks
      Ranjit

      Comment

      • sivadhas2006
        New Member
        • Nov 2006
        • 142

        #4
        Hi Ranjit,

        For 24 bit bitmap,
        The pixel value range is 0 to 16777216.

        Can you able to get the pixel values from the bitmap?

        If yes, give some sample pixel values you got.

        Regards,
        M.Sivadhas.

        Comment

        • ranjitneo
          New Member
          • Nov 2006
          • 13

          #5
          hi...

          file size=921654
          offset=54
          bmpheader size =40
          width=640
          height=480
          size of bmp data=921600
          pallette=116499 1813...

          Thanks
          Ranjit

          Comment

          • sivadhas2006
            New Member
            • Nov 2006
            • 142

            #6
            Originally posted by ranjitneo
            hi...

            file size=921654
            offset=54
            bmpheader size =40
            width=640
            height=480
            size of bmp data=921600
            pallette=116499 1813...

            Thanks
            Ranjit
            Hi Ranjit,

            Thanks for giving information.
            Whatever you are given is correct.
            I think we need to concentrate on the pallette information.
            Can you give some more samples about palette information?

            Note : We need the palette information in the RGB format.

            Regards,
            M.Sivadhas.

            Comment

            • ranjitneo
              New Member
              • Nov 2006
              • 13

              #7
              hello....

              i have uploaded the photo in this link sir.....i am not able to make out what u are asking....plz tell me if u happen to find out....plz tell me how to find what u are asking....sorry for my ignorance....

              Your Download-Link: http://www.uploadwiz.c om/WIZ541902715

              Thanks
              Ranjit

              Comment

              • sivadhas2006
                New Member
                • Nov 2006
                • 142

                #8
                Hi Ranjit,

                Let as assume a matrix of size 640x480.

                So you must have 307200 pixel values.
                I just need the pixel values to find the red dot in the black background.

                Note :The URL you have posted is not working.

                Regards,
                M.Sivadhas.

                Comment

                • ranjitneo
                  New Member
                  • Nov 2006
                  • 13

                  #9
                  hi....

                  ok ok...i got it....it is 68154.....


                  Thanks
                  Ranjit

                  Comment

                  • sivadhas2006
                    New Member
                    • Nov 2006
                    • 142

                    #10
                    Originally posted by ranjitneo
                    hi....

                    ok ok...i got it....it is 68154.....


                    Thanks
                    Ranjit
                    Well.
                    First Convert the color pixel values to grayscale values.

                    Code:
                    nGrayScaleValue = R*0.3 + G*0.59+ B*0.11;
                    Regards,
                    M.Sivadhas.

                    Comment

                    • ranjitneo
                      New Member
                      • Nov 2006
                      • 13

                      #11
                      hi...


                      thanks a lot...can i know how u came up with that..???


                      thanks
                      Ranjit

                      Comment

                      • sivadhas2006
                        New Member
                        • Nov 2006
                        • 142

                        #12
                        Originally posted by ranjitneo
                        hi...


                        thanks a lot...can i know how u came up with that..???


                        thanks
                        Ranjit
                        Hi Ranjit,

                        Well,
                        Can you post your code, whatever you have finished upto now?

                        Regards,
                        M.Sivadhas.

                        Comment

                        • ranjitneo
                          New Member
                          • Nov 2006
                          • 13

                          #13
                          #include <stdio.h>
                          #include <dir.h>
                          #include <graphics.h>
                          #include <stdlib.h>
                          #include <conio.h>

                          #define NO_OF_PIXELS 24
                          main(int argc,char **argv)
                          {
                          struct ffblk *ffblk;
                          char ch;
                          FILE *fp,*fp1;
                          unsigned char color[3];
                          long int i = 0,j = 0;
                          int x =0,y =0;
                          int pixels,done;
                          long colorval= 0;
                          pixels = NO_OF_PIXELS;
                          if(argc > 1)
                          pixels = atoi(argv[1]);
                          ffblk = malloc(sizeof(s truct ffblk));
                          done = findfirst("*.bi n",ffblk,0);
                          fp = fopen (ffblk->ff_name,"rb" );
                          fp1 = fopen("a.csv"," w");
                          while(!feof(fp) && !kbhit())
                          {
                          fread(color,1,3 ,fp);
                          if(color[0] > 0xf9 && color[1] > 0x00 && color[2] > 0x00 && color[0] < 0xff && color[1]< 0x9f && color[2] < 0x9f){

                          fprintf(fp1,"%l d,%d,%d,%d,%d,% s\n",i%pixels,( int)(i/pixels ),color[0],color[1],color[2],ffblk->ff_name);
                          j++;


                          i++;
                          }
                          fclose(fp);



                          here i am checking for the condition if the red color can be spotted(i have converted the bmp file into its binary file.....)...bu t i am not able to find the coordinates of where it is found....

                          Comment

                          Working...