I am using Matlab to analyse video optical flow and what I want to do is weighing the optical flow between video frames.
My problem is I don't know how to modify the read only opticalFlow object property, specially, magnitude property.
Here is my test code (this simple code is on the MathWork help documentation http://uk.mathworks.com/help/vision/ref/opticalflow-class.html):
opflow = opticalFlow(randn(5,5),randn(5,5))
check the output, we have:
opticalFlow with properties:
Vx: [5x5 double]
Vy: [5x5 double]
Orientation: [5x5 double]
Magnitude: [5x5 double]
Then we check the opflow.Magnitude property, we have:
>>opflow.Magnitude
ans =
1.1661 1.5809 1.9726 0.2291 0.6722
1.9727 1.2263 3.0523 0.2715 1.2187
2.2791 1.1224 1.0470 1.5235 0.9531
0.9109 3.6688 1.3717 1.4433 1.9629
0.8494 4.0421 1.8548 1.6603 1.2122
When I try to modify the opticalFlow object(opflow here), the Matlab report an error:
>> opflow.Magnitude(1,1)=0
You cannot set the read-only property 'Magnitude' of opticalFlow.
I then checked setter methods and googled some other documents but still cannot find a solution. I know I could copy them out to another matrix and then modify that new matrix, but it will waste memory while calculating optical flow for a long video sequence. Is there any way I could modify this read only property?