Background Subtraction In Images:
Show older comments
Dear all,
I had written a code which was constructing A background image from a given set of images and then subtracting it so as to remove noise. Now it was working perfectly on my macbook, but when I'm trying to run on windows it's giving me an error.

I'm using sprintf to keep the length of the string constant. like img_00001, img_0002, ....., img_00011, ... img00100, .... etc. This insures that images are properly ordered. Can anyone help me out in figuring, what's the error here. Why it is not working on windows when it was working on MACos.
Thanks,
Matlab Code:
%% Creating And Subtracting a Background Image:
clc ; close all ; clear ;
%%
% Get the names of files to be Imported:
% Directory for importing the images:
import_directory = uigetdir('Locate Folder for Input Images') ;
image_extension = '*.tif' ;
direc = dir([import_directory , filesep , image_extension] ) ;
filenames = {} ;
[filenames{1:numel(direc) , 1}] = deal(direc.name) ;
filenames = sortrows(filenames) ;
num_of_images = length(filenames) ;
%% Preallocating Space for Images:
pj = uint16(zeros(size(imread([import_directory , filesep , filenames{1}])))) ;
% Select Directory For Exporting the Images:
export_directory = uigetdir('Locate Folder for Output Images') ;
tic
for i = 1:num_of_images
name2 = sprintf([export_directory , filesep , 'Background_Subtracted_Output_File_%6.6i.tif'] , i) ;
imwrite(pj , name2) ;
end
t(1) = to
1 Comment
abhimanyu dubey
on 23 Nov 2020
Accepted Answer
More Answers (0)
Categories
Find more on Image Preview and Device Configuration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!