Matlab how to turn the image into 90 degrees?

advertisements

I have 100 gray images (256*256 pixels) and they are stored in faces.mat file. So in the faces.mat file, there are 100 rows and 65536(256*256) columns. Each row represents one image.

Now I want to reshape the faces matrix and showed the images.

I use:

for i=1:N
    imagesc(reshape(faces(i,:)'),256,256));
    colormap gray;
end

But I found my image turn 90 degree!

Could someone tell me how to turn the image right? Did I process images wrong when I turn them into face.mat? Below is the code I wrote to store images to matrix.

function ImageGenerate
Files = dir(strcat('D:\face\','*.tiff'));
LengthFiles = length(Files);
faces = [];
for i = 1:LengthFiles;
    Img = imread(strcat('D:\face\',Files(i).name));
    temp = im2double(Img);
    [row, col] = size(temp);
    vector = [];
    for i =1 : row
        for j = 1:col
            vector = [vector temp(i,j)];
        end
    end
    faces = [faces;vector];
end
save('faces2.mat','faces');


You can use imrotate to rotate images. To rotate 90 degrees counterclockwise, simply write

img = reshape(faces(i,:)'),256,256);
img = imrotate(img, 90);