# How to plot an input signal in image?

Given an input signal(ex. sine) how can one go about plotting an image like below ones(the stripped black and white image)?

The images are from these slides on image processing.

Or this one:

• You need to explain where you're stuck. Your first example even includes all the Matlab code needed to make the image! – Dan Hulme Nov 13 '17 at 14:15
• Thanks. I was not clear as to how get pixel colour based on the function. It works now – ali Nov 13 '17 at 15:11

If you're using Python, you can use a library such as matplotlib for this. It can take a numpy array and plot it as a standard chart using the function plot or as an image using imshow. The resulting image/plot can be displayed in an interactive window, or saved to a file, or it shows inline in your Jupyter notebook if you're using that.