Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

MATLAB - video processing

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.ukfi15DesktopframesFrames_V1151.png' );
It600c = imread( '\icnas1.cc.ic.ac.ukfi15DesktopframesFrames_V1109.png' );

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

figure();
imagesc(It1c);

figure();
imagesc(It600c);

listing = dir('\icnas1.cc.ic.ac.ukfi15DesktopframesFrames_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)));
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...