#include "coolscan.h"
#include <stdio.h>
#include <stdlib.h>

int fd;
struct hello {
	int how_often;
	int uv_sum;
	int v_sum;
	
};
void unvary_parameter(){
/*	register_color_balance_positive(1,25,25,25 ); */
set_film_type(MONO_POSITIVE);
	
} 
void vary_parameter(){
/*	register_color_balance_positive(1,25,100,25 ); */
set_film_type(MONO_NEGATIVE);
}
main(){
	unsigned char vbuf[10000];
	unsigned char uvbuf[10000];
	int i,j,k,time;
	struct hello data[256];	
	for(i=0;i<256;i++){
		data[i].v_sum=0;
		data[i].uv_sum=0;
		data[i].how_often = 0;
	}
	find_coolscan();
	specify_color_balance(1);
	set_film_type(MONO_NEGATIVE);
	stage_move_to(-1);
	agof();
	avon();
	linear_gamma();
	for(k=0;k<50;k++){
		unvary_parameter();
		read_line(1000+40*k,uvbuf);
		vary_parameter();
		read_line(1000+40*k,vbuf);
		for(i=500;i<2000;i++){
			j = uvbuf[i];
			data[j].v_sum += vbuf[i];
			data[j].how_often++;
		}
	} 
	for(i=0;i<256;i++){
		if(data[i].how_often > 1){
			printf("%d %d\n",i,data[i].v_sum /data[i].how_often);
		}
	}
	
}
