Here's my code to produce a glcm using gocv, the functions of imageprocessing package aren't important to this issue, with them a read images from a folder. I'm trying to get the GLCM from the third image (Images[2]), but a get and error when running it. How can I fix it?.
package main
import (
"./imageprocessing"
"gocv.io/x/gocv"
// "fmt"
)
/** CovarFlags
// CovarScrambled indicates to scramble the results.
CovarScrambled CovarFlags = 0
// CovarNormal indicates to use normal covariation.
CovarNormal CovarFlags = 1
// CovarUseAvg indicates to use average covariation.
CovarUseAvg CovarFlags = 2
// CovarScale indicates to use scaled covariation.
CovarScale CovarFlags = 4
// CovarRows indicates to use covariation on rows.
CovarRows CovarFlags = 8
// CovarCols indicates to use covariation on columns.
CovarCols CovarFlags = 16
**/
/**
*
* @brief { function_description }
* @return { description_of_the_return_value }
*/
func main() {
var size int
size = imageprocessing.FolderLength("./imageprocessing/Images/danger")
Images := make([]gocv.Mat,size)
GLCM := gocv.NewMat()
mean := gocv.NewMat()
imageprocessing.ReadFolder(Images,"./imageprocessing/Images/danger",true,false,true)
//CalcCovarMatrix(samples Mat, covar *Mat, mean *Mat, flags CovarFlags, ctype MatType)
gocv.CalcCovarMatrix(Images[2], &GLCM, &mean, gocv.CovarCols, Images[2].Type())
window := gocv.NewWindow("Images[2]")
window.IMShow(Images[2])
window.WaitKey(0)
window.IMShow(GLCM)
window.WaitKey(0)
}
I was passing an RGB Image to the function, which I thought would automatically deal with this. I didn't read the function specifications properly. that's was the problem.
imageprocessing.ReadFolder(Images,"./imageprocessing/Images/danger",true,false,false)
func ReadFolder(Images []gocv.Mat, folder string, print bool, show bool, colorfull bool)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.