Image.Image->apply_matrix is not always very useful...
I'm a little busy myself, otherwise I would provide a patch, my
suggestion is that someone adds a function that does this to
Image.Image:
Image.Image convol(Image.Image i,
array(array(array(array(float)))) foo)
{
Image.Image ret;
array(array(array(array(int)))) foo1=
( array(array(array(array(int)))) ) (foo[*][*][*][*]*100000);
for(int x=0;x<3;x++)
{
array(int) c1=({ 0,0,0 });
c1[x]=255;
array(array(array(int))) foo2=foo1[*][*][x];
for(int y=0;y<3;y++)
{
array(array(int)) foo3=foo2[*][*][y];
int sum=`+(0, @ foo3*({}));
array(int) c2=({ 0,0,0 });
c2[x]=255;
Image.Image tmp;
tmp=i->gray(@c1)->apply_matrix(foo3,0,0,0,
sum?100000.0/sum:1.0)*c2;
if(ret)
ret+=tmp;
else
ret=tmp;
}
}
return ret;
}
I've need a function like this twice now, so I think it would be
useful. Also, the implementation above is grossly inefficient..
If anybody knows a faster way to do the same thing with the currently
available Image operations, let me know.
Possible extentions to this function:
o Add the results to an image to avoid the clipping that would occur
if you did the addition afterwards.
o Add x-stride and y-stride to allow it to compute only every
x:th and y:th pixel to allow scaling in the same step.
(Is it even possible to scale an image without averaging right now?)