3
我想知道是否有人幫助我理解如何將頂層圖像轉換爲底層圖像。 圖片可在以下鏈接中找到。頂部圖片以笛卡爾座標顯示。底部圖像是在極性轉換後的圖像座標將圖像從笛卡爾座標轉換爲極座標
我想知道是否有人幫助我理解如何將頂層圖像轉換爲底層圖像。 圖片可在以下鏈接中找到。頂部圖片以笛卡爾座標顯示。底部圖像是在極性轉換後的圖像座標將圖像從笛卡爾座標轉換爲極座標
這是一個基本rectangular to polar coordinate transform。要進行轉換,掃描輸出圖像並將x和y視爲r和theta。然後用它們作爲r和theta來查找輸入圖像中相應的像素。所以像這樣:
int x, y;
for (y = 0; y < outputHeight; y++)
{
Pixel* outputPixel = outputRowStart (y); // <- get a pointer to the start of the output row
for (x = 0; x < outputWidth; x++)
{
float r = y;
float theta = 2.0 * M_PI * x/outputWidth;
float newX = r * cos (theta);
float newY = r * sin (theta);
*outputPixel = getInputPixel (newX, newY); // <- Should probably do at least bilinear resampling in this function
outputPixel++;
}
}
請注意,您可能想要處理包裝取決於你想要實現的。 θ值在2pi處換行。
你能幫我一個忙,並在MATLAB中編寫代碼。我不熟悉C++? – John
+1 @John您應該在提問時指定了語言。無論如何,如果你刪除「float」這個詞,剩下的幾乎就是你需要的公式。 – K3N
爲什麼newX和newY? –