Home > OS >  Exterior and interior bounds for 2D data plot
Exterior and interior bounds for 2D data plot

Time:01-23

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.

CodePudding user response:

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

CodePudding user response:

1.- Use diff(..,1,1) and diff(..,1,2) to obtain 1st derivatives along x and along y respectively.

diff(..,1,1) is 1st derivative along x axis and diff(..,1,2) is 1st derivative along y axis.

Display origin is located on top left corner and y increases downwards.

2.- The obtained 2D 1st derivative shows the points where the shape starts and stops, for each row and column, including the inner gaps.

  • Related