From: Stewart on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hsscif$brj$1(a)canopus.cc.umanitoba.ca>...
> Stewart wrote:
>
> > The only problem with this is when I find the block I am looking for I
> > can't exit until the for loop has gone through all of the elements.
> >
> > Does anyone know how to exit the for loop at the required point?
>
> break;
>
> when you have found what you want. And be sure to check in case none of the
> blocks had what you wanted.

Thanks again, this excerpt below is the implementation.
I have a search pattern of:
5 4 3
6 1 2
7 8 9

L equals large block and S equals small block, I always start at position 1 and then spiral round. I have created the test images and I know the pattern is in block 3 large and block 9 small both of which are output in the relevant cycle by bstep.
Now I am going to create the Motion Vector which will act as a predictor for the next image.

Stewart.

for k = Lcoord
MinY = k(1);
MaxY = k(2);
MinX = k(3);
MaxX = k(4);
while mse > 1
cur = secondImage(MinY:MaxY, MinX:MaxX);
bstep = bstep + 1;
% Calculate mean square error.
mseImage = (double(ref) - double(cur)) .^ 2;
mse = sum(sum(mseImage)) / (rows * columns);
break
end;
end;