static void
TestFIA_ConvexHullTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "concave_shape.bmp";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);
    CuAssertTrue(tc, src != NULL);
    
    FIBITMAP *hull_dib = FIA_ConvexHull (src);

    CuAssertTrue(tc, hull_dib != NULL);

    FIA_SaveFIBToFile(hull_dib, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_ConvexHullTest.bmp", BIT8);

	FIA_InPlaceConvertToGreyscaleFloatType(&hull_dib, FIT_FLOAT); 
	FIA_InPlaceConvertToGreyscaleFloatType(&src, FIT_FLOAT); 

	FIA_SubtractGreyLevelImages(hull_dib, src);

	FIA_LinearScaleToStandardType(hull_dib, 0, 0, NULL, NULL); 

	// The following tests removing the single pixel artifacts from the convex hull routine
	// around the edge of the shape that should not be effected. (comment the linear scale above)
//	FIA_InPlaceConvertToStandardType(&hull_dib, 0);
//	hull_dib = FIA_Binary3x3Opening(hull_dib);

	FIA_SaveFIBToFile(hull_dib, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_ConvexHullDifference.bmp", BIT8);

    FreeImage_Unload(src);
    FreeImage_Unload(hull_dib);
}
static void
TestFIA_FloodFillTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "particle.bmp";

    FIBITMAP *dib1 = FIA_LoadFIBFromFile(file);

    CuAssertTrue(tc, dib1 != NULL);

    FIBITMAP *dib2 = FreeImage_ConvertTo8Bits(dib1);

    CuAssertTrue(tc, dib2 != NULL);

    FIBITMAP *dib3 = FIA_FloodFill(dib2, 20, 1, 255);

    FIA_SetGreyLevelPalette(dib3);
    
    CuAssertTrue(tc, dib3 != NULL);

    FIA_SaveFIBToFile(dib3, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_FloodFillTest.jpg", BIT24);

    FreeImage_Unload(dib1);
    FreeImage_Unload(dib2);
    FreeImage_Unload(dib3);
}
static void
TestFIA_AffineTransorm32bitScaleTest(CuTest* tc)
{
  const char *file = TEST_DATA_DIR "fly.bmp";

  FIBITMAP *dib1 = FIA_LoadFIBFromFile(file);

  CuAssertTrue(tc, dib1 != NULL);

  FIBITMAP *dib2 = FreeImage_ConvertTo32Bits(dib1);
  
  CuAssertTrue(tc, dib2 != NULL);
  
  FIA_Matrix *matrix = FIA_MatrixNew();

  FIA_MatrixScale(matrix, 2.0, 2.0, FIA_MatrixOrderPrepend);
  
  FIBITMAP *transformed_dib = FIA_AffineTransform(dib2, 1000, 1000,
                                matrix, FIA_RGBQUAD(255,0,255), 0);
  
  FIA_MatrixDestroy(matrix);
  
  CuAssertTrue(tc, transformed_dib != NULL);

  FIA_SetGreyLevelPalette(transformed_dib);

  FIA_SaveFIBToFile(transformed_dib, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_AffineTransorm32bitScaleTest.bmp", BIT24);

  FreeImage_Unload(dib1);
  FreeImage_Unload(dib2);
  FreeImage_Unload(transformed_dib);
}
static void
TestFIA_GreyscalePolygonTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "drone-bee-greyscale.jpg";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);
    CuAssertTrue(tc, src != NULL);
    
    FIAPOINT poly_array[4];

    poly_array[0].x = 10;
    poly_array[0].y = 10;
    poly_array[1].x = 30;
    poly_array[1].y = 200;
    poly_array[2].x = 100;
    poly_array[2].y = 80;
    poly_array[3].x = 60;
    poly_array[3].y = 10;  

    FIA_DrawSolidGreyscalePolygon (src, poly_array, 4, 255, 1);

    CuAssertTrue(tc, src != NULL);

    FIA_SaveFIBToFile(src, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_GreyscalePolygonTest.bmp", BIT24);

    FreeImage_Unload(src);
}
static void
TestFIA_ColourPolygonTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "fly.bmp";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);
    CuAssertTrue(tc, src != NULL);
    
    FIBITMAP *dst = FreeImage_ConvertTo24Bits(src);

    FIAPOINT poly_array[4];

    poly_array[0].x = 10;
    poly_array[0].y = 10;
    poly_array[1].x = 30;
    poly_array[1].y = 200;
    poly_array[2].x = 100;
    poly_array[2].y = 80;
    poly_array[3].x = 60;
    poly_array[3].y = 10;  

    FIA_DrawColourSolidPolygon (dst, poly_array, 4, FIA_RGBQUAD(0, 255, 0), 1);

    CuAssertTrue(tc, dst != NULL);

    FIA_SaveFIBToFile(dst, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_ColourPolygonTest.bmp", BIT24);

    FreeImage_Unload(src);
    FreeImage_Unload(dst);
}
static void
TestFIA_GreyscaleElipseTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "drone-bee-greyscale.jpg";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);
    CuAssertTrue(tc, src != NULL);

    FIARECT rect, rect2;
    rect.left = 50;
    rect.top = 100;
    rect.bottom = 200;
    rect.right = 200;

    rect2.left = 200;
    rect2.top = 100;
    rect2.bottom = 200;
    rect2.right = 300;

    FIA_DrawSolidGreyscaleEllipse (src, rect2, 200, 1);
    FIA_DrawGreyscaleEllipse (src, rect, 200, 0);
    FIA_DrawGreyscaleRect (src, rect, 200, 2);

    FIA_SaveFIBToFile(src, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_GreyscaleElipseTest.bmp", BIT8);

    FreeImage_Unload(src);
}
static void
TestFIA_DrawImageDstRectTest3(CuTest* tc)
{
  const char *file = TEST_DATA_DIR "fly.bmp";

  FIBITMAP *dib1 = FIA_LoadFIBFromFile(file);

  CuAssertTrue(tc, dib1 != NULL);

  FIBITMAP *dib2 = FreeImage_ConvertTo32Bits(dib1);
  
  CuAssertTrue(tc, dib2 != NULL);
  
  FIBITMAP *dst = FreeImage_Allocate(790,582, 32, 0, 0, 0);
   
  CuAssertTrue(tc, dst != NULL);
   
  FIA_Matrix *matrix = FIA_MatrixNew();

  FIA_MatrixScale(matrix, 2.0, 2.0, FIA_MatrixOrderPrepend);
  
   int err = FIA_DrawImageToDst(dst, dib2, matrix, 0,0,350/2,271/2, FIA_RGBQUAD(128,128,128), 1);

  CuAssertTrue(tc, err != FIA_ERROR);
  
  FIA_MatrixDestroy(matrix);
  
  CuAssertTrue(tc, dst != NULL);

  FIA_SaveFIBToFile(dst, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_DrawImageDstRectTest3.bmp", BIT24);

  FreeImage_Unload(dib1);
  FreeImage_Unload(dib2);
  FreeImage_Unload(dst);
}
static void
TestFIA_SolidGSRectTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "drone-bee-greyscale.jpg";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);

    CuAssertTrue(tc, src != NULL);

    FIBITMAP *gs_src = FreeImage_ConvertTo8Bits(src);

    CuAssertTrue(tc, gs_src != NULL);

    FIARECT rect;
    rect.left = 32;
    rect.top = 25;
    rect.bottom = 27;
    rect.right = 34;

    FIA_DrawSolidGreyscaleRect (gs_src, rect, 100);

    FIA_SaveFIBToFile(gs_src, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_SolidGSRectTest.jpg", BIT8);
  
    FreeImage_Unload(src);
    FreeImage_Unload(gs_src);
}
static void
TestFIA_AffineTransorm8bitTest(CuTest* tc)
{
  const char *file = TEST_DATA_DIR "fly.bmp";

  FIBITMAP *dib1 = FIA_LoadFIBFromFile(file);

  CuAssertTrue(tc, dib1 != NULL);

  FIA_Matrix *matrix = FIA_MatrixNew();

  FIA_MatrixRotate(matrix, -45.0, FIA_MatrixOrderAppend);

  FIA_MatrixTranslate(matrix, 40, 40, FIA_MatrixOrderAppend);
  
  FIA_MatrixScale(matrix, 1.2, 1.2, FIA_MatrixOrderPrepend);
  
  FIBITMAP *transformed_dib = FIA_AffineTransform(dib1, FreeImage_GetWidth(dib1), FreeImage_GetHeight(dib1),
                                  matrix, FIA_RGBQUAD(255,0,0), 0);
  
  FIA_MatrixDestroy(matrix);
  
  CuAssertTrue(tc, transformed_dib != NULL);

  FIA_SetGreyLevelPalette(transformed_dib);

  FIA_SaveFIBToFile(transformed_dib, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_AffineTransorm8bitTest.bmp", BIT8);

  FreeImage_Unload(dib1);
  FreeImage_Unload(transformed_dib);
}
コード例 #10
0
static void
TestFIA_ColourElipseTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "bumblebee.jpg";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);
    CuAssertTrue(tc, src != NULL);

    FIARECT rect, rect2, rect3;
    rect.left = 50;
    rect.top = 100;
    rect.bottom = 200;
    rect.right = 200;

    rect2.left = 200;
    rect2.top = 100;
    rect2.bottom = 200;
    rect2.right = 300;

	rect3.left = -50;
    rect3.top = -50;
    rect3.bottom = 50;
    rect3.right = 50;

    FIA_DrawColourSolidEllipse (src, rect, FIA_RGBQUAD(0, 255, 0), 1);
    FIA_DrawColourSolidEllipse (src, rect2, FIA_RGBQUAD(0, 0, 255), 0);
    FIA_DrawColourSolidEllipse (src, rect3, FIA_RGBQUAD(255, 0, 0), 0);
   
	FIA_DrawColourRect (src, rect3, FIA_RGBQUAD(255, 0, 0), 2);
   
    FIA_SaveFIBToFile(src, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_ColourElipseTest.bmp", BIT24);

    FreeImage_Unload(src);
}
コード例 #11
0
static void
TestFIA_IOLoadColourArrayData(CuTest* tc)
{
	FIBITMAP *dib1 = NULL, *dib2 = NULL;
	FREE_IMAGE_TYPE type;
	int bpp, err;
    
	const char *file = "C:\\cup.tif";
	dib1 = FIA_LoadFIBFromFile(file);

	CuAssertTrue(tc, dib1 != NULL);

	dib2 = FreeImage_AllocateT (FIT_BITMAP, FreeImage_GetWidth(dib1), FreeImage_GetHeight(dib1), 8, 0, 0, 0);

	PROFILE_START("CopyColourBytesToFIBitmap");

	for(int i=0; i < 1000; i++) {

		//FIA_CopyColourBytesToFIBitmap (dib2, FreeImage_GetBits(dib1), 0, 1, COLOUR_ORDER_RGB);
		FIA_CopyColourBytesTo8BitFIBitmap (dib2, FreeImage_GetBits(dib1), 24, FI_RGBA_RED, 0, 1);

	}

	PROFILE_STOP("CopyColourBytesToFIBitmap");

	FIA_SaveFIBToFile (dib2, TEST_DATA_OUTPUT_DIR "/IO/save-colour-test.bmp", BIT8);

	FreeImage_Unload(dib1);
	FreeImage_Unload(dib2);
}
コード例 #12
0
static void
TestFIA_Convert48BitsToStandardType(CuTest* tc)
{
	FIBITMAP *dib1 = NULL, *dib2 = NULL;
	FREE_IMAGE_TYPE type;
	int bpp, err;
    
    const char *file = TEST_DATA_DIR "IMG_3182.CR2";
	dib1 = FIA_LoadFIBFromFile(file);

	bpp = FreeImage_GetBPP(dib1);
	type = FreeImage_GetImageType(dib1);

	CuAssertTrue(tc, dib1 != NULL);
	
	dib2 = FIA_Convert48BitOr64BitRGBTo24BitColour(dib1);

	CuAssertTrue(tc, dib2 != NULL);
	
	bpp = FreeImage_GetBPP(dib2);
	type = FreeImage_GetImageType(dib2);

	err = FIA_SaveFIBToFile (dib2, TEST_DATA_OUTPUT_DIR "/IO/save-bmp-colour-test.bmp", BIT24);

	CuAssertTrue(tc, err == FIA_SUCCESS);

	FreeImage_Unload(dib1);
}
コード例 #13
0
static void
TestFIA_IO(CuTest* tc)
{
	FIBITMAP *dib1 = NULL, *dib2 = NULL;
	FREE_IMAGE_TYPE type;
	int bpp, err;
    
    const char *file = TEST_DATA_DIR "001.tif";
	dib1 = FIA_LoadFIBFromFile(file);

	CuAssertTrue(tc, dib1 != NULL);

	bpp = FreeImage_GetBPP(dib1);
	type = FreeImage_GetImageType(dib1);

	CuAssertTrue(tc, bpp == 24);
	CuAssertTrue(tc, type == FIT_BITMAP);
	
	err = FIA_SaveFIBToFile (dib1, TEST_DATA_OUTPUT_DIR "/IO/save-colour-test.bmp", BIT8);

	CuAssertTrue(tc, err == FIA_SUCCESS);

	dib2 = FIA_LoadFIBFromFile(TEST_DATA_OUTPUT_DIR "/IO/save-colour-test.bmp");

	err = FIA_BitwiseCompare(dib1, dib2);

	FreeImage_Unload(dib1);
	FreeImage_Unload(dib2);
}
コード例 #14
0
static void
TestFIA_IOSave8Bit(CuTest* tc, FREEIMAGE_ALGORITHMS_SAVE_BITDEPTH bit_depth, const char *extension)
{
	int err;
	char filepath[500];
	FIBITMAP *original_colour_dib = NULL, *greyscale_dib = NULL;

	const char *file = TEST_DATA_DIR "red-kneed-tarantula.jpg";
	original_colour_dib = FIA_LoadFIBFromFile(file);

	CuAssertTrue(tc, original_colour_dib != NULL);

	greyscale_dib = FreeImage_ConvertTo8Bits(original_colour_dib);

	CuAssertTrue(tc, greyscale_dib != NULL);

	if(bit_depth != BIT_NONE) {
		sprintf(filepath, TEST_DATA_OUTPUT_DIR "/IO/ForcedSave/8bitForcedTo%s.%s", bitdepths[bit_depth], extension);
		err = FIA_SaveFIBToFile (greyscale_dib, filepath, bit_depth);
	}
	else {
		sprintf(filepath, TEST_DATA_OUTPUT_DIR "/IO/SimpleSave/8bit.%s", extension);
		err = FIA_SimpleSaveFIBToFile (greyscale_dib, filepath);
	}

	CuAssertTrue(tc, err == FIA_SUCCESS);

	FreeImage_Unload(original_colour_dib);
	FreeImage_Unload(greyscale_dib);
}
コード例 #15
0
static void
TestFIA_DrawImageTest3(CuTest* tc)
{
  const char *file = TEST_DATA_DIR "fly.bmp";

  FIBITMAP *dib1 = FIA_LoadFIBFromFile(file);

  CuAssertTrue(tc, dib1 != NULL);

  FIBITMAP *dib2 = FreeImage_ConvertTo32Bits(dib1);
  
  CuAssertTrue(tc, dib2 != NULL);
  
  FIBITMAP *dst = FreeImage_Allocate(790,582, 32, 0, 0, 0);
   
  CuAssertTrue(tc, dst != NULL);
   
  int err = FIA_DrawImageFromSrcToDst(dst, dib2, NULL, 0,0,350,271, 350/2,271/2,350/2,271/2,
      FIA_RGBQUAD(255,0,255), 0);
  
  CuAssertTrue(tc, err != FIA_ERROR);
  
  CuAssertTrue(tc, dst != NULL);

  FIA_SaveFIBToFile(dst, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_DrawImageTest3.bmp", BIT24);

  FreeImage_Unload(dib1);
  FreeImage_Unload(dib2);
  FreeImage_Unload(dst);
}
コード例 #16
0
static void
TestFIA_Rect24bitTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "drone-bee.jpg";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);

    FIBITMAP *src24 = FreeImage_ConvertTo24Bits(src);

    CuAssertTrue(tc, src != NULL);

    FIARECT rect, rect2;
    rect.left = 165;
    rect.top = 118;
    rect.bottom = 156;
    rect.right = 200;
    
	rect2.left = -50;
    rect2.top = -50;
    rect2.bottom = 50;
    rect2.right = 50;

    FIA_DrawColourRect (src24, rect, FIA_RGBQUAD(255,0,0), 1);
	FIA_DrawColourRect (src24, rect2, FIA_RGBQUAD(255,255,0), 1);

    FIA_SaveFIBToFile(src24, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_Rect24bitTest.bmp", BIT24);

    FreeImage_Unload(src);
    FreeImage_Unload(src24);
}
コード例 #17
0
static void
TestFIA_ColourTextTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "fly.bmp";
	int bpp;

    FIBITMAP *src = FIA_LoadFIBFromFile(file);
    CuAssertTrue(tc, src != NULL);
    
    FIBITMAP *dst = FreeImage_ConvertTo24Bits(src);

    FIA_DrawHorizontalColourText (dst, 10, 10, FIA_AGG_FONT_VERDANA_12_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 0));
    FIA_DrawHorizontalColourText (dst, 10, 40, FIA_AGG_FONT_VERDANA_16, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 0, 255));
    FIA_DrawHorizontalColourText (dst, 10, 60, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 255));
	FIA_DrawHorizontalColourText (dst, 1000, 600, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 255));
	FIA_DrawHorizontalColourText (dst, -500, -600, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 255));
	FIA_DrawHorizontalColourText (dst, 0, 200, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 255));
	FIA_DrawHorizontalColourText (dst, 0, 300, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", FIA_RGBQUAD(0, 255, 255));

	bpp = FreeImage_GetBPP(dst);

    CuAssertTrue(tc, dst != NULL);

    FIA_SaveFIBToFile(dst, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_ColourTextTest.bmp", BIT24);

    FreeImage_Unload(src);
    FreeImage_Unload(dst);
}
コード例 #18
0
static void
TestFIA_Colour24bitLineTest(CuTest* tc)
{
        const char *file = TEST_DATA_DIR "bumblebee.jpg";

        FIBITMAP *src = FIA_LoadFIBFromFile(file);

        FIBITMAP *src24 = FreeImage_ConvertTo24Bits(src);

        CuAssertTrue(tc, src != NULL);

        FIAPOINT p1, p2, p3;

        p1.x = 10;
        p1.y = 10;
        p2.x = 200;
        p2.y = 300;

        FIA_DrawColourLine (src24, p1, p2, FIA_RGBQUAD(255, 0, 0), 5, 0);

        FIA_SaveFIBToFile(src24, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_Colour24BitLineTest.jpg", BIT24);

        FreeImage_Unload(src);
        FreeImage_Unload(src24);
}
static void
TestFIA_GradientBlendPasteTest6(CuTest* tc)
{
    FIBITMAP *background =  FIA_LoadFIBFromFile(TEST_DATA_DIR "histology_gradient_dest5.png");
    FIBITMAP *src =  FIA_LoadFIBFromFile(TEST_DATA_DIR "jigsaw.png");

    FIA_InPlaceConvertTo24Bit(&background);
    FIA_InPlaceConvertTo24Bit(&src);

    FIA_GradientBlendMosaicPaste (background, src, -300, 170);
    
    FIA_SaveFIBToFile(background, TEST_DATA_OUTPUT_DIR  "/GradientBlending/gradient_blended6.png", BIT24);

    FreeImage_Unload(background);
    FreeImage_Unload(src);
}
static void
TestFIA_GradientBlendPasteTest4(CuTest* tc)
{
    FIBITMAP *background =  FIA_LoadFIBFromFile(TEST_DATA_DIR "histology_gradient_dest.png");
    FIBITMAP *src =  FIA_LoadFIBFromFile(TEST_DATA_DIR "jigsaw-src.png");

    FIA_InPlaceConvertToGreyscaleFloatType(&background, FIT_FLOAT);
    FIA_InPlaceConvertToGreyscaleFloatType(&src, FIT_FLOAT);

    FIA_GradientBlendMosaicPaste (background, src, 780, 620);
    
    FIA_SaveFIBToFile(background, TEST_DATA_OUTPUT_DIR  "/GradientBlending/gradient_blended4.png", BIT24);

    FreeImage_Unload(background);
    FreeImage_Unload(src);
}
コード例 #21
0
static void
TestFIA_GreyscaleTextTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "fly.bmp";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);
    CuAssertTrue(tc, src != NULL);
    
    //FIA_DrawHorizontalGreyscaleText (src, 10, 10, "A quick brown fox jumps over the lazy dog 0123456789", 0);
    FIA_DrawHorizontalGreyscaleText (src, 10, 10, FIA_AGG_FONT_VERDANA_12_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", 0);
    FIA_DrawHorizontalGreyscaleText (src, 10, 40, FIA_AGG_FONT_VERDANA_16, "A quick brown fox jumps over the lazy dog 0123456789", 0);
    FIA_DrawHorizontalGreyscaleText (src, 10, 60, FIA_AGG_FONT_GSE_8x16_BOLD, "A quick brown fox jumps over the lazy dog 0123456789", 0);

    CuAssertTrue(tc, src != NULL);

    FIA_SaveFIBToFile(src, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_GreyscaleTextTest.bmp", BIT8);

    FreeImage_Unload(src);
}
コード例 #22
0
static void
TestFIA_ErosionTest(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);

	PROFILE_START("ErosionFilter");

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

	FIBITMAP* result_dib = FIA_BinaryErosion(border_dib, kernel);

	CuAssertTrue(tc, result_dib != NULL);

	PROFILE_STOP("ErosionFilter");

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

	result_dib = FIA_BinaryInnerBorder(threshold_8bit_dib);

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

	FreeImage_Unload(dib1);
	FreeImage_Unload(threshold_dib);
	FreeImage_Unload(threshold_8bit_dib);
	FIA_Unload(border_dib);
	FreeImage_Unload(result_dib);
}
コード例 #23
0
static void
TestFIA_GSLineTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "drone-bee-greyscale.jpg";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);
    CuAssertTrue(tc, src != NULL);

    FIAPOINT p1, p2;

    p1.x = 10;
    p1.y = 10;
        p2.x = p1.x;
        p2.y = 200;

        FIA_DrawGreyscaleLine (src, p1, p2, 150, 3, 0);
 
    FIA_SaveFIBToFile(src, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_GSLineTest.jpg", BIT8);

    FreeImage_Unload(src);
}
コード例 #24
0
static void
TestFIA_SolidRectTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "bumblebee.jpg";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);

    CuAssertTrue(tc, src != NULL);

    FIARECT rect;
    rect.left = 100;
    rect.top = 100;
    rect.bottom = 200;
    rect.right = 200;
    
    FIA_DrawColourSolidRect (src, rect, FIA_RGBQUAD(255,0,0));

    FIA_SaveFIBToFile(src, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_SolidRectTest.jpg", BIT24);

    FreeImage_Unload(src);
}
static void
TestFIA_GradientBlendPasteTest8(CuTest* tc)
{
    FIBITMAP *src1 =  FIA_LoadFIBFromFile(TEST_DATA_DIR "slide12bit1.png");
    FIBITMAP *src2 =  FIA_LoadFIBFromFile(TEST_DATA_DIR "slide12bit2.png");

	FREE_IMAGE_TYPE type = FreeImage_GetImageType(src1); 
	int bpp = FreeImage_GetBPP(src1);
	int width = FreeImage_GetWidth(src1);
	int height = FreeImage_GetHeight(src1); 

	FIBITMAP *background = FreeImage_AllocateT(type, width * 2, height, bpp, 0, 0, 0);

	FIA_PasteFromTopLeft(background, src1, 0, 0);
    FIA_GradientBlendMosaicPaste (background, src2, 922, 0);
    
    FIA_SaveFIBToFile(background, TEST_DATA_OUTPUT_DIR  "/GradientBlending/gradient_blended8.png", BIT16);

    FreeImage_Unload(background);
    FreeImage_Unload(src1);
	FreeImage_Unload(src2);
}
コード例 #26
0
static void
TestFreeImageIcs_MaxIntensityProjection(CuTest* tc)
{
	ICS *ics;
	Ics_Error err;
	FIBITMAP* fib;

	char *file = "C:\\Csarseven.ics";
  
	err = FreeImageIcs_IcsOpen (&ics, file, "r");

    CuAssertTrue(tc, err == IcsErr_Ok);
	
	fib = FreeImageIcs_MaximumIntensityProjection(ics, 2);

    CuAssertTrue(tc, fib != NULL);

	FIA_SaveFIBToFile (fib, "C:\\max_intensity_project.bmp", BIT8);

	FreeImage_Unload(fib);
	FreeImageIcs_IcsClose(ics);
}
コード例 #27
0
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);
}
コード例 #28
0
static void
TestFreeImageIcs_LoadTest(CuTest* tc)
{
	FIBITMAP *dib1, *dib2, *dib3;
	Ics_Error err;
	ICS *ics;

	char *file = "C:\\Documents and Settings\\Pierce\\Desktop\\xyt.ics";

	err = FreeImageIcs_IcsOpen(&ics, file, "r");

	if(err != IcsErr_Ok)
		return;

	dib1 = FreeImageIcs_LoadFIBFromIcsFile(ics);
	
	CuAssertTrue(tc, dib1 != NULL);

	FIA_SaveFIBToFile (dib1, "C:\\Documents and Settings\\Pierce\\Desktop\\here.bmp", BIT8);

	FreeImage_Unload(dib1);
	FreeImageIcs_IcsClose(ics);
}
コード例 #29
0
static void
TestFreeImageIcs_SumIntensityProjection(CuTest* tc)
{
	ICS *ics;
	Ics_Error err;
	FIBITMAP* fib;

	char *file = "C:\\Documents and Settings\\Pierce\\Desktop\\SarSeven_txy.ics";
  
	err = FreeImageIcs_IcsOpen (&ics, file, "r");

    CuAssertTrue(tc, err == IcsErr_Ok);
	
	fib = FreeImageIcs_SumIntensityProjection(ics, 2);

    CuAssertTrue(tc, fib != NULL);

	FIA_SaveFIBToFile (fib, "C:\\Documents and Settings\\Pierce\\Desktop\\sum_intensity_project.bmp", BIT8);

	FreeImage_Unload(fib);
	FreeImageIcs_IcsClose(ics);

}
コード例 #30
0
static void
TestFIA_GreyscaleU16bitElipseTest(CuTest* tc)
{
    const char *file = TEST_DATA_DIR "drone-bee-greyscale.jpg";

    FIBITMAP *src = FIA_LoadFIBFromFile(file);
    CuAssertTrue(tc, src != NULL);

    FIBITMAP *src2 = FreeImage_ConvertToType(src, FIT_UINT16, 1);

    FIARECT rect;

    rect.left = 100;
    rect.top = 100;
    rect.bottom = 200;
    rect.right = 300;

    FIA_DrawSolidGreyscaleEllipse (src2, rect, 200, 1);
 
    FIA_SaveFIBToFile(src2, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_GreyscaleU16bitElipseTest.bmp", BIT8);

    FreeImage_Unload(src);
    FreeImage_Unload(src2);
}