1
$\begingroup$

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.

enter image description here

Or this one:

enter image description here

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

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – ali Nov 13 '17 at 10:18
  • $\begingroup$ Just to note that my question referred to how the black and white stripped image is created given the sine or whatever signal. $\endgroup$ – ali Nov 13 '17 at 10:28
  • $\begingroup$ 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". $\endgroup$ – Dan Hulme Nov 13 '17 at 10:40
  • $\begingroup$ 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. $\endgroup$ – ali Nov 13 '17 at 12:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.