How can I reverse the colors of an image with the tool ColorMatrix?

946 views Asked by At

What values do I have to put in the Matrix?

Dim clMatriz As Imaging.ColorMatrix = New Imaging.ColorMatrix(New Single()() _
{New Single() {¿?, 0, 0, 0, 0}, _
 New Single() {0, ¿?, 0, 0, 0}, _
 New Single() {0, 0, ¿?, 0, 0}, _
 New Single() {0, 0, 0, ¿?, 0}, _
 New Single() {0, 0, 0, 0, ¿?})
1

There are 1 answers

0
Quasimondo On

Though I am not exactly sure how that particular version of your color matrix works and if your pixel values are in the range 0-255 or 0-1 here's how it should work:

In case your pixel range is 0-255:

Dim clMatriz As Imaging.ColorMatrix = New Imaging.ColorMatrix(New Single()() _ {New Single() {-1, 0, 0, 0, 255}, _ New Single() {0, -1, 0, 0, 255}, _ New Single() {0, 0, -1, 0, 255}, _ New Single() {0, 0, 0, 1, 0}, _ New Single() {0, 0, 0, 0, 1})

In case it is 0-1:

Dim clMatriz As Imaging.ColorMatrix = New Imaging.ColorMatrix(New Single()() _ {New Single() {-1, 0, 0, 0, 1}, _ New Single() {0, -1, 0, 0, 1}, _ New Single() {0, 0, -1, 0, 1}, _ New Single() {0, 0, 0, 1, 0}, _ New Single() {0, 0, 0, 0, 1})