Skip to content
Discussion options

You must be logged in to vote

It's because of your index computation. The way you're doing it now, pixels (0, 10) and (10, 0) will map to the same access_point, 10. This causes the diagonal lines -- the diagonals have the same values because they're actually filled with the same pixel.

So here you need to think about the pixel order. Since they're laid out in rows (first row, then the second row etc.), pixel (x, y) will be at y * width + x. Note, though, that some language and libraries will store 2D arrays by columns instead of rows.

Finally, it won't affect the result but, unless the compiler is being very smart, it will be faster if you access the pixels in a sequential pattern. You're looping by x, then by y, whic…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@AtmoPierce
Comment options

@lnicola
Comment options

@AtmoPierce
Comment options

Answer selected by AtmoPierce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants