Search code examples
type-conversionregionhalcon

Convert XLD to Region


I'm using this code to convert a XLD to a region:

 gen_region_contour_xld (ConnectedDirtRegionsXLDWorld,RegionWorld,'filled')

the XLD is like this:

enter image description here

and the resulting region looks like this:

enter image description here

If we overlap them, we can see that there are some differences, in particular the one marked with the arrow:

enter image description here

I understand that float values are converted to its nearest integer, so on average I would expect some to be rounded up, and some down and the area to be roughly the same. I cannot understand the differences in this case, since it looks that the values have all been rounded up..

I also tried by using set_system('neighborhood',4), it got a little bit better, but not really much. Also this causes a whole load of problem in the rest of the code, so I have set it back to 8 as it was before.

How can this conversion be made more precisely?


Solution

  • please have a look at the following image.

    enter image description here

    Here you can see the real dimension of a pixel (the red square).

    So space, where you have drawn the arrow, has 1-pixel width!