Histogram
Calculates the histogram for an image.

The first method calculates the statistics over a sub-area, while the second method calculates the statistics over the entire image.
Syntax
long* Histogram( pHistSize, pMem, lRow1, lRow2, lCol1, lCol2, lCols, bpp );
long* Histogram( pHistSize, pMem, lRows, lCols, bpp );
Parameters
long *pHistSize
Number of elements in returned array ( 2^16 or 2^32 ).
void* pMem
A void pointer to the image buffer.
long lRow1
The start row, in pixels, of the sub-image area to use in calculating the histogram.
long lRow2
The end row, in pixels, of the sub-image area to use in calculating the histogram.
long lCol1
The start column, in pixels, of the sub-image area to use in calculating the histogram.
long lCol2
The end column, in pixels, of the sub-image area to use in calculating the histogram.
long lRows
The row size of the full image ( in pixels ).
long lCols
The column size of the full image ( in pixels ).
int bpp
[optional] The bits-per-pixel used in the image. Default: CImage::BPP16
Returns
long * - Array of length 2^16 for 16-bit images or 2^32 for 32-bit images. This pointer should not be freed directly by the user application. User applications should call the FreeHistogram method or CImage class destructor to free the data.
Required Headers
CImage.h
Namespace
arc
Throws
std::runtime_error
Remarks
None
Example
        // This code demonstrates how to print out the
        // histogram for an image.

        #include <iostream>
        #include "CController.h"
        #include "CImage.h"

        using namespace std;
        using namespace arc;

        int main()
        {
           CController cController;
           CImage cImg;

           try {
                // ....
                //
                // Take an image, which will reside in the kernel
                // image buffer ( cController.mapFd )
                //
                // ....

                //
                // Assumes a 512x600 pixel image was taken and resides
                // in the kernel image buffer ( cController.mapFd )
                //
                long lHistSize = 0;

                long *pHist = cImg.Histogram( &lHistSize,
                                              cController.mapFd,
                                              512,
                                              600 );

                for ( long i=0; i<lHistSize; i++ )
                    cout << "hist[ " << i << " ]: " << pHist[ i ] << endl;

                cImg.FreeHistogram();
            }
            catch ( std::exception &e )
            {
                cImg.FreeHistogram();
                cerr << "Exception Occurred: " << e.what() << endl;
            }
        }

© Astronomical Research Cameras, Inc.