Exemple #1
0
FIBITMAP *DLL_CALLCONV
FIA_Binary3x3Closing (FIBITMAP * src)
{
	const double vals[9]={1,1,1,1,1,1,1,1,1};
	
	FilterKernel kernel = FIA_NewKernel(1, 1, vals, 9.0);			
	FIABITMAP *dst_FIA = FIA_SetBorder(src, 1, 1, BorderType_Constant, 0);
	FIBITMAP *dst = FIA_BinaryClosing(dst_FIA, kernel);
	FIA_Unload (dst_FIA);

	return dst;
}
static void
TestFIA_ClosingTest(CuTest* tc)
{
	const char *file = TEST_DATA_DIR "\\morpholology_test.bmp";

	FIBITMAP *dib1 = FIA_LoadFIBFromFile(file);
	
	CuAssertTrue(tc, dib1 != NULL);
	
	FIBITMAP *threshold_dib = FreeImage_Threshold(dib1, 20);

	CuAssertTrue(tc, threshold_dib != NULL);

	FIBITMAP *threshold_8bit_dib = FreeImage_ConvertTo8Bits(threshold_dib);

	CuAssertTrue(tc, threshold_8bit_dib != NULL);

	FIABITMAP *border_dib = FIA_SetBorder(threshold_8bit_dib, 2, 2
        , BorderType_Constant, 0.0);

	FilterKernel kernel = FIA_NewKernel(2, 2, kernel_values, 1.0);

	FIBITMAP* result_dib = FIA_BinaryClosing(border_dib, kernel);

	CuAssertTrue(tc, result_dib != NULL);

	FIA_SaveFIBToFile(result_dib, TEST_DATA_OUTPUT_DIR "\\closing_result.jpg", BIT24);

	// Test of convinience 3x3 function
	result_dib = FIA_Binary3x3Closing(threshold_8bit_dib);

	FIA_SimpleSaveFIBToFile(result_dib, TEST_DATA_OUTPUT_DIR "morphology/closing3x3_result.bmp");

	FreeImage_Unload(dib1);
	FreeImage_Unload(threshold_dib);
	FreeImage_Unload(threshold_8bit_dib);
	FIA_Unload(border_dib);
	FreeImage_Unload(result_dib);
}