Still can't print a Histogram from fail input
Althogh I have spend the whole day to my homework . I still can't made it . I need to print out a histogram from a image(subset1.img),there are array 512X512 or 262144 pixel value in the image . However , the array saiz is too large . How can I solve it . Besides , I really don't understand the command to print a histogram , it's quite complicated to me . I would like to print a histogram with bin range of 20 ( 0-20 , 21-40,41-60 and so on ) and each star '*' represent 25 frequency . I already try my best . I hope seniors can help me to produce the histogram . Below is my program code .
**************************************************
#include <stdio.h> include <conio.h> include <math.h>
FILE *input;
void total (void),average ( void ), range ( void ) ,histogram ( void ) ;
float aveg;
int dn,sum,min,maks,choose=10;
main()
{
min=1000;maks=0;
input = fopen ("subset1.img","a+");
printf("\n The Pixel Value Distribution Are As Below \n");
total();range() ;average();histogram () ;
printf(" \n\n\n End ! \n");
getch ();
fclose(input);
return (0);
}
void total()
{
int i, j, sum = 0, subset1[512][512];/*there are 262144 pixel value to analysis*/
input = fopen ("subset1.img","a+"); /*in array 512 X 512 , but there is a error*/
for (i=0; i<512; i++) /*where the array saize is too large */
for (j=0; j<512; j++)
fscanf(input, "%d", &subset1[i][j]);
for (i=0; i<512; i++)
for (j=0; j<512; j++)
{sum +=subset1[i][j];}
fclose(input);
}
void range()
{
int i, j, subset1[512][512];
sum=0;
input = fopen ("subset1.img","a+");
for (i=0; i<512; i++)
for (j=0; j<512; j++)
{
fscanf(input, "%d", &subset1[i][j]);
if(subset1[i][j]>maks)
maks=subset1[i][j];
if(subset1[i][j]<min)
min=subset1[i][j];
}
for (i=0; i<512; i++)
for (j=0; j<512; j++)
{sum +=subset1[i][j];}
fclose(input);
}
void average()
{
input = fopen ("subset1.img","a+");
aveg=sum/262144;
fclose(input);
}
void histogram ()
{
input = fopen ("subset1.img","a+"); /*I really don't know how to printf the */
for (i=0; i<512; i++) /*histogram which the bin range of 20*/
for (j=0; j<512; j++) /*from the range 0-255pixel value */
} /*and each star '*' represent 25 frequency*/
Still looking for solution !
What the format of input fail I need to use ?
Still can get the point to print a histogram , did I need to use array to do that or use if......else command ?
What parameter I should define ?
A beginner must have lots of problems loh . :p