By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,617 Members | 1,591 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,617 IT Pros & Developers. It's quick & easy.

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

P: 13
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
Nov 22 '06 #1
Share this Question
Share on Google+
12 Replies


sivadhas2006
100+
P: 142
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.
Nov 22 '06 #2

P: 13
hi...

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


Thanks
Ranjit
Nov 22 '06 #3

sivadhas2006
100+
P: 142
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.
Nov 22 '06 #4

P: 13
hi...

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

Thanks
Ranjit
Nov 22 '06 #5

sivadhas2006
100+
P: 142
hi...

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

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.
Nov 22 '06 #6

P: 13
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.com/WIZ541902715

Thanks
Ranjit
Nov 22 '06 #7

sivadhas2006
100+
P: 142
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.
Nov 22 '06 #8

P: 13
hi....

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


Thanks
Ranjit
Nov 22 '06 #9

sivadhas2006
100+
P: 142
hi....

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


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

Expand|Select|Wrap|Line Numbers
  1. nGrayScaleValue = R*0.3 + G*0.59+ B*0.11;
  2.  
Regards,
M.Sivadhas.
Nov 22 '06 #10

P: 13
hi...


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


thanks
Ranjit
Nov 22 '06 #11

sivadhas2006
100+
P: 142
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.
Nov 22 '06 #12

P: 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(struct ffblk));
done = findfirst("*.bin",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,"%ld,%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.....)...but i am not able to find the coordinates of where it is found....
Nov 22 '06 #13

Post your reply

Sign in to post your reply or Sign up for a free account.