# How to rotate an image in Matlab

78 visualizzazioni (ultimi 30 giorni)
Emir Mulic il 4 Mag 2022
Modificato: Image Analyst il 7 Mag 2022
For my class project I have to create an app which loads an image and allows you to change Red, blue, green colors and the brightness. I have sucessfully coded this app. Now I have to add a button which would allow me to rotate the image 90 degrees each time. The requirements is that I do not use any pre existing matlab functions, but have to create my own.
Would greatly appreciate any help on this. Thank you.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (4)

J Chen il 4 Mag 2022
You basically read the image into a matrix, then change the array element to a different location (swich row to column, etc.)
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Emir Mulic il 4 Mag 2022
How would i store the image into an empty matrix. And then would I use some matrix transpose function ?

Accedi per commentare.

ac_bm_mat il 5 Mag 2022
Modificato: ac_bm_mat il 5 Mag 2022
Then operating with A matrix can give you 90 degree rotated image.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

yanqi liu il 7 Mag 2022
yes，sir，may be rot90，such as
for i = 1 : 4
im = rot90(im, 1);
figure; imshow(im, []);
end
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Image Analyst il 7 Mag 2022
rot90 is a built in function, which he is not allowed to use.

Accedi per commentare.

Image Analyst il 7 Mag 2022
Modificato: Image Analyst il 7 Mag 2022
You can use the apostrophe operator '
yourImage = yourImage';
This transposes the matrix. To now get a mirror image you have to swap rows or columns.
You can use the rotation matrix: https://en.wikipedia.org/wiki/Rotation_matrix
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Images in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by