Exemplo n.º 1
0
void software_3x3_filter(const char *input)
{
    filter_params filter;
    Image iImage = IMAGE_INITIALIZER;
    Image oImage = IMAGE_INITIALIZER;
    Benchmark b;
    int val = 0;

    initBenchmark(&b, "Software 3x3 Filter", "");

    filter_Init(&filter, 4, 2, 1, 4);
    ImageRead(input, &iImage);

    startBenchmark(&b);
    val = filter_Execute(&filter, &iImage, &oImage);
    stopBenchmark(&b);

    if(val != 0) {
        fprintf(stderr, "software_3x3_filter: ERROR: Filter failed.\n");
    }

    printBenchmark(&b);
    ImageWrite("software_3x3.tif",&oImage);
    ImageCleanup(&oImage);
    ImageCleanup(&iImage);
}
Exemplo n.º 2
0
static void LabelCleanup(LabelElement *c)
{
    if (c->compound != TTK_COMPOUND_TEXT)
	ImageCleanup(&c->image);
    if (c->compound != TTK_COMPOUND_IMAGE)
	TextCleanup(&c->text);
}
Exemplo n.º 3
0
static void ImageElementDraw(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    Drawable d, Ttk_Box b, Ttk_State state)
{
    ImageElement *image = elementRecord;

    if (ImageSetup(image, tkwin, state)) {
	ImageDraw(image, tkwin, d, b, state);
	ImageCleanup(image);
    }
}
Exemplo n.º 4
0
static void ImageElementSize(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
    ImageElement *image = elementRecord;

    if (ImageSetup(image, tkwin, 0)) {
	*widthPtr = image->width;
	*heightPtr = image->height;
	ImageCleanup(image);
    }
}
Exemplo n.º 5
0
void hardware_3x3_filter(const char *input)
{
#ifdef ZYNQ
    Image iImage = IMAGE_INITIALIZER;
    Image oImage = IMAGE_INITIALIZER;
    hardware_config hard_config;
    Benchmark b;
    int val = 0;

    initBenchmark(&b, "Hardware 3x3 Filter", "");
    ImageRead(input, &iImage);
    if(hardware_filter_init(&iImage, &hard_config) != 0) {
        fprintf(stderr, "hardware_3x3_filter: ERROR: Failed to initialize hardware driver\n");
        return;
    }

    startBenchmark(&b);
    val = hardware_filter_execute(&hard_config);
    stopBenchmark(&b);
    if(val != 0) {
        fprintf(stderr, "hardware_3x3_filter: ERROR: Filter failed.\n");
    }

    val = hardware_filter_cleanup(&iImage, &oImage, &hard_config);
    if(val != 0) {
        fprintf(stderr, "hardware_3x3_filter: ERROR: Hardware filter failed to clean up.\n");
    }

    printBenchmark(&b);
    ImageWrite("hardware_3x3.tif",&oImage);
    ImageCleanup(&oImage);
    ImageCleanup(&iImage);
#else
    fprintf(stderr, "Hardware 3x3 filter not supported on x86 platform\n");
#endif

}
Exemplo n.º 6
0
void verify_hardware(const char *input)
{
#ifdef ZYNQ
    hardware_config hard_config;
    filter_params filter;
    Image iImage = IMAGE_INITIALIZER;
    Image oImage_software = IMAGE_INITIALIZER;
    Image oImage_hardware = IMAGE_INITIALIZER;
    unsigned char *hImage = NULL;
    unsigned char *sImage = NULL;
    int i = 0;
    int val = 0;
    int r = 0;
    int c = 0;
    int error = 0;

    ImageRead(input, &iImage);

    filter_Init(&filter, 4, 2, 1, 4);
    if(hardware_filter_init(&iImage, &hard_config) != 0) {
        fprintf(stderr, "hardware_3x3_filter: ERROR: Failed to initialize hardware driver\n");
        return;
    }

    val = hardware_filter_execute(&hard_config);
    if(val != 0) {
        fprintf(stderr, "hardwaree_3x3_filter: ERROR: Filter failed.\n");
    }
    val = hardware_filter_cleanup(&iImage, &oImage_hardware, &hard_config);

    val = filter_Execute(&filter, &iImage, &oImage_software);
    if(val != 0) {
        fprintf(stderr, "software_3x3_filter: ERROR: Filter failed.\n");
    }

    hImage = oImage_hardware.data;
    sImage = oImage_software.data;
    for(r = 0; r < oImage_software.height; r++) {
        for(c = 0; c < oImage_software.width; c++, sImage++, hImage++) {
            if((r <= 2) || (r >= oImage_software.height-3)) {
                continue;
            }
            if((c <= 2) || (c >= oImage_software.width-3)) {
                continue;
            }
            if(*(hImage) != *(sImage)) {
                fprintf(stderr, "Mismatch: Row %d, Col %d, %d != %d\n", r, c, *sImage, *hImage);
                error = 1;
            }
        }
    }
    if(!error) {
        fprintf(stdout, "Images verified correct!\n");
    }

    ImageCleanup(&oImage_software);
    ImageCleanup(&oImage_hardware);
    ImageCleanup(&iImage);

#else
    fprintf(stderr, "Hardware verification of 3x3 filter not supported on x86 platform\n");
#endif


}