How to find the midpoint between two curves in an image

8 ビュー (過去 30 日間)
Suraj Sudhakar
Suraj Sudhakar 2022 年 7 月 27 日
コメント済み: Suraj Sudhakar 2022 年 8 月 10 日
I have attached the image of the curve, I would like to extract the midpoint between the curve. (Ideally, the thickness of the given curve is constant). I tried extracting the gradient direction and using the line along the gradient direction to extract the midpoint, but the gradient direction is not perfectly tangential due to the discrete nature of the iimage
for (points in the upper line)
%get the gradient
m = sin(theta); %slope of the line
%use the slope and known initial point (and assumption that thickness is constant to get a midpoint)
%issue is gradient can only take a few directions, hence getting wrong results
Wanted to know if there is any better way of doing this


Akira Agata
Akira Agata 2022 年 8 月 7 日
How abou the following?
% Load image
I = imread('');
% Binarize the image
I = rgb2gray(I);
BW = imbinarize(I);
% Apply bwdist
J = bwdist(~BW);
% Find maximum position for each row
[~, pt] = max(J, [], 2);
% Create the output image
pt_ind = sub2ind(size(BW), 1:size(BW, 1), pt');
BW2 = false(size(BW));
BW2(pt_ind) = true;
% Let's check!
imshowpair(BW, BW2)
  3 件のコメント
Suraj Sudhakar
Suraj Sudhakar 2022 年 8 月 10 日
That works, thanks


その他の回答 (0 件)




Community Treasure Hunt

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

Start Hunting!

Translated by