利用VLIB函数进行形态学操作:VLIB_dilate_bin_square

来源:百度文库 编辑:神马文学网 时间:2024/04/27 14:39:23

Hello Michael,

Please refer to VLIB_testDilationErosion.c example in the VLIB package.

I will try to explain how to do the same for your case.

1) First use the Create32BitPackedBinImage function to create a binary packed image.

I am assuming by binary image you meant a 720x480 binary array. After you run the above function, you would get a 720x480/32 array.

2) Dilation is performed by a 3x3 kernel. So the output for the first and last lines cant be determined due to edge effect.

The call would look like this:

VLIB_dilate_bin_square((const unsigned char *) InputPackedData , (unsigned char *) DilatedPackedData + 720/8, (720)*(480-2), 720);

The offset of 720/8 is used to move the output pointer to the second line.

An alternative way of doing the same is

  for(i = 1; i <480-1; i++)
    {
        VLIB_dilate_bin_square((const unsigned char *) PackedData + 720/8*(i-1) , (unsigned char *) DilatedPackedData + 720/8*i, 720, 720);
    }

 Let me try to clarify the terminology of pitch as I think the confusion is due to this.

You can think of it as an ROI region with a block height and block width inside an image.

To represent the ROI, you would not need the image height. But you would need the image width for pointer increment to the next line.

In VLIB, the actual image width is called as pitch. Block height is simply called height and block width is simply called width.

Please feel free to ask for more clarification.