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.

How to use VLIB_grayscale_morphology funciton

Other Parts Discussed in Thread: OMAP-L138

Dear all,

I found it is hard for me to implement the VLIB_grayscale_morphology function, because I can't understand some of the input arguments:

void VLIB_grayscale_morphology
(
uint16_t blk_w,       //width of input block, in elements (UQ16.0)
uint16_t line_ofst,  //offset between input lines, in elements (UQ16.0)
uint16_t blk_h,       //height of input block (UQ16.0)
const uint8_t data_ptr[],   //input data pointer (UQ8.0)
uint16_t se_w,                   //width of structuring element block, in elements (UQ16.0)
uint16_t se_h,                   //height of structuring element block (UQ16.0)
const uint8_t se_ptr[],      //structuring element data pointer (UQ8.0) 
const uint8_t refl_se_ptr[],   //Reflected structuring element data pointer (UQ8.0)
uint8_t scratch1_ptr[],          //scratch 1 pointer. Size of this scratch buffer should be equal to input image size (UQ8.0)
uint8_t scratch2_ptr[],         //scratch 2 pointer. This scratch buffer is for temproray data storage and it is used only when se_h =1, and all the elements of                                                       //structuring element is one and (blk_h - (se_h-1))se_h = 0. Size of this buffer should be 32*se_h (UQ8.0)
uint8_t output_ptr[],              //output data pointer (UQ8.0)
uint8_t operation                 //Operation selection 
);

1. what does the 'line_ofst' mean, don't understand what is the offset and what is the input lines?

2. how to set scratch2_ptr[], don't understand what '(blk_h - (se_h-1))se_h = 0' mean?

Please provide an example to call this function, I would be very appreciated.

  • Welcome to the TI E2E forum. I hope you will find many good answers here and in the TI.com documents and in the TI Wiki Pages (for processor issues). Be sure to search those for helpful information and to browse for the questions others may have asked on similar topics (e2e.ti.com). Please read all the links below my signature.

    Please provide the DSP part number used.

    Thank you.

    Note: We strongly recommend you to create new e2e thread for your queries instead of following up on an old/closed e2e thread, new threads gets more attention than old threads and can provide link of old threads or information on the new post for clarity and faster response.

  • Hi Raja, thanks for reply. I did not find any one post similar questions, if you know please give a link. The DSP board I used is OMAP-L138 LCDK, it has a C6748 DSP. 

    Regards,

    Lucas

  • Hi Raja, am I put this question at wrong forum? If yes, could you show in which forum I can ask about VLIB technical questions, thanks!
  • Hi Lucas Chen,

    No problem, I have moved this post to OMAP-L1x forum. We will get back to you. Thank you for your patience.
  • Lucas,

    Have you check the API reference in the User Guide documentation found under vlib_c66x_3_2_0_2/docs.

    the parameter line_ofst refers to the pitch of the input image. If the each row of your image data doesn`t have any additional padded bits then pitch =imageWidth of the image data.

    I agree the description of the scratch buffer 2 is very confusing and will file a documentation issue against it but you can simply allocate a buffer of size ImagePitch*Imageheight and pass that to the API for scratch buffer 1 and 2.

    I think the author meant if the height of the structured element = image Height when they mention (blk_h -se_h)se_h =0.

    There is  a test example for the function in vlib that can be located under vlib_c66x_3_2_0_2\packages\ti\vlib\src\VLIB_grayscale_morphology.It compares output of the VLIB optimized kernel to natural C implementation of the function with some dummy test vectors. Please take a look at the implementation and let us know if there is any other information you need regarding this API.

    Regards,

    Rahul

  • 1. 'line_ofst' is "line offset"... it is another way of saying "pitch" or "stride" of the image.  This means how many bytes from the first pixel of one line, to the first pixels of the next line.  Many times it is the same as the width if you are operating on the full image, but this is not the case if you are operating this function on a region within a larger image.

    2. scratch2_ptr is an optional scratch memory pointer.  It is only required if the other parameters equal the following condition: se_h =1 AND (blk_h - (se_h-1))se_h = 0.  All of these are parameters that user sets in the API.  If these conditions are not true, then you can set scratch2_ptr to NULL.  If they are evaluated as TRUE, then you need to allocate a buffer of 32*se_h bytes, and pass the pointer to scratch2_ptr.  

    The example for calling each of the functions are already in the VLIB package.  Each function has a folder with VLIB kernel name and an extension of _d.c.

  • Jesse, thank you for your reply.

    I run the function, I am happy to see the result which seemed allright. But later I found a bit confused about the processed result. Because the result image has a bit of shift to top-left. I wonder to know why that happened, so I use a 10x10 array data to do a test,

    unsigned const char data[]={ 92, 99, 1, 8, 15, 67, 74, 51, 58, 40,

    98, 80, 7, 14, 16, 73 , 55, 57 , 64, 41,
    4 , 81 , 88, 20, 22, 54 , 56, 63 , 70, 47,
    85, 87 , 19, 21, 3, 60, 62, 69 , 71, 28,
    86, 93, 25, 2, 9 , 61, 68 , 75 , 52 , 34,
    17, 24, 76, 83, 90, 42, 49, 26 , 33, 65,
    23, 5 , 82, 89, 91 , 48, 30 , 32 , 39 , 66,
    79, 6 , 13, 95, 97 , 29, 31 , 38 , 45 , 72,
    10, 12, 94, 96, 78, 35, 37, 44 , 46, 53,
    11, 18, 100, 77, 84, 36, 43, 50, 27, 59};

    The 'data' do an ‘open’ operation by a 3x3 se (all element 1), in 3 cases,

    1 image no padding

    2 image padding 1 pixel boundary

    3 image padding 2 pixels boundary

    The padded pixels are ‘symmetric’ as Matlab open operation used.

    I compared results with Matlab result, seems only padded 2 pixels can obtain right result for a 3x3 SE, that not make sense. To my understanding,

    for a 3x3 SE, padding 1 pixel can obtain a completely result, but below result (blue rectangle) show it missing some pixels.

    Could you tell me the reason, and could you give some guiding ideas for padding image if big size SE need to be used.

    Thank you for you help!

  • hi !

    I have the same question as yours. Have you solve this problem? Could you give me some advice?