フィルターのクリア

How can i crop images from multiple folders that are located under one main folder to a specific size before i feed it through a CNN?

1 回表示 (過去 30 日間)
categories = {'Cardiomegaly','Infiltration', 'No Finding'};
rootFolder = 'C:\Users\roro\Downloads\Data';
imds = imageDatastore(fullfile(rootFolder, categories), ...
'LabelSource', 'foldernames');

採用された回答

Raunak Gupta
Raunak Gupta 2020 年 6 月 24 日
Hi,
You can use augmentedImageDatastore to augment the images read by imageDatastore. The cropping function can be achieved using the OutputSizeMode as centercrop’. You may ‘randcrop’ also if you want cropping to be random instead of focusing at center. Below code might help.
rootFolder = 'C:\Users\roro\Downloads\Data';
imds = imageDatastore(fullfile(rootFolder, categories), ...
'LabelSource', 'foldernames');
% imageSize must be defined according to the final cropped image size
imageSize = [28 28 1];
augimds = augmentedImageDatastore(imageSize,imds,'OutputSizeMode','centercrop');
augimds can then feed to CNN instead of imds.
  3 件のコメント
sania urooj
sania urooj 2021 年 2 月 12 日
Hey ! can you please tell me how to read mat files with folder label instead of images?
sania urooj
sania urooj 2021 年 2 月 12 日
I am merging mat files using the given code but need to concentenate labels into a single file. kindly help.
D = 'D:folder\"
S = dir(fullfile(D,'*.mat'));
for k = 1:numel(S)
F = fullfile(D,S(k).name);
C = struct2cell(load(F));
S(k).data = C{1};
end
M = vertcat(S.data);
save(fullfile(D,'merged.mat'),'M')

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePreprocess Data for Deep Neural Networks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by