This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TMDXIDK57X-LCD: Imglib problem

Part Number: TMDXIDK57X-LCD

Tool/software: TI C/C++ Compiler

Hi,

I'm trying to use imglib library to apply a simple 3x3 kernel (Gaussian filter) to an image, I use IMG_conv_3x3_i8_c8s, for that purpose, I have broken my input image into several iterations and each time I feed some rows of the image to IMG_conv_3x3_i8_c8s routine, I checked some first iterations and it is working correctly, but after some iterations, it starts to generate zeros, can anyone explain why that happens? how can I correct my code?

this is my input image known as cameraMan:

this is my output image with zeros for most parts:

this is my main.c:

/*
 *  ======== main.c ========
 */

#include <xdc/std.h>

#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>
#include <ti/imglib/imglib.h>
#include <ti/sysbios/BIOS.h>

#include <ti/sysbios/knl/Task.h>
#include "ImgCode.h"

#define imSize   256*256
#define Cols     256
#define Rows     256


const char myMask[] = {
                                     0, 1, 0,
                                     1,  2,  1,
                                     0,  1,  0
};



Void taskFxn(UArg a0, UArg a1)
{
    unsigned char  resultImage[(254)*(252)];
    int iter0=0,iter1=0;
     for(iter0=0,iter1=0; iter0<(256*256-3*256); iter0+=256,iter1+=252){
         IMG_conv_3x3_i8_c8s(&myImage[iter0], &resultImage[iter1], 252, 254, myMask, 3);
     }


}

/*
 *  ======== main ========
 */
Int main()
{ 
    Task_Handle task;
    Error_Block eb;

    System_printf("enter main()\n");

    Error_init(&eb);
    task = Task_create(taskFxn, NULL, &eb);
    if (task == NULL) {
        System_printf("Task_create() failed!\n");
        BIOS_exit(0);
    }

    BIOS_start();    /* does not return */
    return(0);
}

and this is my project folder:

IMGLIBReport.zip

Im using sys/BIOS 6_75_02_00 , XDCtools 3_51_01_18, imglib_c66x_3_2_0_1 and CCS 9.1.0.

any help would be appreciated.

alex.

  • Alex,

    HAve you tried to run the test vectors that are provided as part of the IMGLIB for IMG_conv_3x3_i8_c8s function. This will indicate how the mask needs to applied on the image and also if there are special alignment and input/oytput vector size restrictions for the function or also indicate how the images need to be padded to handle edge pixels. I hope you have check the API guide for these details:

    If the optimized version doesn`t work as expected, I would switch to the _cn (Natural C) implementation of the function, This will not have the same restriction for size and alignment as the optimized version. Also indicate what memory is the image stored.

  • Dear Rahul,

    I have read the documentation and ti examples and I know how it works, I also tried to add two columns of zero  to my original image so that the width parameter could be multiple of 4:

        unsigned char  resultImage[(254)*(256)];
        int iter0=0,iter1=0;
         for(iter0=0,iter1=0; iter0<(256*258-3*258); iter0+=258,iter1+=256){
             IMG_conv_3x3_i8_c8s(&myImage[iter0], &resultImage[iter1], 256, 258, myMask, 3);
         }

    0027.IMGLIBReport.zip

    but still, I'm getting the same output, I have traced my code, it's working correctly for first iterations, but after some point ( around 12th iteration) it starts to generate zero, I also tried natural C implementation, the output was the same. after that, I tried to store the result of each individual iteration in an unsigned char [256]:

    unsigned char  resultImage2[256];
        int iter0=0,iter1=0;
         for(iter0=0,iter1=0; iter0<(256*258-3*258); iter0+=258,iter1+=256){
             IMG_conv_3x3_i8_c8s(&myImage[iter0], resultImage2, 256, 258, myMask, 3); // resultImage is correct for all iterations
    }

    and it is working correctly for all iterations!!! but, again, whenever I try to store those values in a bigger array, IMG_conv_3x3_i8_c8s starts to generate zeros after some iterations:

        unsigned char  resultImage[(254)*(256)];
        unsigned char  resultImage2[256];
        int iter0=0,iter1=0;
         for(iter0=0,iter1=0; iter0<(256*258-3*258); iter0+=258,iter1+=256){
             IMG_conv_3x3_i8_c8s(&myImage[iter0], resultImage2, 256, 258, myMask, 3); // resultImage2 is zero after some iterations
             memcpy(&resultImage[iter1], resultImage2, 256); 
         }

    maybe there is some sort of leak in my memory, but I can't find it.

  • Alex,

    We can only provide assistance on the IMGLIB API usage. Any system level implementation issues like memory leak may need further debugging on your side to narrow down for us to look at.

    Please post an update if this is root caused to TI provided software.

    Regards,

    Rahul

  • Hi Rahul,

    Thank you for reading this, I have simplified my problem to 5 lines of code, so that  ti's engineers can find the problem easily. still, I'm not sure whether it's a memory leak or bad usage of API or anything else. But I'm having some similar issues with some other APIs like IMG_histogram_8, which calculates first half of the result correctly, but the other half (second 128 values) are filled with an invalid value, I may open another issue for that.

    Regards,

    Alex.

  • Alex,

    Is this issue resolved or do you still need help with this issue.

    Regards,

    Rahul

  • Rahul,

    My problem remains unresolved, but since I'm not getting any answer from this question, I close it.

    Regards,

    Alex.