MATLAB: How to flip the image

nested for loops

I have an image that I must flip using a nested for loop to flip the image vertically and horizontally, I have written a code that I think works but there is something wrong with it that it isn't. What have I done wrong?
%make 2d arrays values
imageData=imread('image.png');
[row, column] =size(imageData)
newImage=[]
%Use nested loops to change image mirrored
for i=[row:-1:1];
for j=[column:-1:1];
transposedMatrix(column, row) = imageData(i,j);
transposedMatrix
end
end
imshow(transposedMatrix)

Best Answer

The are a few problems with your code. First, if you want the image, you dont want to transpose. That will flip and rotate, As adam has pointed out, column and row, you arent actuall transposing anyway. A better and correct way to transpose is to use permute.
imageData=imread('image.png');
newImage = permute(imageData, [2 1 3]);
imshow(newImage);
To actually flip, you should be able to use the flip function
imageData=imread('image.png');
newImage = flip(imageData,1);
newImage = flip(newImage,2);
imshow(newImage);