I'm trying to make a script so that I can compare multiple frames to a background frame. My script is the following:
close all
clear all
clc
A=imread('background.jpg');
coords = [imread('*.jpg')];
numImages = size(coords,1);
images = cell(1,numImages);
data = cell(1, numImages);
for ii = 1 : numImages
images{ii} = imabsdiff(A,coords(ii,:));
end
for ii = 1 : numImages
E= im2bw(images{ii},0.1);
s = regionprops(E,'centroid');
data{ii} = reshape([s.Centroid],2,[]).';
end
for ii = 1 : numImages
csvwrite(sprintf('data%d.csv', ii), data{ii});
end
I'm trying to compare the images from coords
with A
and then convert them to binary images and get the regionprops into a .csv file. But it doesn't work like I want it to. imread
is failing.