Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...