INSANE slow list accessing with big lists

I made a basic image blurring code which works with Costume blocks.
my idea was collecting the pixel rgb values around each pixel then averaging it and applying it to each pixel. so if we have a pixel list of 100. we pick items from that list 900 times to apply blurring algorithm to each pixel (in paper. irl less because of dead zones which I dont wanna spend time to fix). well its working! extremely slow (still faster than rendering the image myself with pen and stuff) but still good.

i tried it on a basic 15x15 ish picture. it done it instantly. then I opened very big picture. i clicked to run.. progress(processed pixel count. not %) was like.. 1 by 1 per second. its insanely slow. my code is accessing same amount of pixels per loop. its slow just because list is big? how can I avoid it without subdividing the picture data list into pieces. my brain really cant handle that lol

up/down arrow change img.

-- pick the img 4. and make the blur = 1. render by pressing space.
-- pick the img 3. and make the blur = 1. render by pressing space.

you will see that progress is increasing much slower compared to img4.
img3 big and also slow. thats not good for me mate

any help about optimizing this appreciated

1st glance
It looks like you repeatably asking for the pixels or width or height of the image within a loop.

Much better is to set variables to those values outside of the loop and use the variable values inside the loop

A single iteration of "blur" took 1s.
After storing image pixels in the variable ~100ms.

aha. I thought pixels/width/height are fixed values. but i guess its trying to find those everytime i access them. now im getting 3kpixels per second! much better, much better

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.