首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Matlab与复数计算

Matlab与复数计算
EN

Stack Overflow用户
提问于 2013-07-30 02:46:44
回答 1查看 419关注 0票数 1

我目前正在用matlab编写一个代码来分析心脏中的光流,由于某种原因,每当我运行它时,它都会返回奇怪的复杂函数。我不确定它们是从哪里来的,我希望能得到一些帮助来弄清楚这一点。

代码语言:javascript
复制
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

它返回:

代码语言:javascript
复制
aa =

        1080        1920


bb =

       36465           4

bb中的变量从何而来?

谢谢,雅各布

EN

回答 1

Stack Overflow用户

发布于 2013-07-30 06:38:22

尝试将分号(即;)放在指定了aabb的行的末尾

代码语言:javascript
复制
aa = size(of);
...
bb = size(lines);

看看会发生什么。

请注意,由于aabb似乎都没有在程序的后面使用,您可能可以安全地删除这两行。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17931810

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档