Extracting points for sharp curvature from signed distance function array
2 views (last 30 days)
Show older comments
I have a signed distance array, extracted from a black-and-white bitmap. The shape described by the bitmap is arbitrary, and could contain concave or convex curvature of varying scales. I am interested in extracting the position of corners that are sharper than a certain amount. I'm frankly not sure how to define that sharpness here; what I care about is 'shoving' a circle of a defined radius into that corner, and for the corner in total to be larger than that circle (in other words, I don't want it reporting every single rasterisation of the bitmap):
- identifying if any convex curvatures' radius is less a code-defined radius of curvature limit
- calculating what coordinate in the bitmap represents the centrepoint of the code-defined radius of curvature limit for that corner, and then
- to list any and all found sets of centerpoint coordinates in an array of format T= [x1, y1; x2, y2; .... xn, yn].
I'm obtaining my distance array and interpolation function as follows.
X = imread("MeshTest01.bmp"); %load logical (1 or 0) bitmap
A = imrotate(X,-90);
E=edge(A); % Edge finding of bitmap
DistE = bwdist(E, "euclidean"); % signed distance function from edge
DistA = bwdist(A, "euclidean"); % signed distance function from whitespace
D = DistE-2*DistA % Pixel-enumerative distance for signed distance function from material (outside is positive)
D = double(D); %make array forced to Double so interpolation works correctly
Fi = griddedInterpolant(D,'linear')
fd=@(p) Fi(p); %defining the interpolation function call
0 Comments
Answers (1)
Supraja
on 5 May 2023
You can use ‘ischange()’ function which detects abrupt changes in data.
The detailed documentation link for the same is given here: https://www.mathworks.com/help/matlab/ref/ischange.html?searchHighlight=ischange%20function&s_tid=srchtitle_ischange%20function_1
The sample code to use this function is as shown below:
f = @(x) 1-(x./sqrt(1+x.^2)); % Create Function
x = linspace(-10, 10);
y = f(x);
changes = ischange(y, 'linear', 'SamplePoints', x);
plot(x, y, '-', x(changes), y(changes), 'gp')
grid on
axis('equal')
xlim([-2.5 2.5])
0 Comments
See Also
Categories
Find more on Display and Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!