Showing posts with label Matlab. Show all posts
Showing posts with label Matlab. Show all posts

Thursday, December 22, 2022

Fore Ground Extraction and Back ground subtraction from video in Matlab




Gait recognition project Dataset

As i'm currently working on biometric gait recognition project so to complete that project i have to background subtraction to extract foreground from video.

i'm using CASIA data set videos for my experiments.
So background subtraction is the first thing to do in my project so when we have extracted human structure from video we easily perform our algorithms on it to identify its gait.


Matlab code for background subtraction using frame difference:

clc;              % clear command window
clear all;     % clear work space

% Reading video from computer directory
videoObject = VideoReader('001-bg-01-090.avi');

% Determine how many frames there are.
numberOfFrames = videoObject.NumberOfFrames;

% Loop through all frames
for frame = 1 : numberOfFrames

% Extract the frame from the movie structure.

img1 = read(videoObject, frame);
        img2 = read(videoObject, frame+10);

% In above we take two frame to subtract them from each other

% Subtract frames from each other
img3 =  imsubtract(img1,img2);

% Convert the subtracted result to rgb
  img4 = rgb2gray(img3);

% Apply sobel edge detection on rbg frame
  img5 = edge(img4,'Sobel');

% Use morphological approach to fill holes

d =  bwmorph(ege,'remove',1);
 e = imfill(d,'holes');

% And now save them one by one in hard-disk
        outputFolder = '\newdataset\chknew1';
       
       FileName = sprintf('img%.2d.png', frame);

outputFileName = fullfile(outputFolder, FileName);

imwrite(e, outputFileName, 'png');
        
        end


Wednesday, September 28, 2016

Simple Calculator using MATLAB

How to create Simple Calculator using MATLAB - Matlab for beginners

GUI Video is below the code 


function varargout = mycaltest(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @mycaltest_OpeningFcn, ...
                   'gui_OutputFcn',  @mycaltest_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
function mycaltest_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;

guidata(hObject, handles);


function varargout = mycaltest_OutputFcn(hObject, eventdata, handles) 
varargout{1} = handles.output;


function four_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'4');
set(handles.ans,'String',str);


function one_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'1');
set(handles.ans,'String',str);

function point_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'.');
set(handles.ans,'String',str);

function seven_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'7');
set(handles.ans,'String',str);

function zero_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'0');
set(handles.ans,'String',str);

function two_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'2');
set(handles.ans,'String',str);

function five_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'5');
set(handles.ans,'String',str);

function eight_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
% it will take the value of ans (ans is our static text
str = strcat(str,'8');
%it will concatinate 8 with the privues string
set(handles.ans,'String',str);
%and it will again set the new value to ans static text 

function equal_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
%it will take the value 
str = eval(str);
%the eval function solve the string or evalutae the string
set(handles.ans1,'String',str);
%after evaluation the ans was 
      %shown in the above static text ans1.

function three_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'3');
set(handles.ans,'String',str);

function six_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'6');
set(handles.ans,'String',str);

function nine_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'9');
set(handles.ans,'String',str);

function div_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'/');
set(handles.ans,'String',str);

function add_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'+');
set(handles.ans,'String',str);

function sub_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'-');
set(handles.ans,'String',str);

function mul_Callback(hObject, eventdata, handles)
str = get(handles.ans,'String');
str = strcat(str,'*');
set(handles.ans,'String',str);

function clear_Callback(hObject, eventdata, handles)
set(handles.ans1,'String','');
set(handles.ans,'String','');







Read Also: