Background: main task is segmentation and tracking of (multiple) objects in a video, i intend to use meanshift for segmentation to which LUV-color-coded optical flow image is to be used as input.
So i calculated optical flow and converted vertical and horizontal values to polar coordinates using cart2pol. Now used Image Analyst's colorwheel and used following code to obtain RGB-color-coded optical flow image.
%%accessing RGB color agains theta and rho
outDir='./output/';
load([outDir 'polarflow.mat']);
rgbflow=struct('rgb_flow',{});
for i=1:size(polarflow,2)
for row=1:size(polarflow(1).p_flow,1)
for col=1:size(polarflow(1).p_flow,2)
theta=polarflow(i).p_flow(row,col,1);
theta_in_degrees = radtodeg(theta);
theta_in_degrees = ceil(wrapTo360(theta_in_degrees));
rho=ceil(polarflow(i).p_flow(row,col,2));
% colour_row = ceil(size(rgb,1) * theta_in_degrees/359 + eps);
% colour = rgb(colour_row,:); %%these 2 lines return 1755 values, couldn't interpret
colour=rgb(theta_in_degrees,rho,:);
rgbflow(i).rgb_flow(row,col,1)=colour(:,:,1);
rgbflow(i).rgb_flow(row,col,2)=colour(:,:,2);
rgbflow(i).rgb_flow(row,col,3)=colour(:,:,3);
end
end
end
save([outDir 'rgbflow.mat'],'rgbflow');
Problem is only a portion of original image is left, much foreground information is lost. An image and result image is attached. Kindly let me know any tips.

답변 (1개)

Image Analyst
Image Analyst 2016년 1월 9일

0 개 추천

Or you can adapt my attached color wheel demo to use ginput() to let the user pick the color they want to use.

댓글 수: 6

Maryam Butt
Maryam Butt 2016년 1월 9일
Thank you for help, kindly clear one more thing when i use Star Strider's code it returns (r,g,b) value for colour for any value of theta while using that code with your color_wheel returns a row of 1755 columns, how to interpret this?
You can get the row and column from ginput, something like
[x,y] = ginput(1);
row = round(y);
col = round(x);
theColor = rgbImage(row, col, :);
Maryam Butt
Maryam Butt 2016년 1월 9일
ginput isn't necessary because i have all x,y values which I need to convert to polar coordinates (done) then i have got polar values [theta,rho] now i need to access the color value corresponding to theta angle and also incorporate rho somehow.
Image Analyst
Image Analyst 2016년 1월 10일
I'm not sure what you're after with your latest edit, but if you want to track green blobs, see my attached demo.
Maryam Butt
Maryam Butt 2016년 1월 10일
Though in this image green blobs (basketball) need to be tracked but it is only an example, I want to track moving objects in general, they can be of any color, shape etc.
Image Analyst
Image Analyst 2016년 1월 10일
Usually they just use quiver to show arrows. If you want them in colors for different vector lengths, you'd have to look for code for that. I think I've seen it but I don't remember where.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Tracking and Motion Estimation에 대해 자세히 알아보기

질문:

2016년 1월 9일

댓글:

2016년 1월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by