Help developing an image frame sequence generator

조회 수: 7 (최근 30일)
Vanessa
Vanessa 2017년 4월 26일
편집: Will Nitsch 2017년 5월 1일
Hi all,
I am doing a project where I have to create frames of images, to show a track path of an object and detect it. The end goal of my code is to create a line that shows the track path of the object as it moves and a box to detect the object at it's final position on the image (original image and desired output image that I would like is shown as an example).
In order to do this, I need help with generating the frames with different object positions. I have already created an object from an array (using the zeros function) with a set intensity value and have overlayed it on to the original background image (using imadd(image, object)). I have different frames with the object at different positions. Any idea, how I can show a streak/line to show the track path of the object?
I would really appreciate any help with this.
Kind regards,
Vanessa
Original frame:
Desired image output:

채택된 답변

Will Nitsch
Will Nitsch 2017년 5월 1일
편집: Will Nitsch 2017년 5월 1일
Since you have all of the object positions (I assume you know the sequential order of each position as well), you can use Bresenham's line drawing algorithm. Here is a file-exchange submission. This is a well implemented algorithm but the author forgot to terminate a couple of lines with ';', so be sure to add those unless you want tons of stuff printed to the command window. https://www.mathworks.com/matlabcentral/fileexchange/28190-bresenham-optimized-for-matlab
To do this, first get your position coordinates as the (x,y) pixel indices. Then, for each iteration of the sequence (from 1 -> 2, from 2 -> 3, from 3 -> 4, etc.), just call the Breshenam algorithm to generate the list of x and y coordinates associated with the line between each set of two points. For instance, your workflow would go something like this:
Make a red line between points, given two locations '(x1,y1)' and '(x2,y2)':
>> [x y]=bresenham(x1,y1,x2,y2);
>> for i = 1:length(x)
>> Iin(y(i),x(i),1) = 255;
>> Iin(y(i),x(i),2) = 0;
>> Iin(y(i),x(i),3) = 0;
>> end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by