16 views (last 30 days)

Hi, I am trying to make a coarse resolution matrix of 3600x1800 from a 8640x4320 matrix by summing up the elements of the matrix.

Hi am trying the following: However this doesnot work with fractions (here, 2.4)

%%%%Z1 is the original 8640x4320 matrix

abc = blockproc(Z1,[2.4,2.4],@(x)sum(x.data));

abc1 = blockproc(abc,[1,2.4],@(x)sum(x.data));

Matt J
on 23 Jan 2020

Edited: Matt J
on 27 Jan 2020

A 3rd approach, more memory conserving and faster,.

Z1=randi(100,8640,4320);

u = 5; %upsampling factor

d = 12; %downsampling factor

t = d/u; %reduction factor

[m,n]=size(Z1);

L1=speye(m); L2=speye(round(m/t))/u;

R1=speye(n); R2=speye(round(n/t))/u;

L=repelem(L2,1,d) * repelem(L1,u,1);

R=(repelem(R2,1,d) * repelem(R1,u,1)).';

tic

abc4= L*(Z1*R);

toc

Note as well that the matrices L and R are reusable on other Z1 of the same size that one might wish to downsample later on.

SChow
on 23 Jan 2020

Edited: SChow
on 23 Jan 2020

Matt J
on 23 Jan 2020

I would recommend doing this in horizontal and vertical passes, so that the intermediate matrix S won't be so large,

S = sepblockfun( repelem (Z1 , scaling, 1) , [12,1], 'sum');

abc2 = sepblockfun( repelem (S, 1, scaling) , [1,12], 'sum')/scaling^2;

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.