Clear Filters
Clear Filters

how to get the function of a curve in an image by matlab

1 view (last 30 days)
hi all
id like to know if there is any way if I have the photo of a lets say sinusoidal curve and need to extract its function , how is it possible to do in matlab ? also i need to know how to let matlab distinguish the curve of the function in the image

Accepted Answer

Image Analyst
Image Analyst on 5 Mar 2014
Yes, it is. You can threshold the image and use find() to find the top-most pixel in the curve. So that will be your signal. You can then get the period and amplitude and thus define the equation.

More Answers (1)

farzad
farzad on 6 Mar 2014
thank you so much but please can you elaborate it ? what did you mean by threshold the image ? and in the find , I should enter the x,y value of the point that i already know ?
  1 Comment
Image Analyst
Image Analyst on 6 Mar 2014
Let's say the curve is black on a white background. And there is nothing else in the image, like you've cropped it so no axes are there, it's just the signal. You can do
binaryImage = grayImage < 128; % or whatever value works.
[rows, columns, numberOfColorChannels] = size(grayImage);
% For each column, find the pixel that's highest -
% that will be the y signal value for that column.
for c = 1 : columns
y(c) = rows - find(binaryImage(:,c), 1, 'first') + 1;
end

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!