How to compare either one value is closer to some other values?
조회 수: 1 (최근 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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!