Sobel method to generate bump map from a height map

@param input - A height map
@return bump map
176
@Override
    public ImageSource apply(ImageSource input) {
        int w = input.getWidth();
        int h = input.getHeight();

        MatrixSource output = new MatrixSource(input);

        Vector3 n = new Vector3(0, 0, 1);

        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {

                if (x < border || x == w - border || y < border || y == h - border) {
                    output.setRGB(x, y, VectorHelper.Z_NORMAL);
                    continue;
                }

                float s0 = input.getR(x - 1, y + 1);
                float s1 = input.getR(x, y + 1);
                float s2 = input.getR(x + 1, y + 1);
                float s3 = input.getR(x - 1, y);
                float s5 = input.getR(x + 1, y);
                float s6 = input.getR(x - 1, y - 1);
                float s7 = input.getR(x, y - 1);
                float s8 = input.getR(x + 1, y - 1);

                float nx = -(s2 - s0 + 2 * (s5 - s3) + s8 - s6);
                float ny = -(s6 - s0 + 2 * (s7 - s1) + s8 - s2);

                n.set(nx, ny, scale);
                n.nor();

                int rgb = VectorHelper.vectorToColor(n);
                output.setRGB(x, y, rgb);
            }
        }

        return new MatrixSource(output);
    }
365419
@Override
    public Object map(Object input) {
        List<Long> list = (List<Long>) input;
        switch (mathOp) {
            case Add:
                long sum = 0;
                for (Long w : list)
                    sum += w;
                return new LongWritable(sum);
            case Subtract:
                return list.get(0) - list.get(1);
            case Multiply:
                long product = 1;
                for (Long w : list)
                    product *= w;
                return product;
            case Divide:
                return list.get(0) / list.get(1);
            case Modulus:
                return list.get(0) % list.get(1);
            case ReverseSubtract:
            case ReverseDivide:
            case ScalarMin:
            case ScalarMax:
            default:
                throw new RuntimeException("Invalid mathOp: " + mathOp); //Should never happen
        }
    }
53075
@Override
    public Object map(Object input) {
        Number n = (Number) input;
        double val = n.doubleValue();
        return new DoubleWritable((val - mean) / stdev);
    }
1057021
@Nullable
  public static Fingerprint parse(String input) {
    if (input == null) {
      return null;
    }
    if (Constants.INVALID_UFS_FINGERPRINT.equals(input)) {
      return new Fingerprint(Collections.emptyMap());
    }
    Map<String, String> kv = Splitter.on(TAGDELIMTER).trimResults().omitEmptyStrings()
            .withKeyValueSeparator(KVDELIMTER).split(input);
    Map<Tag, String> tagMap = new HashMap<>();

    for (Map.Entry<String, String> entry : kv.entrySet()) {
      tagMap.put(Tag.valueOf(entry.getKey()), entry.getValue());
    }

    // Verify required tags
    for (Tag tag : REQUIRED_TAGS) {
      if (!tagMap.containsKey(tag)) {
        return null;
      }
    }

    return new Fingerprint(tagMap);
  }
