Моя цель - преобразовать 2D-спектр мощности (ниже) из декартовой в полярные координаты.
imshow(np.log10(psd2shift),cmap=cm.jet)
В stackoverflow есть несколько сообщений о том, как это сделать, например, ссылка .И поэтому я считаю, что мой код правильный.
ro,col=psd2shift.shape
cent=(int(ro/2),int(col/2))
max_radius = int(np.sqrt(ro**2+col**2)/2)
polar=cv.linearPolar(np.log10(psd2shift),cent,max_radius,cv.WARP_FILL_OUTLIERS)
plt.imshow(polar,cmap=cm.jet, interpolation='bicubic')
![enter image description here](https://i.stack.imgur.com/JJb0O.png)
Тем не менее я не получаю то, что хочу, вот что: ![enter image description here](https://i.stack.imgur.com/xfjLq.png)
Очевидно, что есть разница в преобразовании, которую я не смог раскрыть, несмотря на то, что копался в помощи функции linearPolar или документации здесь .Кажется, что центр не определен правильно, но я почти уверен, что это так. Смысл?
С help(cv.linearPolar)
Возвращает: Справка по встроенной функции linearPolar:
linearPolar(...)
linearPolar(src, center, maxRadius, flags[, dst]) -> dst
. @brief Remaps an image to polar coordinates space.
.
. @anchor polar_remaps_reference_image
. ![Polar remaps reference](pics/polar_remap_doc.png)
.
. Transform the source image using the following transformation:
. \f[\begin{array}{l}
. dst( \rho , \phi ) = src(x,y) \\
. dst.size() \leftarrow src.size()
. \end{array}\f]
.
. where
. \f[\begin{array}{l}
. I = (dx,dy) = (x - center.x,y - center.y) \\
. \rho = Kx \cdot \texttt{magnitude} (I) ,\\
. \phi = Ky \cdot \texttt{angle} (I)_{0..360 deg}
. \end{array}\f]
.
. and
. \f[\begin{array}{l}
. Kx = src.cols / maxRadius \\
. Ky = src.rows / 360
. \end{array}\f]
.
.
. @param src Source image
. @param dst Destination image. It will have same size and type as src.
. @param center The transformation center;
. @param maxRadius The radius of the bounding circle to transform. It determines the inverse magnitude scale parameter too.
. @param flags A combination of interpolation methods, see cv::InterpolationFlags
.
. @note
. - The function can not operate in-place.
. - To calculate magnitude and angle in degrees @ref cv::cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees.