MATLAB - video processing

◇◆丶佛笑我妖孽 提交于 2019-12-13 08:04:58

问题


The code is for video processing in MATLAB and I have a problem in the first loop. I do not know what the problem is but the error that MATLAB gives is :

Assignment has more non-singleton rhs dimensions than non-singleton subscripts

Error in fi (line 34)

data(:,:,f) = I;

Here is my code:

clc;
close all;
clear all;

It1c = imread( '\\icnas1.cc.ic.ac.uk\fi15\Desktop\frames\Frames_V11\051.png' );
It600c = imread( '\\icnas1.cc.ic.ac.uk\fi15\Desktop\frames\Frames_V11\009.png' );

resf = 0.27e-6;
fr_r = 12000; %frame rate = 12000 fps

figure();
imagesc(It1c);

figure();
imagesc(It600c);

listing = dir('\\icnas1.cc.ic.ac.uk\fi15\Desktop\frames\Frames_V11\*.png');
N = 51;
data = zeros(624,1024,N);

for f = 1:N,
    f

    I = imread(['Frames_V11\',fullfile(listing(f).name)] );
    data(:,:,f) = I;    
end

figure; %see frames
for i = 1:N,
    imagesc(data(:,:,i));
    colorbar;
    pause(0.1);
end

figure; %see frames
for i = 1:N,
    imagesc(data(:,:,i)-data(:,:,1));
    colorbar;
    pause(0.1);
end

for i = 1:N,
    i
    data2(:,:,i) = data(:,:,i)-data(i);
end

figure; %see frames
for i = 1:N,
    imagesc(data2(:,:,i));
    colorbar;
    pause(0.1);
end

figure;
imagesc(squeeze( mean(data2(230:270,:,:),1) ));

figure;
plot(squeeze(mean(mean(data5(210:235,395:425,:),1),2)));

回答1:


Your image data is likely RGB and therefore has the following dimensions [nRows, nCols, nChannels] where nChannels is likely 3. The error is because you're trying to assign this 3D matrix to a 2D slice in data.

You need to therefore concatenate all of the images along the fourth dimension instead of the third.

data = zeros(624, 1024, 3, N);

for f = 1:N
    data(:,:,:,f) = imread(['Frames_V11\',fullfile(listing(f).name)]);
end


来源:https://stackoverflow.com/questions/39044182/matlab-video-processing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!