/*
 * lineacc.h  
 *    -- Accumulator holding data for one horizontal line in the image.
 */


#ifndef _LINEACC_H_
#define _LINEACC_H_


/* lineAcc --
 *
 * Accumulator holding data for one horizontal line in the image.
 * Used for holding temporary data, internally in the function 
 * 'processImage()'.
 *
 * 'lineAcc' is used in the function 'processImage()', to process the
 * input image line by line.
 *
 * 'lineAcc' has (must be allocated to have) as many elements as there 
 * are pixels in the width of the input image, and one lineAcc element 
 * corresponds with one image in a line of the image.
 *
 * Each cell in lineAcc stores the LABEL (= ID number) of the 
 * four-connected component that the image pixel is part of.
 *
 */




#include "label.h"   /* label_h, LABEL_EMPTY  */


/* Implementation:
 * LineAcc is implemented simply as an array of label_t, of a size
 * equal to the width of the image being processed.
 */

typedef struct lineAcc_
	{
	int       N;  /*Nr of elements in pArr[]. */
	label_t * pArr;
	}
lineAcc_t;


/*************************************************************************
 * Function prototypes
 *************************************************************************/


/* lineAcc_alloc() --
 * 
 * User instantiates a lineAcc_t instance, then calls lineAcc_alloc() to
 * allocate the internal members of that lineAcc_t instance.
 *
 * Parameter: 
 *   in_size = the number of different labels that the map must store.
 *
 * Returns 0 on failure, 1 on success.
 */
int lineAcc_alloc( 
	lineAcc_t * pLA,
	int         in_size );


/* lineAcc_free() --
 * Deallocate the internal members of the lineAcc_t structure.
 */
void lineAcc_free( lineAcc_t * pLA );


/* lineAcc_init() --
 * Initialize lineAcc_t instance for beginning with a new image:
 * all elements set to LABEL_EMPTY.
 */
void lineAcc_init( lineAcc_t * pLA );




/* lineAcc_get() --
 * Return the label stored in element in_iX.
 */
label_t lineAcc_get( 
	lineAcc_t * pLA,
	int         in_iX );


/* lineAcc_put() --
 * Set element in_iX to the value in_lbl.
 */
void lineAcc_put( 
	lineAcc_t * pLA,
	int         in_iX,
	label_t     in_lbl );




#endif /*_LINEACC_H_ */