Created
February 9, 2013 18:41
-
-
Save bkrajendra/4746511 to your computer and use it in GitHub Desktop.
MatLab BG removal By Rajendra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [outIm] = makeMask(bg, im, tol) | |
%bg - background image | |
%im - input image | |
%tol - tolerance | |
[h,w] = size(bg); | |
outIm = false(h, w); | |
for ch = 1:h | |
for cw = 1:w | |
imPix = im(ch,cw); | |
bgPix = bg(ch,cw); | |
if ((bgPix == imPix) || (bgPix > imPix && bgPix <= imPix + tol) || (bgPix < imPix && bgPix >= imPix - tol)) | |
outIm(ch, cw) = 0; | |
else | |
outIm(ch, cw) = 1; | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment