I have good knowledge of matlab but new to python. Can you please help me to read few lines of matlab to python? My code is below and I mention too detailed all the data. I am ready to pay for if someone can help me within short notice also. Thank you all.
close all
clear all
clc
%% Read image sequence
path2sequence = 'sequence';
search_string = fullfile(path2sequence, '*.jpeg');
file_list = dir(search_string);
%% Sequencial estimation of the gaussians parameters
% TODO: Learning rate
alpha = 1/50;
% Initial values
im_RGB = imread(fullfile(path2sequence, file_list(1).name));
[m,n] = size(rgb2gray(im_RGB));
mu = single(rgb2gray(im_RGB));
sigma_square = ones(m,n)*100;
% Structure element for morphological operation
se = strel('square',3);
h1 = figure(1);
colormap(gray);
dim = [0 0 1 1];%[0.262499999999998,0.002380951174668,0.480357129073569,0.06428571307943];
txt = [sprintf('Learning Rate: % .2f, Number of Frames: % .2f' ,alpha,inv(alpha))];
ui = annotation('textbox',dim,'String',txt,'FitBoxToText','on','verticalalignment', 'bottom');
% Iterate over the sequence
for i = 2:length(file_list)
im_RGB = imread(fullfile(path2sequence, file_list(i).name));
im = single(rgb2gray(im_RGB));
% TODO: Thresholding for background subtraction
%variance is used as a local threshold
delta_g = abs(im-mu);
%background and foreground pixels are initialized with as 1
mask_back = ones(m,n); %-> background pixels are 1, foreground pixels are set to 0
mask_back(delta_g > 2.5*sqrt(sigma_square)) = 0; % setting foreground to 1 using the threshold
mask_back = logical(mask_back); %convert to type "logical"
% Eliminate noise
% TODO: Closing using structure element "se"
filtered_mask = imclose(mask_back,se);
% Update Gaussian parameters
% TODO: Mean
mu = (alpha * im) + ((1-alpha)*mu); %updating the mean
% TODO: Variance
sigma_square = (alpha * (mu - im).^2) + (1-alpha) * sigma_square; %updating the variance
% Output
subplot(231);
imagesc(im, [0 255]); % TODO: Show input image
title('Input Image')
subplot(232);
imagesc(mu, [0 255]); % TODO: Show mean values
title('Mean Image')
subplot(233);
imagesc(sigma_square, [0 255]); % TODO: Show variances
title('Variance Image')
subplot(234);
imagesc(delta_g, [0 255]); % TODO: Show difference between current image and mean values
title('Delta_G Image')
subplot(235);
imagesc(mask_back, [0 1]); % TODO: Show background mask (unfiltered)
title('Unfiltered Image')
subplot(236);
imagesc(filtered_mask, [0 1]); % TODO: Show background mask after eliminating noise
title('Filtered Image')
drawnow;
% txt = [sprintf('Frame No.: % .2f' ,i)];
txt = [strcat("Frame Number",int2str(i))];
box = annotation('textbox',dim,'String',txt,'FitBoxToText','on');
pause(0.00000000001);
delete(box)
end