Hi Douglas,
I think you might have not initialised the padding pixels around the source image properly. All spatial filter functions, convolutional and morphological, assume that the source image is padded with the proper values. The functions reads the padding pixels outside the source image area as it computes the edge pixels in the destination image. It is up to the caller to allocate sufficient padding and initialise those pixels properly. Please also note that binary images are stored as 1 bit per pixel and not 8 bits.
For binary morphological operations, the padding is initialised using the functions rapp_pad_const_bin() or rapp_pad_clamp_bin(), depending on what boundary conditions you want. In your case the process would be as follows.
1. Allocate a larger buffer to hold the binary threshold image + the necessary padding.
2. Threshold the source image, letting the function write to the actual image area within the larger buffer allocated above.
3. Initialise the padding pixels properly. The required size of the padding depends on the structuring element size.
4. Perform the desired morphological operation on the binary source image.
The recommended practice is to always use pixel buffers with enough padding outside the real image area in order to avoid copying data for operations where padding is needed.
Unfortunately there are not much sample code snippets available, but the docs are quite extensive and should contain everything you need. Please see the sections on padding, pixel buffer semantics and morphological filters for details.
Best regards,
Johan