views:

133

answers:

1

Before I start here, I am using C#. I would like to do some transforms using the ColorMatrix class. The problem is that sometimes an overflow occurs for r, g, or b. Instead of clamping the value at 255, the matrix loops around and starts again at 0. This means that, for images which should appear all white, they begin to turn black again. I am using this to model intensity over different line rates for line scan cameras. Does anyone know of a way to get around this?

BTW, I do have other other methods in mind, and I could do the matrix transforms myself, but I am more interested in a solution to this specific problem (if there is one of course).

+2  A: 

I've bumped into that problem too, and it would be nice if someone know of a fix. I've resorted to ugly work-arounds like:

  float[][] matrixContrastFix =
  {
   new float[] {    1,     0,     0, 0, 0},
   new float[] {    0,     1,     0, 0, 0},
   new float[] {    0,     0,     1, 0, 0},
   new float[] {    0,     0,     0, 1, 0}, 
   new float[] {-.05f, -.05f, -.05f, 0, 1}
  };

(I multiply a lot of ColorMatrixes together and end up with these things in the end.)

But as I guess you mean by other methods, using .LockBits and do it yourself would probably work better.

Hope you get a better answer than mine!

danbystrom
Yeah, I decided to scan the memory myself. Thanks.
Ed Swangren