It was not very clear, but I'll try to help, let's start with a simple example, let's create a 6x6
array to exemplify:
A = [1 2 3 4 5 6; 7 8 9 10 11 12; 13 14 15 16 17 18; 19 20 21 22 23 24; 25 26 27 28 29 30; 31 32 33 34 35 36]
OK This will give you the following array:
A =
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24
25 26 27 28 29 30
31 32 33 34 35 36
Perfect by following your logic (if I understand correctly) you need to walk by applying a 3x3
window, this means you would need to extract the following sub-arrays from the main array:
Your first sub-array would be:
1 2 3
7 8 9
13 14 15
Second:
4 5 6
10 11 12
16 17 18
Third:
19 20 21
25 26 27
31 32 33
Fourth:
22 23 24
28 29 30
34 35 36
The logic to do this is to actually walk through a loop and increment the row and column by 3:
A = [1 2 3 4 5 6; 7 8 9 10 11 12; 13 14 15 16 17 18; 19 20 21 22 23 24; 25 26 27 28 29 30; 31 32 33 34 35 36]
[l, c] = size(A)
c1=1;
c2=3;
while c1 <= c
l1 = 1;
l2 = 3;
while l1 <= l
D = A(c1:c2, l1:l2)
l1 = l1 +3;
l2 = l2+3;
end
c1 = c1+3;
c2 = c2 +3;
end
The above code prints the sub-matrices shown in this example.
To extract the minimum value inside each sub-array you can use the min
function of matlab, in this case add after D = A(c1:c2, l1:l2)
the following line minimo =min(D(:))