I am trying to write the server element which will render a image constructed in Flash. I'm using ColorMatrixFilter in AS3 but it takes a 4x5 matrix, whereas the PHP version takes 5x5. I don't understand what the 5th row is? I think the last column is brightness. I don't understand how ColorMatrixFilter works on AS3 either but this is what I have
[flash=] _SafeStr_10115 = new Map();
_SafeStr_19559("dark_sepia", _SafeStr_19546, [0.4, 0.4, 0.1, 0, 110, 0.3, 0.4, 0.1, 0, 30, 0.3, 0.2, 0.1, 0, 0, 0, 0, 0, 1, 0], null);
_SafeStr_19559("increase_saturation", _SafeStr_19546, [2, -0.5, -0.5, 0, 0, -0.5, 2, -0.5, 0, 0, -0.5, -0.5, 2, 0, 0, 0, 0, 0, 1, 0], null);
_SafeStr_19559("increase_contrast", _SafeStr_19546, [1.5, 0, 0, 0, -50, 0, 1.5, 0, 0, -50, 0, 0, 1.5, 0, -50, 0, 0, 0, 1.5, 0], null);
_SafeStr_19559("shadow_multiply_02", _SafeStr_19547, null, BlendMode.MULTIPLY);
_SafeStr_19559("color_1", _SafeStr_19546, [0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131, 0, 0, 0, 0, 0, 1, 0], null, 1);
_SafeStr_19559("hue_bright_sat", _SafeStr_19546, [1, 0.6, 0.2, 0, -50, 0.2, 1, 0.6, 0, -50, 0.6, 0.2, 1, 0, -50, 0, 0, 0, 1, 0], null, 1);
_SafeStr_19559("hearts_hardlight_02", _SafeStr_19547, null, BlendMode.HARDLIGHT, 1);
_SafeStr_19559("texture_overlay", _SafeStr_19547, null, BlendMode.OVERLAY, 1);
_SafeStr_19559("pinky_nrm", _SafeStr_19547, null, BlendMode.NORMAL, 1);
_SafeStr_19559("color_2", _SafeStr_19546, [0.333, 0.333, 0.333, 0, 0, 0.333, 0.333, 0.333, 0, 0, 0.333, 0.333, 0.333, 0, 0, 0, 0, 0, 1, 0], null, 2);
_SafeStr_19559("night_vision", _SafeStr_19546, [0, 0, 0, 0, 0, 0, 1.1, 0, 0, -50, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], null, 2);
_SafeStr_19559("stars_hardlight_02", _SafeStr_19547, null, BlendMode.HARDLIGHT, 2);
_SafeStr_19559("coffee_mpl", _SafeStr_19547, null, BlendMode.MULTIPLY, 2);
[/flash]
The third argument is the colour matrix.
PHP colormatriximage
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP colormatriximage
see
http://www.imagemagick.org/script/comma ... lor-matrix
http://designstacks.net/color-matrix
Other two elements besides the main RGB are alpha and constant offsets
http://www.imagemagick.org/script/comma ... lor-matrix
http://designstacks.net/color-matrix
Other two elements besides the main RGB are alpha and constant offsets
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PHP colormatriximage
In IM "-color-matrix", the matrix rows represent output, and columns represent input. For RGB images, the 5 rows and columns are: red, green, blue, alpha, and offset. For example, if the first row has values "a,b,c,d,e" then the output red channel will be:
R' = a*R + b*G + c*B + d*A + e
where R,G,B and A are the input values.
The final row of the 5x5 matrix is meaningless.
R' = a*R + b*G + c*B + d*A + e
where R,G,B and A are the input values.
The final row of the 5x5 matrix is meaningless.
snibgo's IM pages: im.snibgo.com
Re: PHP colormatriximage
Would you mind showing me an example? For a function with the following paramssnibgo wrote:In IM "-color-matrix", the matrix rows represent output, and columns represent input. For RGB images, the 5 rows and columns are: red, green, blue, alpha, and offset. For example, if the first row has values "a,b,c,d,e" then the output red channel will be:
R' = a*R + b*G + c*B + d*A + e
where R,G,B and A are the input values.
The final row of the 5x5 matrix is meaningless.
function($image, $flash_array, $alpha = 255)
I can't seem to get it working x(!
alpha = alpha of the colour matrix
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP colormatriximage
Play with the online interactive color-matrix at http://designstacks.net/color-matrix. That should allow you to figure it out.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PHP colormatriximage
I haven't use ActionScript for years. Looking at the link Fred gave, the differences to IM seem to be:
In AS, the offset is typically in the range 0 to 255. In IM, this corresponds to 0.0 to 1.0.
In IM "-color-matrix", I generally use 6x6 matrices. For RGB images, the six columns and rows are: red, green, blue, alpha, unused, offset.
In AS, the offset is typically in the range 0 to 255. In IM, this corresponds to 0.0 to 1.0.
In IM "-color-matrix", I generally use 6x6 matrices. For RGB images, the six columns and rows are: red, green, blue, alpha, unused, offset.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP colormatriximage
I think snibgo is correct, in IM the offsets are in the range 0 to 1.
The IM matrix uses 6x6 to permit c,m,y,k,alpha,offset for a CMYKA image
For RGBA image if you need the offset, then you can use 5x5. If no offset, then 4x4 and if no alpha, then 3x3 are permitted.
The IM matrix uses 6x6 to permit c,m,y,k,alpha,offset for a CMYKA image
For RGBA image if you need the offset, then you can use 5x5. If no offset, then 4x4 and if no alpha, then 3x3 are permitted.