How to compare either one value is closer to some other values?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
dpb
2015-4-9
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!