Looks like the reason for the "fragments" is CFA (color filter array).
Pixels arrangement is like Bayer Mosaic as follows:

It isn't clear what is the CFA alignment.
You posted:
According to the manufacturer, the NIR data is stored in the blue channel and the visible light (red edge) in the red channel
But there are 4 possible combinations of Bayer alignment.
In Matlab demosaic function documentation combinations are referred as 'gbrg'
, 'grbg'
, 'bggr'
and 'rggb'
.
I don't know what is the most common alignment.
I can't say which channel supposed to be the "blue channel", and which is the "red channel". (all we know is they positioned diagonally).
I also couldn't find the alignment information in Google.
Since I couldn't tell which is which, I have extracted all 4 possible channels:
srcN = 4608; %Raw image width (number of columns).
srcM = 3456; %Raw image height (number of rows).
%Open raw image for reading.
f = fopen('2017_0321_134045_015.RAW', 'r');
%Read raw data into matrix I (use '*uint16' for keeping data in uint16 - no conversion to double).
I = fread(f, [srcN, srcM], '*uint16');
fclose(f);
%Transpose I, because RAW image format is row-major, and Matlab matrix format is column-major.
I = I';
%Assume Bayer mosaic sensor alignment.
%Seperate to mosaic components.
J1 = I(1:2:end, 1:2:end);
J2 = I(1:2:end, 2:2:end);
J3 = I(2:2:end, 1:2:end);
J4 = I(2:2:end, 2:2:end);
figure;imshow(J1);title('J1');
figure;imshow(J2);title('J2');
figure;imshow(J3);title('J3');
figure;imshow(J4);title('J4');
%Save all 4 images as tif
imwrite(J1, 'J1.tif');
imwrite(J2, 'J2.tif');
imwrite(J3, 'J3.tif');
imwrite(J4, 'J4.tif');
Here are the four images (shrank by a factor of x4):
J1:

J2:

J3:

J4:

Update:
Emotional_Cabbage posted the following reference image:

I tried to get the raw image to the reference, but I can't get it right.
I think the CFA alignment is:
J1
- Red color channel.
J2
and J3
- Monochromatic instead of green color channel.
J4
- NIR color channel.
Illustration:

I used the following processing code:
J = demosaic(I, 'rggb');
J = imadjust(J, [0.02, 0.98], [], 0.45); %Adjust image intensity, and use gamma value of 0.45
J(:,:,2) = J(:,:,2)*0.75; %Reduce the green by factor of 0.75
figure;imshow(J);
Result:

There is still some missing information for getting the right result...