Generating 2D Perlin Noise

I am trying to generate a random texture - something like perlin noise. Currently, I get:

I am trying to generate something like this:

I think I could get something near it by combining the first and last texture (In the first pic), but Im not sure. Help?

Ok, I have figured out a way to generate perlin noise.

I am now wondering - how do I apply this image to an array of cubes, as a sort of heightmap? In theory, I think you need to iterate over every pixel in the generated image, and convert it to a number, and then apply that number to the cubes height?

I just have no idea on how to do that, coding-wise. Help?

Hey sorry for the super hard necromancing, but how exactly did you go about making that (p.s. I can help w/ the cube part)

Found this great tutorial some times ago: http://www.float4x4.net/index.php/2010/06/generating-realistic-and-playable-terrain-height-maps/ Helped me a lot!