Borrar filtros
Borrar filtros

Can the vectors' colours be changed when using opticalFlowFarneback?

2 visualizaciones (últimos 30 días)
ZEE
ZEE el 20 de En. de 2019
Respondida: Vishnu Sreekumar el 25 de Jun. de 2019
Hi, I'm trying to create a colored optical flow depending on the magnitude of the vector.
Is there a way to change the colors of the quiver using the built-up functions opticalFlowFarneback and estimate flow?
This is my code which creates just blue arrows. However, I want arrows with different colors depending on the magnitude for example 'jet' or 'parula' colour maps
im1=outA(:,:,:,1);
im2=outA(:,:,:,60);
opticFlow = opticalFlowFarneback();
flow = estimateFlow(opticFlow,im1);
flow = estimateFlow(opticFlow,im2);
figure
imshow(im1)
hold on
plot(flow,'DecimationFactor',[5 5],'ScaleFactor',4);
hold off

Respuestas (1)

Vishnu Sreekumar
Vishnu Sreekumar el 25 de Jun. de 2019
An option would be to choose a color based on magnitude first:
thisColor = whatever mapping you have between say mean(flow.Magnitude(:)) and your colormap
and then:
figure;
imshow(im1)
hold on;
quiver(flow.Vx,flow.Vy, 'Color', thisColor)
PS: Just make sure quiver(flow.Vx, ...) gives you the same result as plot(flow), because I've always been confused by what's X and what's Y in these matrices, sometimes, due to the built-in functions in MATLAB being geared towards video applications, X direction can be top to bottom (rows of a matrix) and Y can be columns of the matrix meaning the horizontal axis! So if that's the case, you might find that quiver(flow.Vy, flow.Vx, ...) matches plot(flow) better.

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by