Example code (the biggest issue is that it assumes all pixels are visible  this has to be adjusted). Script (C#): // C# using M = Manifold; class Script { static Manifold.Context Manifold; static void Main() { } // assumes float64 pixels // assumes all pixels are visible // computes min of 8 slopes from center to neighbors // // slopemin for pixel static double SlopeMinValue(double beg, double end, double dx) { return (end  beg) / dx; } static double SlopeMinValueInc(double slope, double beg, double end, double dx) { return System.Math.Min(slope, (end  beg) / dx); } static double SlopeMinPixel(M.Tile.PixelSet<double> pixels, int x, int y) { double center = pixels[x, y]; double dx = 1; double dxdiag = 1.4142; // sqrt(2) double value; // use horizontal / vertical neighbors value = SlopeMinValue(center, pixels[x1, y], dx); value = SlopeMinValueInc(value, center, pixels[x+1, y], dx); value = SlopeMinValueInc(value, center, pixels[x, y1], dx); value = SlopeMinValueInc(value, center, pixels[x, y+1], dx); // use diagonal neighbors value = SlopeMinValueInc(value, center, pixels[x1, y1], dxdiag); value = SlopeMinValueInc(value, center, pixels[x1, y+1], dxdiag); value = SlopeMinValueInc(value, center, pixels[x+1, y1], dxdiag); value = SlopeMinValueInc(value, center, pixels[x+1, y+1], dxdiag); return value; } // slopemin for tile static public M.Tile SlopeMin(M.Tile t, int radius) { M.Application app = Manifold.Application; M.TileBuilder builder = app.CreateTileBuilder(); // start with blank tile of the same size as source builder.StartTile(t.Width, t.Height, t.Type); // set pixels M.Tile.PixelSet<double> pixelsOld = (M.Tile.PixelSet<double>)t.Pixels; M.TileBuilder.PixelSet<double> pixelsNew = (M.TileBuilder.PixelSet<double>)builder.Pixels; for (int y = radius; y < builder.Height  radius; ++y) { for (int x = radius; x < builder.Width  radius; ++x) pixelsNew[x, y] = SlopeMinPixel(pixelsOld, x, y); } // return composed tile return builder.EndTile(); } } Query: SQL9 FUNCTION SlopeMin(@t TILE, @r INT32) TILE AS SCRIPT [SlopeMin] ENTRY 'Script.SlopeMin'; VALUE @t TILE = StringJsonTile('[2,2,3,2,1,2,3,3,3]', 3, 3, 1, false); VALUES (TileJson(SlopeMin(@t, 1))); MXB attached. Hope this is useful as a starting point. Attachments: slopemin.mxb
