|
Hi everyone,
Long-time reader, first time poster.
I am currently trying to improve the performance of a program I am working on by carrying out operations in parallel. The basic code that I am using for this operation is something like:
for i = 1:Mdivs
parfor j = 1:Ndivs
pic = fun1(img1((i-1)*step+1:min([factor+(i-1)*step,M]),(j-1)*step+1:min(factor+(j-1)*step,N),:));
motion(i,j,:) = fun2(pic);
end
end
fun1 takes an RGB image, processes it and returns a grayscale image. fun2 processes the grayscale image and returns a two-element vector (1x1x2 in size actually), which I store at the appropriate location in motion. step,factor,M and N are of class double. They are used to extract a subimage from the image img1.
The problem that I have is that the code behaves very erratically. Sometimes, the execution is perfect, but at other times I get the following error message:-
Error using ==> parallel_function at 594
Subscripted assignment dimension mismatch.
Error in ==> control2 at 22
parfor j = 1:Ndivs
I have spent a long time trying to figure out any pattern in the instances which cause the error, but have come up with squat. Any suggestions at all would be very helpful.
Thanks and cheers!
|