我目前正在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
它返回:
aa =
1080 1920
bb =
36465 4
在哪里从BB变量从何而来?
感谢, 雅各
你是说变量'lines'有时很复杂,但它不应该是?在R2012b中查看'videooptflowlines'的内容(在命令窗口中编辑videooptflowlines'),我没有看到它如何返回复杂的值。 – horchler
据我所知,这个问题实际上与复数无关。我认为标题和标签应该进行编辑以反映这一点,但希望在进行编辑之前进一步澄清OP。 – tmpearce