Python Creating noise images with Python and OpenGL

Click For Summary
The discussion focuses on creating an nxn noise image for line integral convolution using OpenGL. The initial code snippet demonstrates generating a 2D array of random values, which can be scaled to a desired range. However, the user seeks guidance on how to convert this array into an image format suitable for OpenGL, expressing uncertainty about achieving this through forum posts alone. They reference several Stack Overflow links that illustrate converting images to and from arrays using the Pillow library but emphasize the need for OpenGL-specific methods. The conversation highlights the challenge of integrating noise generation with OpenGL image rendering and the desire for comprehensive tutorials or books on the topic.
Avatrin
Messages
242
Reaction score
6
Hi

I am learning how to do a line integral convolution with OpenGL given a vector field. So, as a first step, I need to learn how to create an nxn noise image. Are there any good tutorials/books I can use to learn how to do this?
 
Technology news on Phys.org
Here's one way:

Python:
import random
n=3
nxn = [[random.random() for i in range(n)] for j in range(n)]

You can replace random.random() with an expression to magnify the random values as random.random() values vary from 0.0 to 1.0

so 5*randomrandom() will give you a spread of 0.0 to 5.0

and (5*randomrandom()+3) will give you a range of 3.0 to 8.0 as examples.
 
  • Skeptical
Likes Avatrin
Alright, but this doesn't output an image. That's why I am asking for a tutorial or a book; I am not sure a forum post is going to tell me how to create images with OpenGL.