MATLAB: Loop overwriting previous file

image processingimage segmentationMATLAB

Hi, I am trying to automate uncollaging collaged images. I have a folder with a bunch of collaged images that are already binary. When I run my loop and use regionprops it only ends up saving information for the last image in the folder… how do I fix this???
for n = 1:total_images_binary
binary_Images=fullfile(image_folder_binary, filenames_bin(n).name) ; % its will specify images names with full path and extension
our_images_binary = imread(binary_Images); % read images
labeledImage = bwlabel(our_images_binary,8); % Label each blob so we can make measurements of it
blobMeasurements = regionprops(labeledImage, our_images_binary, 'all');
numberOfBlobs = size(blobMeasurements, 1);
end

Best Answer

for n = 1:total_images_binary
binary_Images=fullfile(image_folder_binary, filenames_bin(n).name) ; % its will specify images names with full path and extension
our_images_binary = imread(binary_Images); % read images
labeledImage = bwlabel(our_images_binary,8); % Label each blob so we can make measurements of it
blobMeasurements = regionprops(labeledImage, our_images_binary, 'all');
numberOfBlobs(n) = size(blobMeasurements, 1);
end