From: Stewart on
I am using the code below to try and provide an estimated motion vector for the next frame. I have to use this code in a m-code block which will then be passed to Xilinx to operate an FPGA. The code works as far as it goes but I need to obtain an estimate of the motion vector from the ref_frame array.

Based on the row and column location of the central pixel of the matching blocks from the reference block to the current block, then repeating the process with further frames as they arrive.

Also can anyone tell me if the functions used will encode in an m-code block for simulink and then xilinx using Matlab 2006a, I am using 2009a at home at the moment.
If blkproc won't work has anyone any pointers on how to code it.

f1, f, and f3 are <128x128 uint8 >
ref_frame is a <8x8 double >

Any guidance will be helpful,
Stewart

close all
clear all
%% Load first frame
f1 = rgb2gray(imread('Frame1.jpg')); % first frame
%figure, imshow(f1)
%% Load second frame
f2 = rgb2gray(imread('Frame2.jpg'));
%figure, imshow(f2)
%% find difference between f1 and f2 and square the difference ready for
% mean square error calculation.
f3 = (imabsdiff(f1,f2).^2);
%% Run block match pass
fun = @mean2;
ref_frame = blkproc(f3,[16,16], fun); %create reference frame
figure, imshow(ref_frame,'DisplayRange',[])
From: Stewart on
"Stewart " <tired2409.remove(a)hotmail.com> wrote in message <hqkq54$alg$1(a)fred.mathworks.com>...
> I am using the code below to try and provide an estimated motion vector for the next frame. I have to use this code in a m-code block which will then be passed to Xilinx to operate an FPGA. The code works as far as it goes but I need to obtain an estimate of the motion vector from the ref_frame array.

Any guidance on how to do this.>
> Based on the row and column location of the central pixel of the matching blocks from the reference block to the current block, then repeating the process with further frames as they arrive.
>
> Also can anyone tell me if the functions used will encode in an m-code block for simulink and then xilinx using Matlab 2006a, I am using 2009a at home at the moment.
> If blkproc won't work has anyone any pointers on how to code it.
>
> f1, f, and f3 are <128x128 uint8 >
> ref_frame is a <8x8 double >
>
> Any guidance will be helpful,
> Stewart
>
> close all
> clear all
> %% Load first frame
> f1 = rgb2gray(imread('Frame1.jpg')); % first frame
> %figure, imshow(f1)
> %% Load second frame
> f2 = rgb2gray(imread('Frame2.jpg'));
> %figure, imshow(f2)
> %% find difference between f1 and f2 and square the difference ready for
> % mean square error calculation.
> f3 = (imabsdiff(f1,f2).^2);
> %% Run block match pass
> fun = @mean2;
> ref_frame = blkproc(f3,[16,16], fun); %create reference frame
> figure, imshow(ref_frame,'DisplayRange',[])
From: David Young on
I'm finding it hard to work out how the code you've supplied relates to the problem of finding a motion vector. Can you explain the algorithm you're aiming to implement?
From: Stewart on
"David Young" <d.s.young.notthisbit(a)sussex.ac.uk> wrote in message <hql7k9$1pm$1(a)fred.mathworks.com>...
> I'm finding it hard to work out how the code you've supplied relates to the problem of finding a motion vector. Can you explain the algorithm you're aiming to implement?

What I am trying to do is to identify the moving part between two images using the least mean square error. However I am not able to use any of the Matlab MLSE functions because I am intending to implement the process on a Virtex2 FPGA using an m-block in Simulink and then process with Xilinx ISE. However my weak link is Matlab.

Si I get the two images into two 2x2 arrayswith the first providing the reference block.

The second array has the block in a new position and I want to work out what the direction of travel has been so I can use it as a predictor for the next frame to speed up the location of the target area.

Stewart.