I need help to merge 2-for loops using filter2 (2D) filter or any suitable way to make my code efficient enough.
I want to run a 2D sliding window of 256*256 to move through whole data and calculate one 'dc' for each patch, moreover, I just received last value of ''dc'' while rest of previous values are 0.
img= [1:1664,1:4352] %% Size of image
PRF = 1925;
k = 128; % size of patch
for i = k+1:size(img_o,1)-k
for j = k+1:size(img_o,2)-k
Bb = img_o(i-kk:i+kk-1, j-kk:j+kk-1);
dc(k) = doppler_centroid(Bb, PRF); %% this function calculate doppler centroid ''dc''
C(i,j) = dc(k);