How to detect & fitting curvature from the binary image?

3 次查看(过去 30 天)
I have a binary image, and I want to detect & draw curvature from the image.
This is my original image.
This is what I want.
Since the positions of arcs and straight lines in a binary image are not constant and thousands of images must be processed, I want to detect the pixel location without specifying it.
I did some searches, but not sure where should I start.
I would appreciate it if you could recommend some things to study.
Thank you.

采纳的回答

Mathieu NOE
Mathieu NOE 2023-11-21
hello
this would be my suggestion, based on this Fex submission :
result
code :
filename = 'image.png';
tmp = imread(filename);
inpict = im2double(rgb2gray(tmp));
[m,n] = size(inpict);
% find values above threshold
[y,x] = find(inpict>0.5);
% flip y direction (on the data)
y = m-y;
% take unique values
[y,ia,ic] = unique(y);
x = x(ia);
% smooth the data with smoothn
% FEX : https://fr.mathworks.com/matlabcentral/fileexchange/25634-smoothn?s_tid=srchtitle
z = smoothn({x,y},1e3,'robust');
xs = z{1};
ys = z{2};
subplot(1,2,1)
imshow(inpict);
subplot(1,2,2)
plot(x,y,'*k',xs,ys,'r');

更多回答(1 个)

Image Analyst
Image Analyst 2023-11-21
See my solution to your duplicate question:
If you want, you could split the curve up into right half and left half but I assumed that the "thing" is actually some single surface with a rod sticking into it so both sides would probably have the same curvature so I just fit both sides to one polynomial.
  2 个评论
DW
DW 2023-11-23
I tried "Mathieu NOE" 's solution also, but your solution helped me more with my specific problem.
Since the curved surfaces on the left and right are subtly (sometimes very) different, now I'm trying to fit the curves separately for the left and right.
Thank you again!
Image Analyst
Image Analyst 2023-11-23
You could certainly split mine up into right and left sides. Note that @Mathieu NOE still had the spike in there, and it uses a File Exchange program, and smooths the data locally, while mine ignores the spike, uses only built-in functions, and fits the entire surface to a smooth polynomial rather than just smoothing locally. It just depends on how you prefer to do it.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by