The color matrix needs a 5x5 matrix for RGBKA channels. 6x6 adds a constant column, with the last row being usless, ans it assigned to 'constant' and thus is not needed.
You can ensure the matrix is the size you want by prefacing the numbers with a "WxH:"
The matrix is simply overlayed on a identity 6x6 matrix, before being matrix multiplied to each source pixel.
This is explained in IM Examples, Color Modifications, Color Matrix
http://www.imagemagick.org/Usage/color_ ... lor-matrix
In the first 5x5 case you multiply the black channel by a value of 1.0 but this image has no balck channel, so make no contribution. Result unchanged image.
In the second 6x6 case, the values to calculate a red result is: 1 0 0 0 0 1
That equates to red from source (multiplyed by 1) plus 1.0 as a constant (6th column).
The result is Red+1.0 which does not fit in a 0 to 1 (normalized color) range.
As such it is clipped to 1.0, and results in just red = 1.0 in the destination image. A very red image.
The -color-matrix is working as it is currently defined to work.
In many ways color-matrix has never quite been what people want, as everyone has different needs and expectations. The black column/row for example is very rarely needed or used.
I myself would prefer to be able to define what channels, and the order of the channels whcih are in the matrix. Especially in IMv7 where we can have many extra channels, not all of which will be involved in the calculations.