clear all
close all
reader = VideoReader('shahar_jack.avi');
vid = {};
while hasFrame(reader)
vid{end+1} = im2single(readFrame(reader));
end
bg = mean( cat(4, vid{:}), 4);
fIdx = 1;
fg1 = sum( abs( vid{fIdx} - bg ), 3 ) > 0.25;
fg2 = imresize(fg1, 0.5);
figure;
subplot(141); imshow( bg );
subplot(142); imshow( vid{fIdx} );
subplot(143); imshow( fg2 );
clc;
close all;
imtool close all;
clear;
workspace;
fontSize = 14;
grayImage = peaks(200);
imshow(grayImage, []);
subplot(2,2,1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
axis on;
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
binaryImage = grayImage > 5;
subplot(2,2,2);
imshow(binaryImage, []);
title('Binary Image', 'FontSize', fontSize);
axis on;
measurements = regionprops(binaryImage, 'Centroid')
[rows columns] = size(binaryImage);
rowsToShift = round(rows/2- measurements.Centroid(2))
columnsToShift = round(columns/2 - measurements.Centroid(1))
shiftedImage = circshift(binaryImage, [rowsToShift columnsToShift]);
subplot(2,2,3);
imshow(shiftedImage, []);
title('Shifted Binary Image', 'FontSize', fontSize);
axis on;