Start New Discussion within our Software Development Community

Hello, Im programming an image reader and I need to print out a histogram that shows how many times a given pixel value is present in a image - actually it doesn't have to be the graph, just a table with two columns would be enough

i have written a class for the whole program but i have everything else working except the histogram, any suggestions would be appreciated

# include <iostream>						
# include <fstream>
# include <string>
# include <cmath>
# include <iomanip>
# include <ctime>

using namespace std;

class image									
    int height, width, depth;
    char header[100];
    char line[100];
    char comment;
    short **data;
    ifstream fin;
    ofstream fout;
    string filename;

    void reader();							
    void writer();
    void rotate_clock();
    void rotate_anti();
    void resize();
    void histogram();
    void delete_p();

and heres the function i have written

void image::histogram()
	int counter[256];

	for (int z=0; z<256; z++)

	for (int value=0; value<=depth; value++)

i have no idea how to get it to work

> char comment;
How big a comment?

> counter[264]=depth;
Do array bounds mean anything to you?

What is depth?

The basics for a histogram is
for all pixels

This question has already been answered. Start a new discussion instead.