How to compare either one value is closer to some other values?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Akzeptierte Antwort
dpb
am 9 Apr. 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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!