972660
public void process(GrayF32 input ) {
		constructPyramid(input);

		corners.reset();

		// top to bottom. This way the intensity image is at the input image's scale. Which is useful
		// for visualiztion purposes
		double scale = Math.pow(2.0,pyramid.size()-1);
		for (int level = pyramid.size()-1; level >= 0; level--) {
			// find the corners
			detector.process(pyramid.get(level));

			// Add found corners to this level's list
			PyramidLevel featsLevel = featureLevels.get(level);

			FastQueue<ChessboardCorner> corners = detector.getCorners();
			featsLevel.corners.reset();
			for (int i = 0; i < corners.size; i++) {
				ChessboardCorner cf = corners.get(i);

				// convert the coordinate into input image coordinates
				double x = cf.x*scale;
				double y = cf.y*scale;
				// Compensate for how the pyramid was computed using an average down sample. It shifts
				// the coordinate system.
//				if( scale > 1 ) {
//					x += 0.5*scale;
//					y += 0.5*scale;
//				}

				ChessboardCorner cl = featsLevel.corners.grow();
				cl.first = true;
				cl.set(x,y,cf.orientation,cf.intensity);
			}
			scale /= 2.0;
		}

		// Create a combined set of features from all the levels. Only add each feature once by searching
		// for it in the next level down
		for (int levelIdx = 0; levelIdx < pyramid.size(); levelIdx++) {
			PyramidLevel level0 = featureLevels.get(levelIdx);

			// mark features in the next level as seen if they match ones in this level
			if( levelIdx+1< pyramid.size() ) {
				PyramidLevel level1 = featureLevels.get(levelIdx+1);
				markSeenAsFalse(level0.corners,level1.corners);
			}
		}

		for (int levelIdx = 0; levelIdx < pyramid.size(); levelIdx++) {
			PyramidLevel level = featureLevels.get(levelIdx);
			// only add corners if they were first seen in this level
			for (int i = 0; i < level.corners.size; i++) {
				ChessboardCorner c = level.corners.get(i);
				if( c.first )
					corners.grow().set(c);
			}
		}
	}
618833
public Object transform( int from, int to, Object input ) {
        return transform( from, to, input, null );
    }
910498
public static String unAccent(String input) {
        if (MAP_NORM == null || MAP_NORM.size() == 0) {
            MAP_NORM = new HashMap<Character, Character>();
            MAP_NORM.put('À', 'A');
            MAP_NORM.put('Á', 'A');
            MAP_NORM.put('Â', 'A');
            MAP_NORM.put('Ã', 'A');
            MAP_NORM.put('Ä', 'A');
            MAP_NORM.put('È', 'E');
            MAP_NORM.put('É', 'E');
            MAP_NORM.put('Ê', 'E');
            MAP_NORM.put('Ë', 'E');
            MAP_NORM.put('Í', 'I');
            MAP_NORM.put('Ì', 'I');
            MAP_NORM.put('Î', 'I');
            MAP_NORM.put('Ï', 'I');
            MAP_NORM.put('Ù', 'U');
            MAP_NORM.put('Ú', 'U');
            MAP_NORM.put('Û', 'U');
            MAP_NORM.put('Ü', 'U');
            MAP_NORM.put('Ò', 'O');
            MAP_NORM.put('Ó', 'O');
            MAP_NORM.put('Ô', 'O');
            MAP_NORM.put('Õ', 'O');
            MAP_NORM.put('Ö', 'O');
            MAP_NORM.put('Ñ', 'N');
            MAP_NORM.put('Ç', 'C');
            MAP_NORM.put('ª', 'A');
            MAP_NORM.put('º', 'O');
            MAP_NORM.put('§', 'S');
            MAP_NORM.put('³', '3');
            MAP_NORM.put('²', '2');
            MAP_NORM.put('¹', '1');
            MAP_NORM.put('à', 'a');
            MAP_NORM.put('á', 'a');
            MAP_NORM.put('â', 'a');
            MAP_NORM.put('ã', 'a');
            MAP_NORM.put('ä', 'a');
            MAP_NORM.put('è', 'e');
            MAP_NORM.put('é', 'e');
            MAP_NORM.put('ê', 'e');
            MAP_NORM.put('ë', 'e');
            MAP_NORM.put('í', 'i');
            MAP_NORM.put('ì', 'i');
            MAP_NORM.put('î', 'i');
            MAP_NORM.put('ï', 'i');
            MAP_NORM.put('ù', 'u');
            MAP_NORM.put('ú', 'u');
            MAP_NORM.put('û', 'u');
            MAP_NORM.put('ü', 'u');
            MAP_NORM.put('ò', 'o');
            MAP_NORM.put('ó', 'o');
            MAP_NORM.put('ô', 'o');
            MAP_NORM.put('õ', 'o');
            MAP_NORM.put('ö', 'o');
            MAP_NORM.put('ñ', 'n');
            MAP_NORM.put('ç', 'c');
        }

        if (input == null) {
            return "";
        }

        StringBuilder sb = new StringBuilder(input);

        for (int i = 0; i < input.length(); i++) {
            Character c = MAP_NORM.get(sb.charAt(i));
            if (c != null) {
                sb.setCharAt(i, c.charValue());
            }
        }

        return sb.toString();

    }
