Beispiel #1
0
McoStatus ScanCal::_localcal(PWlinear **linear, MultiLcal *gcal, MultiLcal **lcal, long num, double *in, double *out)
{
	McoStatus status; 
	long i, m, j, local;
	double rgb[3], lch[3], caled[3];
	double white[3];
	
	white[0] = 96.42;
	white[1] = 100.0;
	white[2] = 82.49;
	
	m = 0;
	for (i=0; i<num; i++){
		rgb[0] = in[m];
		rgb[1] = in[m+1];
		rgb[2] = in[m+2];
		
		status = _linearstrech(3, linear, 1, rgb);
		if(status != MCO_SUCCESS)	return status;
		
		for(j = 0; j < 3; j++){
			if(rgb[j] < 0)	rgb[j] = 0;
			if(rgb[j] > 255)	rgb[j] = 255.0;
		}	
			
		status = gcal->apply(1, rgb, caled);
		if(status != MCO_SUCCESS)	return status;
		xyztonxyzinplace(caled, white, 1);
		nxyztoLabinplace(caled, 1);
		labtolch(caled, lch);
		
	
		if(lch[1] > GRAY_THRESHOLD){
			local = _select_local(lch);
			status = lcal[local]->apply(1, rgb, caled);
			if(status != MCO_SUCCESS)	return status;
			xyztonxyzinplace(caled, white, 1);
			nxyztoLabinplace(caled, 1);
		}

//fix cyan here, may introduce new bug
/*
		if(lch[1] > GRAY_THRESHOLD && lch[2] > 215 && lch[2] < 250){
			status = _cyan->apply(1, rgb, caled);
			if(status != MCO_SUCCESS)	return status;
			xyztonxyzinplace(caled, white, 1);
			nxyztoLabinplace(caled, 1);
		}
*/
		
		out[m] = caled[0];
		out[m+1] = caled[1];
		out[m+2] = caled[2];
		m += 3;
	}
			
	return MCO_SUCCESS;		
}
Beispiel #2
0
//apply the calibration here
McoStatus	ScanSimpleCal::compute(long num, double *in, double *out)
{
    McoStatus status;
    long i, m, j, local;
    double rgb[3], lch[3], caled[3];
    double white[3];

    white[0] = 96.42;
    white[1] = 100.0;
    white[2] = 82.49;

    m = 0;
    for (i=0; i<num; i++) {
        rgb[0] = in[m];
        rgb[1] = in[m+1];
        rgb[2] = in[m+2];

        status = _linearstrech(3, _linear, 1, rgb);
        if(status != MCO_SUCCESS)	return status;

        for(j = 0; j < 3; j++) {
            if(rgb[j] < 0)	rgb[j] = 0;
            if(rgb[j] > 255)	rgb[j] = 255.0;
        }

        status = _gcal->apply(1, rgb, caled);
        if(status != MCO_SUCCESS)	return status;
        xyztonxyzinplace(caled, white, 1);
        nxyztoLabinplace(caled, 1);

        out[m] = caled[0];
        out[m+1] = caled[1];
        out[m+2] = caled[2];
        m += 3;
    }

    return MCO_SUCCESS;
}