Determining new x,y location of an object
1 回表示 (過去 30 日間)
古いコメントを表示
If I know the original x,y location of an object, then move it randomly to a different point on an image, how can I determine it's new x,y location?
2 件のコメント
Jan
2012 年 11 月 30 日
@Sara: Most likely the problem gets clear, when you post the relevant part of the code.
Of course the information where the parts of the scrambled image are located afterwards are available in your program already. But we cannot guess where or in which format.
回答 (3 件)
Image Analyst
2012 年 11 月 29 日
Did you move the object digitally, in code, or did you move it, say, by moving it to a new place in a scene and take another photo of it?
1 件のコメント
Image Analyst
2012 年 11 月 29 日
If you move the object by deltaX and deltaY, then obviously the new location is
newX = startingX + deltaX;
newY = startingY + deltaY;
Needless to say, it's new position is (newX, newY). But this is way way too obvious (you wouldn't have even asked about something so trivial and simple) so we must have misunderstood your question. Can you try to describe it in more detail this time?
John Petersen
2012 年 11 月 30 日
You know which cell in A that the pedestrian is located, right? Say it's the A(r,c) cell. Then,
ped = (c-1)*2 + r; % location of the pedestrian in A strung out,
% i.e. A(ped) = A(r,c)
B=randperm(8);
C=reshape(B,2,4);
D=mat2cell(C,[1,1],[1,1,1,1]);
for i=1:8
[row,col]=find(C==i) % move tile i to row,col
D(row,col)=A(i); % Build new image
if (C(i)==ped)
Row_newped = row; %FOUND PEDESTRIAN in New image
Col_newped = col;
end
end
There's probably a more efficient code that doesn't require a loop, but this should be clear to you so you understand the idea.
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!