# Imposing a prescribed motion field to a grayscale image

4 ビュー (過去 30 日間)
AP 2015 年 1 月 7 日

I have a grayscale image with intensity distribution I1(i,j). I am trying apply a motion field
u(i,j), v(i,j)
where (i,j) is the index coordinates in the image, u is the horizontal velocity, and v is the vertical velocity. I want to obtain the intensity at the next frame, I2(i,j), after being imposed by the prescribed motion field. In other word, by processing I1 and I2, one should get the motion field u,v. This is how I approached but it does not work:
% Creating a grayscale image.
a = 0;
b = 1;
I1 = (b-a).*rand(numel(u),1) + a;
I1 = reshape(I1, size(u));
I2 = zeros(size(I1));
InRows = size(I1, 1);
InCols = size(I1, 2);
% Estimating the intensity field in the next frame.
for j = 1:size(I1,2)
for i = 1:size(I1,1)
i1 = i + (round(v(i,j)));
j1 = j + (round(u(i,j)));
if i1 > 0 && i1 < (InRows+1) && j1 > 0 && j1 < (InCols+1)
I2(i1, j1) = max(I2(i1, j1),I1(i, j));
end
end
end
Could someone help me how this can be approached?
##### 1 件のコメント表示非表示 なし
David Young 2015 年 1 月 7 日
You say it does not work - what exactly goes wrong?

サインインしてコメントする。

### 回答 (2 件)

Guillaume 2015 年 1 月 7 日
In any case, it looks like a job for imwarp:
I2 = imwarp(I1, cat(3, u, v)); %imwarp with displacement field
##### 0 件のコメント表示非表示 -1 件の古いコメント

サインインしてコメントする。

Image Analyst 2015 年 1 月 7 日
Attached is an example for how to shift/move/translate an image with imwarp(). サインインしてコメントする。

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!