multi channel support

Refactored data structure to process n-dimensional images. Each channel is processed separately. Added regression tests.