2015-11-26 112 views
1

我有一个变量X,它是32乘32乘32.我希望imagesc这显示人脑的图像。然而,随着代码,我跑(见下文)我得到如下图像:如何在Matlab中通过P矩阵来旋转N中的图像通过P中的矩阵

Brain rotated 90 degrees

我想通过90度,使得脊髓是在该图的底部以旋转此。我已经尝试过诸如imrotateflipdim等算法,但这些只是给我一个绿屏。

我的代码迄今:

clc; clear all; close all; 
set(0,'defaulttextinterpreter','latex',... 
    'DefaultAxesFontSize',16,'defaultLineLineWidth',2) %use LaTeX 
h1=figure('units','normalized','outerposition',[0 0 1 1]); %create Figure. 
filename = 'testnew51.gif'; 
X = analyze75read('Anatomical.img'); 
Y=analyze75read('Mask.img'); 

hsurface=imagesc(squeeze(X(:,15,:))); 
C=imrotate(hsurface,-90); 

axis equal 
colormap jet 
shading interp 

figure 
B=flipdim(hsurface,1); 
imagesc(B) 

figure 
imagesc(C) 

非常感谢, 瑞安

+1

在显示图形后,您是否尝试过使用'axis ij'或'axis xy'? – rayryeng

+0

@rayryeng这似乎并没有做任何事情。我想旋转数据,而不仅仅是轴的值。 – timmr002

+0

您是否试过对数据使用[rot90](http://fr.mathworks.com/help/matlab/ref/rot90.html?refresh=true)? – Ikaros

回答

1

感谢HamtaroWarrior。通过x轴循环的工作代码如下:

X = analyze75read('Anatomical.img'); 
Y=analyze75read('Mask.img'); 
for i=1:32; 
Xy=(rot90((squeeze(X(i,:,:))))); 
imagesc(Xy); 
title([num2str(i)]); 
pause(0.5); 
clear Xy 
end