I saw a code from rgbe bayer conversion program as follows:
% subsample HDR image to get RGGB Bayer pattern
I(1:2:end, 1:2:end) = HDR(1:2:end, 1:2:end, 1); % R
I(1:2:end, 2:2:end) = HDR(1:2:end, 2:2:end, 2); % G odd
I(2:2:end, 1:2:end) = HDR(2:2:end, 1:2:end, 2); % G even
I(2:2:end, 2:2:end) = HDR(2:2:end, 2:2:end, 3); % B
To understand this concept i tried this code with simple arrays in command window as follows:
>> x=[1 2 3 4 5;6 7 8 9 10;11 12 13 14 15;16 17 18 19 20]
x =
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
>> h=[20 19 18 17 16; 15 14 13 12 11; 10 9 8 7 6; 5 4 3 2 1]
h =
20 19 18 17 16
15 14 13 12 11
10 9 8 7 6
5 4 3 2 1
>> x(1:2:end,1:2:end)=h(1:2:end,1:2:end,1)
x =
20 2 18 4 16
6 7 8 9 10
10 12 8 14 6
16 17 18 19 20
>> x(1:2:end,2:2:end)=h(1:2:end,2:2:end,2)
error: h(_,_,2): but h has size 4×5
What does this error mean?
Why did it happen?
Best Answer