Search code examples
matlabmathmatlab-figurecomputational-geometry

Exterior and interior bounds for 2D data plot


https://dropmefiles.com/kIe16 - this contains two matrices from Matlab

With the code below, I'm building the following plot:

n = 1:1:(51);
plot(Xm(n,:)',Rm(n,:)','b.','MarkerSize',8)
grid on
grid minor

enter image description here

What I need to do: build the exterior and interior bounds for this 2D data plot, like here. This is very approximate.

enter image description here

My considerations: I roughly understand how to build the upper and lower exterior boundaries. Since the data is divided into vertical lines, we can simply find their min and max, and then connect them with straight lines. But I have absolutely no ideas about interior boundaries.


Solution

  • This is contour-from-image extraction problem.

    There is well-known Suzuki algorithm to extract whole hierarchy of contours from bw images.

    Suzuki, S. and Abe, K., Topological Structural Analysis of Digitized Binary Images by Border Following. CVGIP 30 1, pp 32-46 (1985).

    It is implemented in the OpenCV library (I used it from C++ and Python), and looks like it is accessible/available from MATLAB, https://www.mathworks.com/discovery/matlab-opencv.html