How to compare either one value is closer to some other values?

1 visualización (últimos 30 días)
Tanmoy
Tanmoy el 9 de Abr. de 2015
Respondida: dpb el 9 de Abr. de 2015
For example, I have an image containing lines. A line with SLOPE = 50 degree, if any other line is between 45-55 degree of SLOPE (say 48,53), I wanna merge those line. (I mean, merge the line with closer/ nearer slope). I have a matrix with slopes of all line in the image SLOPE(20*1) of class double. I am trying by stating
if (SLOPE(a) >= SLOPE(:,1) - 5 || SLOPE(a) <= SLOPE(:,1) + 5)
dataset(a) = dataset(a) + dataset of those that match if condition
end
Don't get confidence, this inequality is defined properly? say, dataset is (x,y) location of that lines. How can I write the 2nd line of the code? SLOPE of a particular line could be equal to none, some, or all of them.

Respuesta aceptada

dpb
dpb el 9 de Abr. de 2015
Use histc with the EDGES input the boundaries between desired bins; in your example it would be
[~,ix]=histc(SLOPE,[-inf 45 55+eps inf]);
Then
SLOPES(ix==2)
is the elements between 45-55, inclusive. NB: the use of +eps on the upper bound of the range; by default histc use >=X< as the range so must modify a little to get the inclusive upper bound.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by