Shift matrix in y direction

  • Follow


Hello All,

I want to shift a (120,120) matrix spatially.I used the following program and got the final image shited along x, as in I am able to shift the data right and left.i am having trouble with shifting the data up and down.


clear all;
fid = fopen('Homo_noabs_S4D4.bin','r+');
A = fread(fid,'double');
a=reshape(A,120,120,120);
a=a(:,:,15);
figure,imagesc(a);
Y=a;
a=reshape(a,14400,1);
b=zeros(size(a));
for j=1:size(a(:))-3000
    b(j)=a(j+3000);
end
size(b);
b=reshape(b,120,120);
figure,imagesc(b);
0
Reply Aishwarya 7/20/2010 10:48:04 PM

Aishwarya wrote:

> I want to shift a (120,120) matrix spatially.I used the following 
> program and got the final image shited along x, as in I am able to shift 
> the data right and left.i am having trouble with shifting the data up 
> and down.
> 
> 
> clear all;
> fid = fopen('Homo_noabs_S4D4.bin','r+');
> A = fread(fid,'double');
> a=reshape(A,120,120,120);
> a=a(:,:,15);
> figure,imagesc(a);
> Y=a;
> a=reshape(a,14400,1);
> b=zeros(size(a));
> for j=1:size(a(:))-3000
>    b(j)=a(j+3000);
> end
> size(b);
> b=reshape(b,120,120);
> figure,imagesc(b);

Have you considered using the optional arguments to imagesc() to specify the 
positions of the corners of the images?

imagesc([1000 3000], [2000 4000], a)

would put the lower left corner at axes coordinates [1000, 2000] and would put 
the upper right corner at axes coordinates [3000 4000]. (Not actually the 
corners themselves, but for the precise details look at the documentation for 
image() )
0
Reply Walter 7/20/2010 11:00:10 PM


"Aishwarya " <icemails@yahoo.co.in> wrote in message <i25934$7bs$1@fred.mathworks.com>...
> Hello All,
> 
> I want to shift a (120,120) matrix spatially.I used the following program and got the final image shited along x, as in I am able to shift the data right and left.i am having trouble with shifting the data up and down.
> 
> 
> clear all;
> fid = fopen('Homo_noabs_S4D4.bin','r+');
> A = fread(fid,'double');
> a=reshape(A,120,120,120);
> a=a(:,:,15);
> figure,imagesc(a);
> Y=a;
> a=reshape(a,14400,1);
> b=zeros(size(a));
> for j=1:size(a(:))-3000
>     b(j)=a(j+3000);
> end
> size(b);
> b=reshape(b,120,120);
> figure,imagesc(b);

If you have the image processing toolbox you could use my tool:
http://www.mathworks.com/matlabcentral/fileexchange/27251-imtranslate
0
Reply Sean 7/21/2010 1:59:06 PM

2 Replies
340 Views

(page loaded in 0.04 seconds)

Similiar Articles:













7/29/2012 7:21:06 AM


Reply: