calculate_lines_gauss_parameters (MaxLineWidth, [Contrast,0], Sigma, Low, High)
輸入最大線寬以及對比度計算Sigma,Low,High
* Check control parameters if (|MaxLineWidth| != 1) throw ('Wrong number of values of control parameter: 1') endif if (not is_number(MaxLineWidth)) throw ('Wrong type of control parameter: 1') endif if (MaxLineWidth <= 0) throw ('Wrong value of control parameter: 1') endif if (|Contrast| != 1 and |Contrast| != 2) throw ('Wrong number of values of control parameter: 2') endif if (min(is_number(Contrast)) == 0) throw ('Wrong type of control parameter: 2') endif * Set and check ContrastHigh ContrastHigh := Contrast[0] if (ContrastHigh < 0) throw ('Wrong value of control parameter: 2') endif * Set or derive ContrastLow if (|Contrast| == 2) ContrastLow := Contrast[1] else ContrastLow := ContrastHigh / 3.0 endif * Check ContrastLow if (ContrastLow < 0) throw ('Wrong value of control parameter: 2') endif if (ContrastLow > ContrastHigh) throw ('Wrong value of control parameter: 2') endif * * Calculate the parameters Sigma, Low, and High for lines_gauss if (MaxLineWidth < sqrt(3.0))* 注意LineWidthMax < sqrt(3.0)將導致Sigma < 0.5,這沒有任何意義,因為相應的平滑濾波掩碼的大小為1x1。 * 為了避免這種情況,LineWidthMax被限制為大於或等於sqrt(3.0)的值,而對比度值則適用於反映這樣一個事實: * 在平滑圖像中,比sqrt(3.0)像素更細的線具有更低的對比度(與寬為sqrt(3.0)像素的線相比)。 ContrastLow := ContrastLow * MaxLineWidth / sqrt(3.0) ContrastHigh := ContrastHigh * MaxLineWidth / sqrt(3.0) MaxLineWidth := sqrt(3.0) endif * 將LineWidthMax和給定的對比值轉換為lines_gauss所需的輸入參數Sigma, Low和High HalfWidth := MaxLineWidth / 2.0 Sigma := HalfWidth / sqrt(3.0) Help := -2.0 * HalfWidth / (sqrt(6.283185307178) * pow(Sigma,3.0)) * exp(-0.5 * pow(HalfWidth / Sigma,2.0)) High := fabs(ContrastHigh * Help) Low := fabs(ContrastLow * Help) return ()