问题
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):
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;
Copy first row to other rows for receiving something like vertical lines.
Use
cv::getRotationMatrix2D
andcv::warpAffine
to get needed wave orientation.
来源:https://stackoverflow.com/questions/33278533/drawing-a-wave-represented-by-orientation-frequency-phase-shift-amplitude-u