Code:
#include <stdio.h>
/* This takes in as input, an image file
and gives as output the 2D array or
a matrix representation of the image
whose elements are the intensities of the pixel
*/
int main()
{
FILE *fp1, *fp2;
int i,j;
int str[50][50];
fp1 = fopen("pic.bmp", "r"); /* Input, the image file in the bin folder */
fp2 = fopen("pic.doc","w");
for(i=0;i<50;i++)
{
for(j=0;j<50;j++)
{
fscanf(fp1,"%d",str[i][j]);
}
}
for(i=0;i<50;i++)
{
for(j=0;j<50;j++)
{
fprintf(fp2,"%d",str[i][j]);/* the value read */
}
printf("\n");
}
printf("Hello, world\n");
return 0;
}
Greetings!
This is the program i have written. I guess this does read the picture, takes in the values of the pixels. And i have printed the ouput matrix to a word doc. And lo! i get the following output. I now wanna know if this is the real procedure.
If there are any built-in C functions that calculate the pixel intensities, do tell me...
The output of the above program is attached...thanks in advance....