0
最近,我一直對機器學習感興趣,特別是機器學習與圖像,但要做到這一點,我需要能夠處理圖像。我希望對圖像處理庫的工作方式有更全面的瞭解,所以我決定建立自己的圖書館來閱讀我能理解的圖像。但是,我似乎有一個問題,當談到讀取圖像的SIZE,因爲這個錯誤彈出,當我嘗試編譯:爲什麼你不能把一個變量作爲一個多維數組大小放在Go中?
./imageProcessing.go:33:11: non-constant array bound Size
這是我的代碼:
package main
import (
// "fmt"
// "os"
)
// This function reads a dimension of an image you would use it like readImageDimension("IMAGENAME.PNG", "HEIGHT")
func readImageDimension(path string, which string) int{
var dimensionyes int
if(which == "" || which == " "){
panic ("You have not entered which dimension you want to have.")
} else if (which == "Height" || which == "HEIGHT" || which == "height" || which == "h" || which =="H"){
//TODO: Insert code for reading the Height of the image
return dimensionyes
} else if (which == "Width" || which == "WIDTH" || which == "width" || which == "w" || which =="W"){
//TODO: Insert code for reading the Width of the image
return dimensionyes
} else {
panic("Dimension type not recognized.")
}
}
func addImage(path string, image string, Height int, Width int){
var Size int
Size = Width * Height
var Pix [Size][3]int
}
func main() {
}
我剛剛開始用Go編程,所以如果這個問題聽起來不怎麼樣,我很抱歉