Drawing a Wave represented by (Orientation, Frequency, Phase-shift, Amplitude) Using OpenCv

╄→尐↘猪︶ㄣ 提交于 2019-12-25 19:04:08

问题


I want to create an empty image and take parameters from user, which are Wave Orientation, Wave Frequency, Phase-shift, Wave Amplitude.

And I have to give an output similar to the following image:

My questions:

  • How can I draw waves inside my empty image?
  • What functions should I use?

回答1:


I guess you can do the following steps (but I am not sure, since I didn't test it):

  1. Use sine function with needed Wave Frequency, Phase-shift and Wave Amplitude to calculate values of pixels in one row. Possibly it will look like this with using sine and normalization:

    for( int j = 0; j < I.cols; ++j ) I.at<uchar>(i,j) = (Amplitude * sin(frequency*j + PhaseShift) + 1) / 2 * 255;

  2. Copy first row to other rows for receiving something like vertical lines.

  3. Use cv::getRotationMatrix2D and cv::warpAffine to get needed wave orientation.



来源:https://stackoverflow.com/questions/33278533/drawing-a-wave-represented-by-orientation-frequency-phase-shift-amplitude-u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!