382860
private BufferedImage scaleBuffered( BufferedImage input ) {
		int m = Math.max(input.getWidth(),input.getHeight());
		if( m <= controls.maxImageSize )
			return input;
		else {
			double scale = controls.maxImageSize/(double)m;
			int w = (int)(scale*input.getWidth()+0.5);
			int h = (int)(scale*input.getHeight()+0.5);

			// Use BoofCV to down sample since Graphics2D introduced too many aliasing artifacts
			BufferedImage output = new BufferedImage(w,h,input.getType());
			Planar<GrayU8> a = new Planar<>(GrayU8.class,input.getWidth(),input.getHeight(),3);
			Planar<GrayU8> b = new Planar<>(GrayU8.class,w,h,3);
			ConvertBufferedImage.convertFrom(input,a,true);
			AverageDownSampleOps.down(a,b);
			ConvertBufferedImage.convertTo(b,output,true);
			return output;
		}
	}
1181254
@Override
    public Object map(Object input) {
        Number n = (Number) input;
        return n.doubleValue() - mean;
    }
927598
public static Props fromHierarchicalMap(final Map<String, Object> propsMap) {
    if (propsMap == null) {
      return null;
    }

    final String source = (String) propsMap.get("source");
    final Map<String, String> propsParams =
        (Map<String, String>) propsMap.get("props");

    final Map<String, Object> parent = (Map<String, Object>) propsMap.get("parent");
    final Props parentProps = fromHierarchicalMap(parent);

    final Props props = new Props(parentProps, propsParams);
    props.setSource(source);
    return props;
  }
801124
public static ConfigNode load(Map<String, String> input) {
        ConfigNode config = new ConfigNode();

        load(config, input);

        return config;
    }
181154
@Override
    public ImageHeader readHeader(InputStream input) throws IOException
    {
        final int toSkip = 15 + 3;
        long skipped = input.skip(toSkip);
        checkSkippedError(skipped, toSkip);

        final int width = readInt(input, 2, false);
        skipped = input.skip(2);
        checkSkippedError(skipped, 2);

        final int height = readInt(input, 2, false);

        return new ImageHeaderModel(width, height, ImageFormat.BMP);
    }
747909
@Override
    public Object transform( Object input ) {

        Map<String,Object> output = new HashMap<>();

        // Create a root LiteralPathElement so that # is useful at the root level
        MatchedElement rootLpe = new MatchedElement( ROOT_KEY );
        WalkedPath walkedPath = new WalkedPath();
        walkedPath.add( input, rootLpe );

        rootSpec.apply( ROOT_KEY, Optional.of( input ), walkedPath, output, null );

        return output.get( ROOT_KEY );
    }
828689
@Override
    public Object map(Object input) {
        Number n = (Number) input;
        return doOp(n.intValue());
    }
404520
@Override
    public Object transform( Object input ) {

        if ( input == null ) {
            // if null, assume HashMap
            input = new HashMap();
        }

        // TODO : Make copy of the defaultee or like shiftr create a new output object
        if ( input instanceof List ) {
            if  ( arrayRoot == null ) {
                throw new TransformException( "The Spec provided can not handle input that is a top level Json Array." );
            }
            arrayRoot.applyChildren( input );
        }
        else {
            mapRoot.applyChildren( input );
        }

        return input;
    }
350532
public static float[] asFloatTypeArray(List<Float> input) {
		float[] result = new float[input.size()];

		for (int i = 0; i < result.length; i++) {
			result[i] = input.get(i);
		}

		return result;
	}
481814
public int bump(CmsUUID id) {

        CmsDetailPageInfo info = m_infoById.get(id);
        if (info == null) {
            throw new IllegalArgumentException();
        }
        String type = info.getType();
        List<CmsDetailPageInfo> infos = m_map.get(type);
        int oldPos = infos.indexOf(info);
        infos.remove(oldPos);
        infos.add(0, info);
        return oldPos;
    }