Determining new x,y location of an object
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Jan
am 30 Nov. 2012
@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.
Antworten (3)
Image Analyst
am 29 Nov. 2012
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 Kommentar
Image Analyst
am 29 Nov. 2012
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
am 30 Nov. 2012
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.
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!