i tried to produce a pixel histogram with dimension 256 * 256 (that shows the number of certain pixel in the histogram, see the attachment ) by writing a function, i tried to write the follwing code:
Code:
void histogram (){
int row, col, i, j, n, x, y, f;
unsigned char image_num[256];
unsigned char image_1[HEIGHT][WIDTH], image[HEIGHT][WIDTH];
unsigned char image_2[HEIGHT][WIDTH];
readImage("SweetieCoupleBack.bmp", image); <-- a function that can be used to read an image
for (i = 0; i < 256; i++)
image_num[i] = 0;
for (row = 0; row < HEIGHT; ++row){
for(col = 0; col < WIDTH; ++col) {
for (i = 0; image[row][col] = i; i++) {
image_num [i] ++;}
}}
for (i = 0; i < 256 ; i++){
for (x = 0; x < 256; x ++){
for (y = 0 ; y <= image_num[i] / 256 ; y++){
image_2[y][x] = 255;}
image_2[y][x] = 0;}}
writeImage("Histogram.bmp", image_2); <-- a function that can be used to write in a new image
}
however, the histogram cannot be produced, i want to ask why, and how to solve this problem, thx~~~