Greetings Overflowers,
I have a gray image matrix in MatLab and few specific pixel coordinates of that image.
I want to calculate the mean and standard deviation of values within a rectangular area in that matrix such that:
- it is positioned at an angle (e.g. 0, 45, 90, 135)
- it contains all the few pixels
- its area is minimum for each angle and its height >= its width
For now I would be happy if I can do so for the vertical, horizontal and both diagonals cases, though I would really appreciate if I can do it for any angle in hand.
Any ideas ?
So, given the input angle
theta, and bunch of coordinatespoints, you want the minimum enclosing rectangle at that angle (what does that mean? — the height axis is set at that angle? the width axis? And angle from vertical-clockwise (like headings) or horizontal-anticlockwise (like maths)?).Further more, we adjust the height so that it’s >= the width.
In that case, I think the following might work:
theta(use a rotation matrix for this)thetaany more since we’ve already transformed the coordinates)theta).Something like this could work (untested), tweak to your desire:
Then use it like this (the one caveat is X/Y vs i/j):