Code: Select all
convert -size 50x500 xc: -channel RGBA -sparse-color Shepards '0,0 rgb(0,255,0,1) 0,250 rgb(255,255,255,0) 0,500 rgb(255,0,0,1)' test.png
Code: Select all
convert -size 50x500 xc: -channel RGBA -sparse-color Shepards '0,0 rgb(0,255,0,1) 0,250 rgb(255,255,255,0) 0,500 rgb(255,0,0,1)' test.png
Code: Select all
-fx "v.p{0,u*v.h}"
try adding -alpha set or -matte after -channel RGBAhaarts wrote:I want to create a gradient with more than two colors and one of the colors should be transparent. Searching the forum I found that -sparse-color in combination with the Shepard method could do the trick. So I tried:The resulting test.png doesn't include the alpha channel. I don't quite understand why. The docs state that one should define -channel and the colors are correct as well as far as I can tell.Code: Select all
convert -size 50x500 xc: -channel RGBA -sparse-color Shepards '0,0 rgb(0,255,0,1) 0,250 rgb(255,255,255,0) 0,500 rgb(255,0,0,1)' test.png
haarts wrote:On a related note, I'm trying to understand the -fx operator. I have:This means that of the second image (v) the pixelvalue (p{}) is used for the resulting image. But I'm unclear on what pixelvalue is used. The first column obviously, but what row? u is the first image, v the second and h the height? If the first image is greyscale and the second a gradient image as described in my previous post what is the result? I assumed this was a color replacement. A mapping of greyscale to color space. But in that light the multiplier does not make sense to me.Code: Select all
-fx "v.p{0,u*v.h}"
Now I see! Thanks for clearing this up for me. And I replaced the -fx expression with the -clut expression. Many thanks for the tip.anthony wrote:
v.p{x,y} will look up the pixel at the point x,y in the second image 'v'
The x,y coordinate may be a floating point position so interpolation may be used to mixx colors of near by pixels.
So 0 means just the first 'zeroth' column of pixels will be used,
u*v.h mean the y coodinate is the color of the current pixel in the first image (in 0 to 1 range) multiplied by the height of thesecond image.
So this FX expression replaces the original with a lookup of its color in the second image.
that is replace pixel colors using a Color Lookup Table (the -clut operator is essentuallty does same thing (with minor improvements)
See IM Examples, Color LUT
http://www.imagemagick.org/Usage/color/#clut
Adding -alpha resulted in an error and -matte didn't do anything as far as I can see. I resolved the issue by -append and using different gradients. Thanks for the help though!fmw42 wrote: try adding -alpha set or -matte after -channel RGBA
Code: Select all
convert -size 50x500 xc: -alpha set -channel RGBA \
-sparse-color Shepards '0,0 rgba(0,255,0,1)
0,250 rgba(255,255,255,0)
0,500 rgba(255,0,0,1)' test.png
Code: Select all
convert logo: -alpha set -channel A -sparse-color Barycentric \
'0,0 opaque 0,%h transparent' \
show: