Thursday, February 19, 2015

Olsen Noise 2D Java Code Updated.


http://pastebin.com/AFSnaJnk //commented to hell and back.

I went about rewriting the code, I was always annoyed by how much memory the sucker would grab up when it didn't really need to do that. I fixed all those issues. Figured out a better way to do matrix convolutions (for basically all images, all convolutions). But should hopefully have that sped up. And able to work without tossing around giant memory blocks. It sits in it's own foot print, even when it does operations like blur with a convolution kernel.

To use the class I did:
     
        on = new OlsenNoise2D(); //really all the functions can be static.
        int rh = on.getRequiredDim(height);
        stride = on.getRequiredDim(width);
        pixels = new int[stride * rh];
        on.olsennoise(pixels, stride, x, y, width, height);
        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        bi.setRGB(0, 0, width, height, pixels, 0, stride);


Update: Use to have source here just use the pastebin.

No comments: