gpt4 book ai didi

matlab如何将图像旋转90度?

转载 作者:行者123 更新时间:2023-12-02 06:39:21 24 4
gpt4 key购买 nike

我有 100 张灰度图像(256*256 像素),它们存储在 faces.mat 文件中。因此,在 faces.mat 文件中,有 100 行和 65536(256*256) 列。每行代表一个图像。

现在我想 reshape 面部矩阵并显示图像。

我使用:

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

但是我发现我的形象转了90度! enter image description here

谁能告诉我如何将图像调整到正确的位置吗?当我将图像转为face.mat时,我处理图像是否错误?下面是我编写的用于将图像存储到矩阵的代码。

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');

最佳答案

对于使用 90 度的 int 乘数旋转图像,有 rot90功能:

rot90(Img);

这比 imrotate 更有效比 just transpose 更通用其他答案中提出了这一点。

关于matlab如何将图像旋转90度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15123807/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com