Alien-FreeImage

 view release on metacpan or  search on metacpan

src/Source/LibRawLite/internal/dcb_demosaicing.c  view on Meta::CPAN

	min = MIN(image[indx+1+u][1], MIN(image[indx+1-u][1], MIN(image[indx-1+u][1], MIN(image[indx-1-u][1], MIN(image[indx-1][1], MIN(image[indx+1][1], MIN(image[indx-u][1], image[indx+u][1])))))));

	max = MAX(image[indx+1+u][1], MAX(image[indx+1-u][1], MAX(image[indx-1+u][1], MAX(image[indx-1-u][1], MAX(image[indx-1][1], MAX(image[indx+1][1], MAX(image[indx-u][1], image[indx+u][1])))))));

	image[indx][1] = ULIM(image[indx][1], max, min);				
		}
}




// FBDD (Fake Before Demosaicing Denoising)
void CLASS fbdd(int noiserd)
{ 
	double (*image2)[3];
        // safety net: disable for 4-color bayer or full-color images
        if(colors!=3 || !filters)
            return;
	image2 = (double (*)[3]) calloc(width*height, sizeof *image2);

	border_interpolate(4);

if (noiserd>1)
{
#ifdef DCRAW_VERBOSE
	if (verbose) fprintf (stderr,_("FBDD full noise reduction...\n"));
#endif
	fbdd_green();
	//dcb_color_full(image2);
	dcb_color_full();
	fbdd_correction();	
	

	dcb_color();
	rgb_to_lch(image2);
	fbdd_correction2(image2);
	fbdd_correction2(image2);
	lch_to_rgb(image2); 

}
else
{
#ifdef DCRAW_VERBOSE
	if (verbose) fprintf (stderr,_("FBDD noise reduction...\n"));
#endif

	fbdd_green();
	//dcb_color_full(image2);
	dcb_color_full();
	fbdd_correction();	
}

free(image2);

}




// DCB demosaicing main routine
void CLASS dcb(int iterations, int dcb_enhance)
{


	int i=1;
	
	float (*image2)[3];
	image2 = (float (*)[3]) calloc(width*height, sizeof *image2);

	float (*image3)[3];
	image3 = (float (*)[3]) calloc(width*height, sizeof *image3);
	
#ifdef DCRAW_VERBOSE
	if (verbose) fprintf (stderr,_("DCB demosaicing...\n"));
#endif

 		border_interpolate(6);

		dcb_hor(image2);
 		dcb_color2(image2);
  		
 		dcb_ver(image3);
 		dcb_color3(image3);
  		
 		dcb_decide(image2, image3);

		free(image3);

		dcb_copy_to_buffer(image2);

		while (i<=iterations)
		{
#ifdef DCRAW_VERBOSE
			if (verbose) fprintf (stderr,_("DCB correction pass %d...\n"), i);
#endif                        
			dcb_nyquist();
			dcb_nyquist();
			dcb_nyquist();
			dcb_map();
			dcb_correction();	
			i++;
		}
		
		dcb_color();
		dcb_pp();	
		
#ifdef DCRAW_VERBOSE
	if (verbose) fprintf (stderr,_("finishing DCB...\n"));
#endif		
		dcb_map();
		dcb_correction2();

		dcb_map();
		dcb_correction();

		dcb_map();
		dcb_correction();

		dcb_map();
		dcb_correction();	

		dcb_map();
		dcb_restore_from_buffer(image2);
		dcb_color();

	if (dcb_enhance)
	{	
#ifdef DCRAW_VERBOSE
		if (verbose) fprintf (stderr,_("optional DCB refinement...\n"));
#endif
		dcb_refinement();
 		//dcb_color_full(image2);		
 		dcb_color_full();		
	}


		free(image2);

}



( run in 1.186 second using v1.01-cache-2.11-cpan-71847e10f99 )