3 ms·
I would say it's better to iterate on y first because line at the time is more sequential access than column at a time. I noticed that before the naming incons
by asveikau 6y ago
I would say it's better to iterate on y first because line at the time is more sequential access than column at a time.
I noticed that before the naming inconsistency.
- dheera 6y agoEh it depends on what you're doing with it. If you're doing some kind of convolution type thing that is going to access a whole lot of nearby pixels in all directions, it doesn't really matter. Also there are times I like to store "images" such that accessing image[x,y] yields (x,y) as if the image were placed in the 1st quadrant, which makes code easier to read and more intuitive. In that case the outer irritation being x-wise and the inner irritation being y-wise is faster. I absolutely hate those irritating image[height-y, x] type bullshit appearing all over my code. If you want readability image[x, y] should be (x,y) with the origin at the lower left as it always is in grade school. (I hate the people who invented matrices for putting 0,0 at the top left and inverting the y-axis.)