Clear Filters
Clear Filters

How to compair between two lines in binary images?

2 views (last 30 days)
Dear all,
I want to compare between two lines in two binary images (each image has one line as shown in the attachment).
One line is suppose to be more noisy than the other one (line_39 is more noisy than line_30). How can I differentiate between them. Is there someway to measure the noisiness of a line in binary images?
I tried to measure the standard deviation but I am not sure if this is a correct way:
I = imread('line30.tif');
B = bwboundaries(Line);
xy = B{1};
x_vals = xy(:,1);
y_vals = xy(:,2);
A = [x_vals ones(size(x_vals))];
b = y_vals;
sol = A\b;
m = sol(1);
c = sol(2);
errs = (m*x_vals + c) - y_vals;
Any idea how to do that?
Any help will be appreciated.

Answers (4)

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 21 Aug 2014
Edited: Salaheddin Hosseinzadeh on 21 Aug 2014
Hi Meshoo,
I guess you can do it in different ways.
What I think of, is Fourier analysis.
Forget about the x axis, I would find the position of each 1(white spot)
find(I == 1);
and store it's y parameter in variable called "Y" then I get fft of Y and compare it's frequency with the other image. Noise should increase the amplitude of the higher frequencies!
Then you can add (sum) all the frequency amplitudes and the grater the summation the higher the noise!
sum(abs(fft(Y)))); % something like this
If you tried it please let me know about its result.

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 21 Aug 2014
You may also want to try diff
Just like before, get the line out your picture by finding its white spots.
Get diff of its Y values and
This may also work
Please let me know the result!! I'm very curious to know!
Meshooo on 22 Aug 2014
Thank you very much. I tried what you suggested fft and diff but they didn't show any good significance to differentiate between the lines.
Image Analyst
Image Analyst on 22 Aug 2014
Did you try my suggestion? I have and it works for me.

Sign in to comment.

Image Analyst
Image Analyst on 21 Aug 2014
What I've done is to fit the y data to a polynomial, like a line or quadratic. Then calculate the RMS or MAD difference between the data and the fitted curve.
Image Analyst
Image Analyst on 22 Aug 2014
Like Salaheddin said, you don't need any toolbox to calculate differences, absolute values, and squares - it's just basic built in math. First you fit the curves with polyfit() and polyval() - again, built in to base MATLAB, not in toolboxes. See attached polyfit demo if you need an example.
Meshooo on 25 Aug 2014
Thank you very much for the demo. I will work on it sometime this week and will let you know guys the result.

Sign in to comment.

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 22 Aug 2014
How about to find the mean value of the curve, specially that it's a line, and consider it as a fitted curve, just as Image Analyst said, and then do the rest of your analysis? You don't need any toolbox for this.
Just consider you're dealing with a error, forget about line, analyze the error, find its mean, variance or RMS or standard dev and ...
One of them should give u a clue hopefully.

Community Treasure Hunt

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

Start Hunting!