Hello everybody,
I've googled a lot and searched on this forum but i was not able to find an answer to my question.
I work for a company developing an Android / iOS photography application, that needs to apply filters and effects to images selected by the user.
We used the Gpuimage framework, based on Opengl, and the method to apply effects using lookup textures for RGB color space, like described in this article: http://liovch.blogspot.it/2012/07/add-i ... r-ios.html
We need to apply these effects on small thumbnails on client side to let show the result, then the user should send original high resolution version of the pictures to our server, in order to buy prints of them.
So our need is to apply the effects on high resolution on server side, to avoid performance issues on mobile devices.
We run our php server with ImageMagick already set up (we already make use of it for image processing).
I've tried to apply the same Gpuimage lookup textures with ImageMagick using the "clutImage" method (-clut option with command line), but the result is absolutely different, because clearly image magick color lookup table are different from gpuimage lookup textures.
Is there any method to convert gpuimage lookup textures to clut that ImageMagick undesrtands?
Convert Gpuimage Lookup table to Image magick lut
-
- Posts: 2
- Joined: 2017-01-13T04:36:48-07:00
- Authentication code: 1151
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert Gpuimage Lookup table to Image magick lut
Looking at your link, the IM construct you need isn't "clut" but "hald-clut", which represents a cube of colours eg 64x64x64 colours. The x,y,z coordinates represent the input colour for the lookup, and the colour in that cell is the output colour.
The 3-D cube has the cells rearranged into a 2-D square, eg 512, because sqrt(64^3) = 512.
h.png is the identity 512x512 hald clut. It looks different to the ones on your link. I suppose a different transformation is made to convert 3 dimensions to 2.
The 3-D cube has the cells rearranged into a 2-D square, eg 512, because sqrt(64^3) = 512.
Code: Select all
convert hald:8 h.png
snibgo's IM pages: im.snibgo.com
-
- Posts: 2
- Joined: 2017-01-13T04:36:48-07:00
- Authentication code: 1151
Re: Convert Gpuimage Lookup table to Image magick lut
I suppose it must be a different algorithm.
Looking at code in the Android porting, i can see some lines of transformation instructions:
Documentation is quite poor and simply states that you're applying a rgb color lookup table as a texture, but is not clear which kind of lut.
At this point I think we'll have to create a command line tool, instead of using Image magick
Looking at code in the Android porting, i can see some lines of transformation instructions:
Code: Select all
public static final String LOOKUP_FRAGMENT_SHADER = "varying highp vec2 textureCoordinate;\n" +
" varying highp vec2 textureCoordinate2; // TODO: This is not used\n" +
" \n" +
" uniform sampler2D inputImageTexture;\n" +
" uniform sampler2D inputImageTexture2; // lookup texture\n" +
" \n" +
" uniform lowp float intensity;\n" +
" \n" +
" void main()\n" +
" {\n" +
" highp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);\n" +
" \n" +
" highp float blueColor = textureColor.b * 63.0;\n" +
" \n" +
" highp vec2 quad1;\n" +
" quad1.y = floor(floor(blueColor) / 8.0);\n" +
" quad1.x = floor(blueColor) - (quad1.y * 8.0);\n" +
" \n" +
" highp vec2 quad2;\n" +
" quad2.y = floor(ceil(blueColor) / 8.0);\n" +
" quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n" +
" \n" +
" highp vec2 texPos1;\n" +
" texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);\n" +
" texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);\n" +
" \n" +
" highp vec2 texPos2;\n" +
" texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);\n" +
" texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);\n" +
" \n" +
" lowp vec4 newColor1 = texture2D(inputImageTexture2, texPos1);\n" +
" lowp vec4 newColor2 = texture2D(inputImageTexture2, texPos2);\n" +
" \n" +
" lowp vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n" +
" gl_FragColor = mix(textureColor, vec4(newColor.rgb, textureColor.w), intensity);\n" +
" }";
At this point I think we'll have to create a command line tool, instead of using Image magick