Visible/NIR Fusion
The H7 algorithm is running!!!
Bochi and I finally found out that the order in which we ran each modular parts of this algorithm had the largest effect on memory usage
For example, running the less memory intensive sections first, such as calculating the gradient of the visible light image versus calculating the fusion map for the NIR image allowed the H7 to get a lot further without hard-faulting (ran out of memory)
The second major memory optimization was the following: instead of allocating 3 separate arrays:
float channel_1[w*h], float channel_2[w*h], float channel_3[w*h]
we could store them all in one array as a flattened array
float myArray[3*w*h]
and pass only the channel we needed by using pointer arithmetic
(myArray + width * height * i)
where i = 0, 1, 2
Summary
Re-ordering the allocation of arrays and the execution of code along with pointer specific memory optimizations significantly reduced the memory usage and, also, reducing the number of calls to malloc (a very expensive function) allowed us to finally prove that this algorithm can be run on the H7 (albiet for a very downsampled image)
Comments