Image average multipe frame same matrix. Matlab - matlab

I've a matrix RF = RF(512,1728). This matrix contain 9 images and the number of frame is equal 9, the first image considering one single frame is: RF1 = RF1(:,1:192) etc. So I'd like to average the hole matrix in order to obtain one single image. any idea?
Thanx in advance!

Just reshape the matrix
allRF=reshape(RF,[512,192,9]);
and compute the mean
meanRF=mean(allRF,3);

A simple, vectorized way:
k=reshape(RF,512,192,1728/192);
mean(k,3)

Related

Why does the ifft2 image split in 4?

After doing a two-dimensional inverse Fourier transform in MATLAB, I got the 4-part split image of MRI. How can I solve this problem?
for i =1:8
raw_i = ifft2(kspace(:,:,i)); %kspace contains the 8-coil wise MRI data w.o undersampling , 160*160*8 matrix
imshow(abs(raw_i),[]);
Use fftshift to rearrange the result; it shifts the zero frequency parts to the center of the image.
imshow(fftshift(abs(raw_i)),[]);

How to calculate per-page STD in matlab?

Suppose I have matrix A of 100x200x300. Third dimension is called "page" in Matlab and this matrix has 300 pages then.
Now I want to calculate standard deviation within each page and get a result matrix of 1x1x300.
I can't just do
std(std(A,0,1),0,2)
because normalization will be wrong as I think.
You need to collapse the first two dimensions into one (i.e. into columns) using reshape; and then compute std along each column:
Ar = reshape(A, size(A,1)*size(A,2), size(A,3));
result = std(Ar);
This will give you a 1x300 vector as result. If you really need it to be 1x1x300, use
result = shiftdim(result, -1);

How can I equalize the size of those two matrices in matlab?

I have the following two matrices with the sizes shown:
x ---> 256x256
y ---> 65536x2
How can we equalize the sizes of those two matrices? In other words, how can we make size y equal size x? I know we can use padarray. But, how can we use it here? Wouldn't some information get lost from this equalization?
Thanks.
Have a look to Reshape. If you need help with it. Provide more informations of what you want to do.
y = reshape(y,256,256);
Use reshape function then:
reshape(y,size(x))

Matlab Isolating 2D Array from 3D Matrix

I have a 3D matrix called M of size <100x100x100>, so basically coordinates.
I am trying to get the array of at specific values of y. However using M(:,1,:) I get a <100x1x100> matrix whereas finding I can use M(:,:,1) and get a <100x100> matrix.
Is there an easy way to turn the <100x1x100> into a <100x100> by either isolating it a different way or using a short translation?
Thanks,
Does squeeze do what you want?
a = ones(100, 1, 100);
b = squeeze(a);
size(b) % 100x100

get a 2d matrix out of a 3d matrix Matlab

I have a 3d mxnxt matrix , I want to be able to extract t 2d nxm matrices.
In my case I have a 1024x1024x10 matrix and I want to have 10 images showing it to me.
This is not reshaping, I want just part of the data each time, is there a way doing it simpler that just coping member by member the data needed?
Yes, just do e.g.:
my_2d_array = my_3d_array(:,:,n);
For more info, see e.g. http://www.mathworks.com/help/techdoc/math/f1-86528.html.
as Oliver said you can use:
my_2d_array = my_3d_array(:,:,n);
You can use squeeze function to remove the 1*1 of the matrix.