matlab - Find Value at a given Orientation in Matrix -
in matlab i've matrix where, in previous stage of code, specific element chosen. point of matrix find maximum, not maximum value between surounding neighbours given radius, maximum value @ given angle of orientation. let me explain example:
this matrix a:
a =
0 1 1 1 0 0 9 1 0 0 2 2 4 3 2 8 1 0 0 2 2 3 3 2 2 1 0 0 1 1 3 2 2 2 1 0 0 8 2 3 3 2 7 2 1 0 1 1 2 3 2 3 2 1
the element chosen in first stage 4 in a(2,4), , next element should maximum value with, example, 315 degrees angle of orientation, 7 in a(5,7).
what i've done is, depending on angle, subdivide matrix in different quadrants , make new matrix (an a's submatrix) values of quadrant.
so, example, submatrix a's 4th quadrant:
q_a =
4 3 2 8 1 0 3 3 2 2 1 0 3 2 2 2 1 0 3 3 2 7 2 1 2 3 2 3 2 1
and now, here question, how can extract 7?
the thing i've been able (and works) find values on threshold value , calculate how points orientated. then, saving values have similar orientation given 1 (315 degrees in example) , finding maximum among them. works guess there faster , "cleaner" solution.
this theory, don't have image processing toolbox test it. maybe can comment?
%make (r,c) center padding zeros if r > size(a,1)/2 @ = padarray(a, [size(a,1) - r], 0, 'pre'); else @ = padarray(a, [r-1], 0 'post'); if c > size(a,2)/2 @ = padarray(at, [size(a,2) - c], 0, 'pre'); else @ = padarray(at, [c-1], 0 'post'); %rotate angle (maybe should -angle or else 360-angle or 2*pi-angle, i'm not sure ar = imrotate(at,angle, 'nearest', 'loose'); %though think nearest , loose defaults %find max max(ar(size(ar,1)/2, size(ar,2)/2:end); %obviously must adjust handle case of odd dimension sizes.
also depending on array requirements, padding -inf
might better 0
Comments
Post a Comment