From: Stewart on
Hi,

I have a submatrix defined as:

cur = secondImage(5:8, 5:8);

And a matrix with the coordinates required:

ScbN = [5 8 5 8; 5 8 9 12; 1 4 9 12; 1 4 5 8;...
1 4 1 4; 5 8 1 4; 9 12 1 4; 9 12 5 8; 9 12 9 12];

Now, I would like to use a loop which in turn takes the four coordinates from ScbN
and places them into cur.
Subsequently I do an mse compare on cur and the ref block and when mse equals zero the matching block has been found. placing the coordinates in by hand shows the desired result.
My problem is that I have no idea how to get the four coordinates from ScbN into cur.

Any assistance or pointers gratefully received.

Stewart.
From: Walter Roberson on
Stewart wrote:

> I have a submatrix defined as:
>
> cur = secondImage(5:8, 5:8);
>
> And a matrix with the coordinates required:
>
> ScbN = [5 8 5 8; 5 8 9 12; 1 4 9 12; 1 4 5 8;...
> 1 4 1 4; 5 8 1 4; 9 12 1 4; 9 12 5 8; 9 12 9 12];

> Now, I would like to use a loop which in turn takes the four coordinates
> from ScbN
> and places them into cur.

for K = 1 : size(ScbN, 1)
curr = ScbN(K,:);
%some code here
end
From: Stewart on
Walter Roberson <roberson(a)hushmail.com> wrote in message <0T_Hn.5917$%u7.4696(a)newsfe14.iad>...
> Stewart wrote:
>
> > I have a submatrix defined as:
> >
> > cur = secondImage(5:8, 5:8);
> >
> > And a matrix with the coordinates required:
> >
> > ScbN = [5 8 5 8; 5 8 9 12; 1 4 9 12; 1 4 5 8;...
> > 1 4 1 4; 5 8 1 4; 9 12 1 4; 9 12 5 8; 9 12 9 12];
>
> > Now, I would like to use a loop which in turn takes the four coordinates
> > from ScbN
> > and places them into cur.
>
> for K = 1 : size(ScbN, 1)
> curr = ScbN(K,:);
> %some code here
> end

Thanks for your suggestion Walter.

I have been working on it and I found that the matrix is the wrong way round, above is 4x9 and it should be 9x4. Then I can use a for loop and pick out the required values from the columns rather than the rows.

clc;
close all;
clear all;
workspace;

%%
Lcoord =[17 17 1 1 1 17 33 33 33; 32 32 16 16 16 32 48 48 48;...
17 33 33 17 1 1 1 17 33; 32 48 48 32 16 16 16 32 48];

Scoord = [5 5 1 1 1 5 9 9 9; 8 8 4 4 4 8 12 12 12;...
5 9 9 5 1 1 1 5 9; 8 12 12 8 4 4 4 8 12];
%%
count = 0;
secondImage = rgb2gray(imread('LI.jpg'));
%%
for k = Lcoord

MinY = k(1);
MaxY = k(2);
MinX = k(3);
MaxX = k(4);
cur = secondImage(MinY:MaxY, MinX:MaxX);
count = count + 1;
end;

This loop allows me to inspect a block search window with either a small 4x4 block or a large 16x16 block in an anticlockwise patern from the centre to 3 o clock and then round.
From: Stewart on
"Stewart " <tired2409.remove(a)hotmail.com> wrote in message <hss36n$cg0$1(a)fred.mathworks.com>...
> Walter Roberson <roberson(a)hushmail.com> wrote in message <0T_Hn.5917$%u7.4696(a)newsfe14.iad>...
> > Stewart wrote:
> >
> > > I have a submatrix defined as:
> > >
> > > cur = secondImage(5:8, 5:8);
> > >
> > > And a matrix with the coordinates required:
> > >
> > > ScbN = [5 8 5 8; 5 8 9 12; 1 4 9 12; 1 4 5 8;...
> > > 1 4 1 4; 5 8 1 4; 9 12 1 4; 9 12 5 8; 9 12 9 12];
> >
> > > Now, I would like to use a loop which in turn takes the four coordinates
> > > from ScbN
> > > and places them into cur.
> >
> > for K = 1 : size(ScbN, 1)
> > curr = ScbN(K,:);
> > %some code here
> > end
>
> Thanks for your suggestion Walter.
>
> I have been working on it and I found that the matrix is the wrong way round, above is 4x9 and it should be 9x4. Then I can use a for loop and pick out the required values from the columns rather than the rows.
>
> clc;
> close all;
> clear all;
> workspace;
>
> %%
> Lcoord =[17 17 1 1 1 17 33 33 33; 32 32 16 16 16 32 48 48 48;...
> 17 33 33 17 1 1 1 17 33; 32 48 48 32 16 16 16 32 48];
>
> Scoord = [5 5 1 1 1 5 9 9 9; 8 8 4 4 4 8 12 12 12;...
> 5 9 9 5 1 1 1 5 9; 8 12 12 8 4 4 4 8 12];
> %%
> count = 0;
> secondImage = rgb2gray(imread('LI.jpg'));
> %%
> for k = Lcoord
>
> MinY = k(1);
> MaxY = k(2);
> MinX = k(3);
> MaxX = k(4);
> cur = secondImage(MinY:MaxY, MinX:MaxX);
> count = count + 1;
> end;
>
> This loop allows me to inspect a block search window with either a small 4x4 block or a large 16x16 block in an anticlockwise patern from the centre to 3 o clock and then round.


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?
From: Walter Roberson on
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.