so I have been trying to alter an image's contrast with matrices and this is what I have come up with:
final defaultColorMatrix = const <double>[
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
];
List<double> calculateContrastMatrix(double contrast) {
final m = List<double>.from(defaultColorMatrix);
m[0] = contrast;
m[6] = contrast;
m[12] = contrast;
m[5] = (1 - contrast) / 2;
m[10] = (1 - contrast) / 2;
m[15] = (1 - contrast) / 2;
return m;
being contrast and adjustable value between 0 and 1
it is giving me sub optimal results
I just realized that the last column is not
m[5]
,m[10]
,m[15]
butm[4]
,m[9]
,m[14]
. I forgot that dart's array index starts at 0.I also forgot that the last column in flutter matrices is not normalized to it expects values between 0-255 so the correct solution is: