0
$\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$
2
  • $\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
    Commented Nov 13, 2017 at 14:15
  • $\begingroup$ Thanks. I was not clear as to how get pixel colour based on the function. It works now $\endgroup$
    – ali
    Commented Nov 13, 2017 at 15:11

1 Answer 1

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$
4
  • $\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
    Commented Nov 13, 2017 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
    Commented Nov 13, 2017 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
    Commented Nov 13, 2017 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
    Commented Nov 13, 2017 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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