Changing file save name
1 次查看(过去 30 天)
显示 更早的评论
I have 10 images (collages), within each image there is anywhere from 20-200 smaller images. In total there are 3000 images between all 10 images.
Currently my code crops the small images from the collages and I know have 3000 images. When I save each of the small cropped image is saves it like... NAME%collage1%001, NAME%collage1%002,...,NAME%collage10%200.
I would like to save each of the small cropped images as... NAME%001, NAME%002,..., NAME%3000.
sum_blob = sum(numberOfBlobs) % I use this to get the sum of the number of blobs on each of the 10 collage images
message = sprintf('Would you like to crop out and save each individual images?');
reply = questdlg(message, 'Extract Individual Images?', 'Yes', 'No', 'Yes');
% Note: reply will = '' for Upper right X, 'Yes' for Yes, and 'No' for No.
if strcmpi(reply, 'Yes')
for n = 1 : non_binary_images
for k = 1 : numberOfBlobs(n) % Loop through all blobs.
% Find the bounding box of each blob.
thisBlobsBoundingBox = blobMeasurements{n}(k).BoundingBox; % Get list of pixels in current blob.
% Extract out this zoop into it's own image.
subImage = imcrop(OG_images{n}, thisBlobsBoundingBox);
% Saving the cropped image
folder = 'folder';
thisBaseFileName = sprintf('NAME%4d_%03d%.tif', n, k);
thisFullFileName = fullfile(folder, thisBaseFileName);
imwrite(subImage, thisFullFileName,'tif');
end
end
end
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Import, Export, and Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!