フィルターのクリア

Error in reading image files from folder before cropping them

2 ビュー (過去 30 日間)
Nidhi Chakravarthy
Nidhi Chakravarthy 2021 年 5 月 18 日
回答済み: Walter Roberson 2021 年 5 月 18 日
Hi
i am getting an error while reading the image(.png) files from folder before cropping it.
code:
imageDir = ('/Users/apple/Documents/MSCPROJ/database/savedimages/*.ng');
ssss = imageSet(imageDir);
for k = 5 : ssss.Count
theImage = imread(ssss);
croppedImage = imcrop(theImage,[646, 1291, 481, 600]);
baseFileName = sprintf('Image #%d.png', k);
fullFileName = fullfile(imageDir, baseFileName);
imwrite(croppedImage, fullFileName);
end
Errors:
>> cropimage
Error using imageSet/parseDirInput (line 131)
Input, imageLocation, must be a valid folder name or a cell array of image file locations.
Error in imageSet/parseInput (line 101)
this = this.parseDirInput(varargin{:});

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 5 月 18 日
You cannot specify a wildcard when using imageSet() . You can only specify a directory name, or an exact list of files. If you specify the directory name, you have no control over the file extension.
imageSet() is not recommended; imageDatastore is recommended instead. imageDatastore has a 'FileExtensions' option that permits you to specify the file extensions.

Community Treasure Hunt

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

Start Hunting!

Translated by