
How to detect & fitting curvature from the binary image?
8 次查看(过去 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.
0 个评论
采纳的回答
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
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 个评论
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 Center 和 File Exchange 中查找有关 Interpolation 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!