필터 지우기
필터 지우기

How to detect & fitting curvature from the binary image?

조회 수: 12 (최근 30일)
DW
DW 2023년 11월 21일
댓글: Image Analyst 2023년 11월 23일
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');
  댓글 수: 2
DW
DW 2023년 11월 21일
Thank you so much.
That was helpful.
Mathieu NOE
Mathieu NOE 2023년 11월 21일
as always , my pleasure !

댓글을 달려면 로그인하십시오.

추가 답변 (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에서 Interpolation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by