MATLAB How can I find the maximum dimension of a rotated image in MATLAB?

AI Thread Summary
To find the maximum dimension of a rotated image in MATLAB, the initial approach using the Pythagorean theorem to calculate dimensions based on a 45-degree rotation is flawed for non-square rectangles. Instead, the maximum size of a rectangle when rotated depends on its dimensions, where the larger dimension will dictate the containment size. Specifically, if the rectangle has dimensions a and b, with b being greater than a, a square with side b can encompass the rectangle at any rotation angle. This understanding clarifies that the maximum dimension is not simply derived from the 45-degree rotation assumption. Accurate calculations should focus on the rectangle's orientation and dimensions rather than relying solely on diagonal measurements.
eddiethegreat
Messages
1
Reaction score
0
Hi,

I am working on a MATLAB assignment and I stuck in rotating image,
I got a code that allocates starting and ending points in matrix I got, works with no difficulties. (which means this code allows me to ignore the white(255) points and get he actual size of image, that is a rectangle or a square)

My problem is I needed to find maximum dimension of this picture when rotated, so that I will expand all of my rotations to maximum rotation size. I can't obtain that so simply.

I got a solution (probably incorrect) which is:

think that the image I got is a rectangle with width:a, length:b,
when I rotate to 45degrees I get the maximum size, so that with simple Pythagorean theorem we can say that one side comes from a is a*sqrt(2) and other is b*sqrt(2), then maximum size of my image when rotated should be a square, with one side equals to (a+b)*sqrt(2), which gives an incorrect result.

Can you help me out?
 
Physics news on Phys.org
Probably of no help to the OP, but I would take a different approach. The idea that you get the largest containing rectangle if the original rectangle is rotated 45° is reasonable if the original figure is a square, but it isn't reasonable if the figure is a rectangle. In that case, if a and b are the dimensions of the rectangle, and b > a, then a square with side b would be able to contain the rectangle if it's rotated by any amount.
 
  • Like
Likes Wrichik Basu

Similar threads

Replies
4
Views
2K
Replies
4
Views
3K
Replies
1
Views
2K
Replies
2
Views
2K
Back
Top