I need help with image processing in Octave. I’m trying to calculate a local “sliding window” ssd on some images. The slowness is excessive (the nested for loops add up to 88*120*41*41 iterations), so it’s impossible to work with it. The version i’m using is 3.6.2 on Windows7 64bit. (corei5)
I’m launching the following octave script
onto the following image
http://picpaste.com/pattern1-90xYCNZB.bmp
Any suggestion?
Thank you in advance for your attention
Take a loop at the functions
filter2,ordfilt2andblockproc(this last one is most likely what you will use. It was called blkproc in package versions prior to 2.0.0). I didn’t take a good look at what your code is trying to do but I’d be very surprised if those loops really are necessary. You seem to be doing only simple arithmetic at different indexes. Learn how to vectorize your code and you’ll see a huge improvement. If you can explain what the code is supposed to be doing, we might be of more help.Also, you don’t need to use
sum (sum (x)), you can and should replace these withsum (x(:)). And you also don’t need to usesum (x.^2), you can usesumsq (x). So your 4 function callsqrt (sum (sum (curDiff.^2)))of yours could be replaced bysumsq (curDiff(:)).Compare the following:
Not only it’s much shorter and easier to read, it’s also 4x faster (which in a huge loop like yours will make a huge difference).