2013-07-29 5 views
1

현재 matlab에 코드를 작성하여 침투하는 심장에서 옵티컬 플로우를 분석하고 있는데 어떤 이유로이 알고리즘을 실행할 때마다 이상한 복합 함수가 반환됩니다. 나는 그들이 어디에서 왔는지 모르겠다. 나는 그것을 알아 내는데 도움이 될 것이다.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 

이 반환 BB에서 변수에서 온 할

aa = 

     1080  1920 


bb = 

     36465   4 

를?

감사합니다, 야곱

+0

변수'lines'가 때때로 복잡하다고 말하는 것입니까? 그렇지 않아야합니까? R2012b에서'videooptflowlines' (명령 창에서'edit videooptflowlines' 편집)의 내용을 보면 어떻게 복잡한 값을 반환 할 수 있는지 보지 못했습니다. – horchler

+0

제가 말할 수있는 한,이 질문은 실제로 복소수와 아무 관련이 없습니다. 제목과 태그는이를 반영하기 위해 편집되어야한다고 생각하지만, 편집을 진행하기 전에 OP의 더 명확한 설명을 원합니다. – tmpearce

답변

1

aabb

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

에 할당하고 무슨 일이 일어 나는지되는 라인의 끝에 세미콜론 (즉;)를 넣어보십시오.

나중에 aa도 아니고 bb도 프로그램에서 나중에 사용 된 것 같지 않으므로 두 줄을 모두 안전하게 삭제할 수 있습니다.

+0

나는 이것이 출력의 억제에 의한 것만 큼 복잡하고 복잡한 숫자가 전혀없는 것 같다. – tmpearce

+0

나는 특정 출력을 억제하지 않기 위해 세미콜론을 의도적으로 사용하지 않았다. 나는 "변수 bb"의 출력이 어디서 오는 것인지 혼란 스럽다. 입력과 입력 사이에는 상관 관계가 없다. –