This post is part of a series about some experiments I’m doing combining space and time in slit scan photographs. The series starts here.
When you take a set of 10,000 5200×3500 pixel images and run slit scan simulations against them, there are a lot of options:
- What image to start with.
- Which way to run the simulated scan.
- How fast to move the simulated slit.
- How diffuse the edges of the slit should be.
There are way more than 10,000 ways to process all those images, and probably several thousand that yield meaningfully different results. It takes between 20 minutes and two hours to process an image. That means that opportunities for experimentation are limited. I’ve tried reducing the size of the images, finding something that works, then going back to the big images, and trying to get something similar. I don’t like that workflow, and it’s pretty hit and miss.
What to do?
Heck, this is photography! You already know the answer: pour money on it.
I called up MathWorks and ordered the Parallel Processing Toolkit for Matlab. The price wasn’t actually all that high. I spet about five minutes scanning the documentation, and found a tool that will work for me. It’s a construction similar to a for loop, but one that allows parallel execution. It’s called parfor. I was careful to write a loop for processing images in parallel where any iteration did not depend on the result of any other iteration. I was also careful to create any class instances inside the loop, so that each parallel interation would get its own class instance.
When I ran it, I got a bunch of Matlab processes:
There’s a place in the Matlab console for tuning the parallel execution. About the only thing I needed to do was to pick the maximum number of parallel workers so that the combined process set was just under being disk-limited, and that I had enough CPU capacity left to do my usual work while Matlab did its thing. I picked 24 workers, which gave me resource utilization like this:
Then I proceeded to make images like these: