【问题标题】:Matlab and Complex Number ComputingMatlab 和复数计算
【发布时间】:2013-07-29 18:46:43
【问题描述】:

我目前正在 matlab 中编写代码来分析滤心中的光流,并且由于某种原因,每当我运行它时,它都会返回奇怪的复杂函数。我不确定它们来自哪里,我希望能得到一些帮助来解决这个问题。

function [opticalFlow] = opticalflowanalysis(handles,hOpticalflow)

videoReader = vision.VideoFileReader('jun07_0165_segment8to12_20.avi','ImageColorSpace','Intensity','VideoOutputDataType','single');
converter = vision.ImageDataTypeConverter; 
opticalFlow = vision.OpticalFlow('OutputValue', 'Horizontal and vertical components in complex form','ReferenceFrameDelay', 6);
shapeInserter = vision.ShapeInserter('Shape','Lines','BorderColor','Custom', 'CustomBorderColor', 255);
videoPlayer = vision.VideoPlayer('Name','Motion Vector');
%Convert the image to single precision, then compute optical flow for the video. Generate coordinate points and draw lines to indicate flow. 

i=0;
mm = ones(1080,1920);
%Display results.      
while ~isDone(videoReader)
    frame = step(videoReader);
    im = step(converter, frame);
    of = step(opticalFlow, im); %always complex number
    aa = size(of)
    lines = videooptflowlines(of, 5); %complex number only sometimes - when lines appear?
    bb = size(lines)
    x = i+ 1;
    if(x==2)
        mm = of;
    end
    % show diff bw of and lines matrices
    if (x == 2)||(x == 10)
        for j=1:1:1080 %gives j = [1 2 ... 720]
            for k=1:1:1920 %gives k = [1 2 ... 1280]
                of(j,k)
                lines(j,k)
                if(of(j,k) ~= lines(j,k))
                    disp(['of[',num2str(j),',',num2str(k),'] = ', num2str(of(j,k)), '...', 'lines[',num2str(j),',',num2str(k),'] = ', num2str(lines(j,k))])
                end
            end
        end
    end
    if ~isempty(lines)
      out =  step(shapeInserter, im, lines); 
      step(videoPlayer, out);
    end
end
%Close the video reader and player ,
%handles.output = hObject;
release(videoPlayer);
release(videoReader);

mm

返回:

aa =

        1080        1920


bb =

       36465           4

bb的变量来自哪里?

谢谢, 雅各布

【问题讨论】:

  • 您是说变量lines 有时很复杂,但不应该如此?查看 R2012b 中videooptflowlines(命令窗口中的edit videooptflowlines)的内容,我看不出它是如何返回复杂值的。
  • 据我所知,这个问题实际上与复数无关。我认为应该编辑标题和标签以反映这一点,但在继续编辑之前希望 OP 进一步澄清。

标签: matlab computer-vision complex-numbers matlab-cvst


【解决方案1】:

尝试在aabb 被分配到的行的末尾放置分号(ie ;

aa = size(of);
...
bb = size(lines);

看看会发生什么。

请注意,因为 aabb 似乎都不会在程序的后面使用,您可能可以安全地删除这两行。

【讨论】:

  • 我同意,这似乎完全是由于抑制输出,而与复数无关。
  • 我故意不使用分号,因为我不希望抑制这些特定的输出。我只是对“变量 bb”的输出来自哪里感到困惑,我看不出它与输入之间没有相关性。
猜你喜欢
  • 1970-01-01
  • 2017-10-29
  • 2011-08-17
  • 1970-01-01
  • 2015-12-10
  • 2011-12-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多