import numpy as np
导入cv2
frommatplotlibimportpyplotasplt
img=cv2.im read (c : (用户(not my username (桌面) (20140505 ) 124500 ) 4096 ) hmiIC.jpg ) )。
孤独的夕阳_image=cv2 .孤独的夕阳alize(img,dst=None,孤独的夕阳_type=cv2.NORM_MINMAX,dtype=cv2.CV_32F )。
plt.imshow (孤独的夕阳_image,cmap='afmhot ',interpolation='bicubic ' ) )。
PLT.xticks([,PLT.yticks ) [ ] ) ) )。
plt.show () )
The solar disc I'm using:
I ' mwonderingifthereisaneasywaytoconverttheimagefromcartesiantopolar?
Like this example:
Or like this example:
For some reason,I ' vefoundmanyexamplesinmatlabbuti ' veyettofindoneinpython.I ' vebeenlookingatthisfromopencvbuti ' mnotententtion asiwanttokeeptheoriginalimage/array size.iknowconvertingtopolarwill ' screw ' uptheimagebutthatisfine, themainthingi ' mwantingtodoismeasuretheintensityofthesolardiskfromthecenterouttotheedge,plottingafunctionofintensityvsradiuradiue
解决方案
代码:
导入cv2
import numpy as np
source=cv2.im read (c :/users/selwyn 77/desktop/sun.jpg ',1 ) )
----ensureimageisofthetypefloat-- -
img=source.astype(NP.float32 ) )
----thefollowingholdsthesquarerootofthesumofsquaresoftheimagedimensions----
--- thisisdonesothattheentirewidth/heightoftheoriginalimageisusedtoexpressthecompletecularrangeoftheresultingpolarimagth
value=NP.sqrt ((img.shape [0]/2.0 ) *2.0 ) ) img.shape[1]/2.0 ) **2.0 ) )
polar _ image=cv2.linear polar (img,(img.shape[0]/2,img.shape[1]/2 ),value,cv2.warp_fill_ool
polar _ image=polar _ image.as type (NP.uint8) )。
CV2.imshow(polarimage ),polar_image ) )。
cv2 .等待密钥(0) () ) ) ) ) ) ) ) ) ) ) )。
cv2.destroyAllWindows (
结果: