0

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:

enter image description here

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
sundar
  • 59
  • 4
  • https://en.wikipedia.org/wiki/Edge_detection is your start. – Lucas Jan 18 '16 at 17:08
  • @Lucas - I have tried using edge detection methods but they do not really work well because the image is quite noisy. One possible way will be to fit a curve and then extract information from it, but I am not sure how. – sundar Jan 18 '16 at 17:18
  • 2
    Hi there! I rolled back your question to its previous state. It seems that the original question has already been answered, and that you are now asking a "continuation" of your problem, a next step. If that is the case, please, consider accepting the answer that helped you ( see https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work ) and open a new question with the new problem and reference this one. Keep on with the programing! – Ander Biguri Jan 19 '16 at 12:57

2 Answers2

1

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.

Result

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.

brodoll
  • 1,851
  • 5
  • 22
  • 25
Martin
  • 107
  • 1
  • 9
  • Hi Martin, your suggestion works well if I am interested only on the position of the curves. However, as I have edited my question now, I need to obtain the shape of the curve on the left and right hand side of the vertical lines. – sundar Jan 19 '16 at 12:33
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')
John
  • 5,735
  • 3
  • 46
  • 62
  • Hi John, Thanks for your suggestion. The canny edge detector works well and now I have edited my question to explain the entire problem. Any suggestions for obtaining the shape of the curve? – sundar Jan 19 '16 at 12:13
  • @sundar If this question has helped you, consider accepting it and asking another question as a continuation of this one! – Ander Biguri Jan 19 '16 at 13:00