Skip to content

image.GetPoint() is extremely slow #408

Open
@MTRNord

Description

@MTRNord

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions