// EXAMPLE color transform (gray-scale) // Create a gray-scale image by taking a linear combination of the RGB // values of the input image as a gray-level intensity. // // Port First_In: 2D Image to transform // Port Second_In: 4x4 matrix to provide colormap transform // // Port First_Out: Transformed 2D byte Image // // Extract input transform matrix mat := scalar_lattice_in(Second_In); // Take linear combination of input matrix channels // using tensor product. v := (double) [mat[0][0], mat[0][1], mat[0][2]]; gray := First_In +.* v; // Scales the range to 0..255 mx := max(max(gray)); mn := min(min(gray)); if (mx == mn) mn -= 1; gray = (gray - mn) * (255 / (mx - mn)); // Assign to known output name First_Out := (byte) inside([gray, gray, gray]);