Open
Description
Hi.
I am trying to reimplement the pdq hash algorithm in go and need to access all pixels and their r g b values individually for the whole image. It seems to work fine up until I call image.GetPoint
. Doing this seems to significantly (speak SECONDS per iteration aka about 2 minutes for the whole file) slow down the process.
I am not sure why its slow.
The code used is like this:
numCols := image.Width()
numRows := image.Height()
for i := 0; i < numRows; i++ {
for j := 0; j < numCols; j++ {
colorArray, err := image.GetPoint(j, i)
if err != nil {
log.Fatalf("Error getting pixel: %v", err)
}
r := colorArray[0]
g := colorArray[1]
b := colorArray[2]
(*luma)[i*numCols+j] = LUMA_FROM_R_COEFF*r + LUMA_FROM_G_COEFF*g + LUMA_FROM_B_COEFF*b
}
}
where image is a reference to the image. The rest is semi relevant only. I verified that the GetPoint call specifically is the slow part of the loop.
Any ideas what might be going on or how to make it faster?
Metadata
Metadata
Assignees
Labels
No labels
Activity