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

In summary, the speaker is working on a MATLAB assignment involving rotating an image and finding its maximum dimensions. They come up with a solution involving Pythagorean theorem, but it does not provide the correct result. They request help from the listener, who offers a different approach.
  • #1
eddiethegreat
1
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
  • #2
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

1. How do I rotate an image in MATLAB?

To rotate an image in MATLAB, you can use the imrotate function. This function takes in the image you want to rotate and the desired angle of rotation as inputs. It will then create a rotated version of the image and return it as an output.

2. Can I rotate an image by a specific angle in MATLAB?

Yes, the imrotate function allows you to specify the angle of rotation in degrees. You can also choose to rotate the image clockwise or counterclockwise by using a negative or positive angle, respectively.

3. Will rotating an image in MATLAB affect its quality?

Rotating an image in MATLAB should not affect its quality significantly. However, if you rotate an image by a large angle or if the image has a low resolution, you may notice some distortion or blurring in the rotated image.

4. How do I save a rotated image in MATLAB?

To save a rotated image in MATLAB, you can use the imwrite function. This function takes in the rotated image and the desired file name as inputs. It will then save the rotated image in the current working directory.

5. Can I rotate only a specific part of an image in MATLAB?

Yes, you can use the imrotate function with a specific region of interest (ROI) to rotate only a part of an image. This can be done by specifying the ROI using the imcrop function and then passing it as an input to the imrotate function.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
745
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top