Identify curves in binary image

徘徊边缘 提交于 2019-12-25 06:55:58

问题


I have a binary image in which I would like to detect curves and output the coordinate pixel positions of the curves. The image is a noisy one and I would like to detect the two curves that run horizontally.

I am using MATLAB to perform image analysis. It will be great if you can provide me some hints towards identifying these curves.

An example picture:


回答1:


Use a canny edge detector. But, in order to make it work well, you'll have to read about the parameters that go into it, and "fiddle" with them. I expect Canny edge detection to do pretty well on this data set.

edge(yourImageHere, 'canny')



回答2:


If the images stay like this, you can probably do a pretty easy way of just counting the bits line by line (but this works only, if they remain horizontal or vertical). This will give you some kind of a histogram along the y-coordinate, that lets you average your y-coordinate for one of the lines.

% Read the image
img = imread('To_detect_curves.png');
% Convert it to BW
img = rgb2gray(img);
% Get the size of the image for the loops
[width,height] = size(img);
bits_per_line = zeros(height,1);
% Sum over all lines (rows)
for idx=1:height
    bits_per_line(idx) = sum(img(idx,:));
end
plot(1:height,bits_per_line)

As a result you will be having something like the following, where you can easily determine the Y coordinate for your lines.

This will surely not help you with more complex images, but for the image you provided it should do. If you have more information on what you want to do exactly, let us know.



来源:https://stackoverflow.com/questions/34860236/identify-curves-in-binary-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!