Filter löschen
Filter löschen

Saving multiple cropped images to a different folder

2 Ansichten (letzte 30 Tage)
no zoop
no zoop am 26 Aug. 2019
Beantwortet: Image Analyst am 26 Aug. 2019
So I am new to matlab and having trouble using the imwrite() function. I uncollaged an image (137 seperate images) and want to save the individual images to a new folder. How do I use the imwrite() function to save all the cropped images? I was using this post ... https://www.mathworks.com/matlabcentral/answers/73719-uncollage-a-collage-image
Code...
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')
figure; % Create a new figure window.
% Maximize the figure window.
set(gcf, 'Units','Normalized','OuterPosition',[0 0 1 1]);
for k = 1 : numberOfBlobs % Loop through all blobs.
% Find the bounding box of each blob.
thisBlobsBoundingBox = blobMeasurements(k).BoundingBox; % Get list of pixels in current blob.
% Extract out this zoop into it's own image.
subImage = imcrop(originalImage, thisBlobsBoundingBox);
% Saving the cropped image
**imwrite(subImage,'path to folder') ?? **
end
end

Akzeptierte Antwort

Image Analyst
Image Analyst am 26 Aug. 2019
folder = 'c:/wherever';
thisBaseFileName = sprintf('Image %3.3d', k);
thisFullFileName = fullfile(folder, thisBaseFileName);
imwrite(subImage, thisFullFileName);

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by