<p>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 <code>plot</code> or as an image using <code>imshow</code>. 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.</p>

<p>There are other (better?) Python chart plotting libraries but the functionality is basic and IMO matplotlib is easier to get started with (perhaps just because it's older and more established).</p>

<p>You can also do this using OpenCV, if your input is an OpenCV image. Its plotting functions are named similarly to the matplotlib ones. OpenCV is available in Python, C++, and a handful of other languages.</p>

CC BY-SA 3.0
2017-11-13T10:18:02.697Z
Thank you for the answer. but what is the algorithm if I one wants to implement it and not using 3rd parties? I use c# language.
ali
CC BY-SA 3.0
2017-11-13T10:28:14.170Z
Just to note that my question referred to how the black and white stripped image is created given the sine or whatever signal.
ali
CC BY-SA 3.0
2017-11-13T10:40:48.127Z
In that case, could you edit your question and make it clearer? Regardless of language, the short answer is "make an array of values from your function and then convert it into the image type you're using".
Dan Hulme
CC BY-SA 3.0
2017-11-13T12:04:35.277Z
Sorry about the question not being clear enough. I have updated it. I still don't understand how to do it could you give an example please.
ali
CC BY-SA 3.0
2017-11-13T09:49:43.823Z
2017-11-13T09:49:43.823Z
Dan Hulme
<p>Given an input signal(ex. sine) how can one go about plotting an image like below ones(the stripped black and white image)? </p>

<p>The images are from <a href="http://www.robots.ox.ac.uk/~az/lectures/ia/lect2.pdf" rel="nofollow noreferrer">these slides</a> on image processing.</p>

<p><a href="https://i.sstatic.net/4ZhOo.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4ZhOo.png" alt="enter image description here"></a></p>

<p>Or this one:</p>

<p><a href="https://i.sstatic.net/LjYJ8.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/LjYJ8.png" alt="enter image description here"></a></p>

CC BY-SA 3.0
2017-11-13T14:15:18.120Z
You need to explain where you're stuck. Your first example even includes all the Matlab code needed to make the image!
Dan Hulme
CC BY-SA 3.0
2017-11-13T15:11:27.000Z
Thanks. I was not clear as to how get pixel colour based on the function. It works now
ali
<image-processing><antialiasing>
How to plot an input signal in image?
ali
# How to plot an input signal in image?

(Asked by: username_0 on 2017-11-13)

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](http://www.robots.ox.ac.uk/~az/lectures/ia/lect2.pdf) on image processing.

[![enter image description here](https://i.sstatic.net/4ZhOo.png)](https://i.sstatic.net/4ZhOo.png)

Or this one:

[![enter image description here](https://i.sstatic.net/LjYJ8.png)](https://i.sstatic.net/LjYJ8.png)

**Tags:** image-processing, antialiasing

> **Comments:**
> **username_1**: You need to explain where you're stuck. Your first example even includes all the Matlab code needed to make the image!  
> **username_0**: Thanks. I was not clear as to how get pixel colour based on the function. It works now  

---

## 1 answers

### Answer by username_1 on 2017-11-13. Score: 1 | Accepted answer

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.

There are other (better?) Python chart plotting libraries but the functionality is basic and IMO matplotlib is easier to get started with (perhaps just because it's older and more established).

You can also do this using OpenCV, if your input is an OpenCV image. Its plotting functions are named similarly to the matplotlib ones. OpenCV is available in Python, C++, and a handful of other languages.

> **Comments:**
> **username_0**: Thank you for the answer. but what is the algorithm if I one wants to implement it and not using 3rd parties? I use c# language.  
> **username_0**: Just to note that my question referred to how the black and white stripped image is created given the sine or whatever signal.  
> **username_1**: In that case, could you edit your question and make it clearer? Regardless of language, the short answer is "make an array of values from your function and then convert it into the image type you're using".  
> **username_0**: Sorry about the question not being clear enough. I have updated it. I still don't understand how to do it could you give an example please.  

---

