How to get pixel location in after rotating the image?
You first need to define where you are rotating your image around.
If you are rotating it around (0,0) (i.e. your image is located in the positive x and y quadrant), you can apply a rotation matrix in its vanilla form:
$\left[\begin{array}{c}x' \\y' \\1\end{array}\right] = $
$\begin{bmatrix}\cos \theta &amp;\sin \theta &amp;0\\-\sin \theta &amp; \cos \theta &amp;0 \\0 &amp;0 &amp;1\end{bmatrix}$
$\left[\begin{array}{c}x \\y \\1\end{array}\right] = $
$\left[\begin{array}{c}x\cos\theta + y\sin\theta \\-x\sin\theta+y\cos\theta \\1\end{array}\right]$
where x and y is your starting pixel location, x' and y' is your new pixel location, and $\theta$ is the counterclockwise angle to rotate (you can ignore the 3rd row for now). Notice that because you are using sine and cosine functions, the new pixel location is unlikely to be an integer, so you will need to do some rounding.
However, if you are rotating around the center of the image (which is the more common use-case), you will need to first translate the &quot;origin&quot; of your image to the center, apply your rotation, then move your image back.
This alters the calculations to this:
$\left[\begin{array}{c}x' \\y' \\1\end{array}\right]$
$=\begin{bmatrix}1 &amp;0 &amp;0\\0 &amp;1 &amp;0 \\X/2 &amp;Y/2 &amp;1\end{bmatrix}$
$\begin{bmatrix}\cos \theta &amp;\sin \theta &amp;0\\-\sin \theta &amp; \cos \theta &amp;0 \\0 &amp;0 &amp;1\end{bmatrix}$
$\begin{bmatrix}1 &amp;0 &amp;0\\0 &amp;1 &amp;0 \\-X/2 &amp;-Y/2 &amp;1\end{bmatrix}$
$\left[\begin{array}{c}x \\y \\1\end{array}\right]$
$=\left[\begin{array}{c}(x-X/2)\cos\theta + (y-Y/2)\sin\theta + X/2 \\-(x-X/2)\sin\theta+(y-Y/2)\cos\theta + Y/2 \\1\end{array}\right]$
where capital X and Y are the size of your image in the x and y directions.

You can read more about image transformations on the mathworks page here.