Main Content

splitEachLabel

비율을 기준으로 ImageDatastore 레이블 분할

설명

예제

[imds1,imds2] = splitEachLabel(imds,p)imds의 이미지 파일을 2개의 새 데이터저장소인 imds1imds2로 분할합니다. 새 데이터저장소 imds1에는 각 레이블에서 첫 번째 p개 또는 p 비율에 해당하는 파일이 포함되고 imds2에는 각 레이블의 나머지 파일이 포함됩니다. p는 각 레이블에서 imds1에 할당할 파일의 비율을 나타내는 0과 1 사이의 숫자일 수도 있고, 각 레이블에서 imds1에 할당할 파일의 절대 개수를 나타내는 정수일 수도 있습니다.

예제

[imds1,...,imdsM] = splitEachLabel(imds,p1,...,pN)은 데이터저장소를 N+1개의 새 데이터저장소로 분할합니다. 첫 번째 새 데이터저장소인 imds1에는 각 레이블에서 첫 번째 p1개 또는 p1 비율에 해당하는 파일이 포함되고 그다음 새 데이터저장소인 imds2에는 그다음 p2개 또는 p2 비율에 해당하는 파일이 포함되는 식입니다. p1,...,pN이 파일 개수를 나타내는 경우 이들의 합은 원래 데이터저장소 imds에서 가장 작은 레이블에 포함된 파일의 개수보다 크지 않아야 합니다.

예제

___ = splitEachLabel(___,'randomized')는 각 레이블에서 지정된 비율에 해당하는 파일을 새 데이터저장소에 무작위로 할당합니다.

예제

___ = splitEachLabel(___,Name,Value)는 하나 이상의 이름-값 쌍의 인수를 사용하여 새 데이터저장소의 속성을 지정합니다. 예를 들어, 'Include','labelname'을 사용하여 분할할 레이블을 지정할 수 있습니다.

예제

모두 축소

ImageDatastore 객체를 만들고 이 객체가 포함되는 폴더의 이름에 따라 각 이미지의 레이블을 지정합니다. 결과로 생성되는 레이블 이름은 demosimagesci입니다.

imds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),...
'LabelSource', 'foldernames', 'FileExtensions', {'.jpg', '.png', '.tif'});

imds.Labels
ans = 

     demos 
     demos 
     demos 
     demos 
     demos 
     demos 
     imagesci 
     imagesci 

imds의 파일에서 2개의 새 데이터저장소를 만듭니다. 첫 번째 데이터저장소인 imds60에는 demos 레이블이 지정된 파일 중 처음 60%에 해당하는 파일과 imagesci 레이블이 지정된 파일 중 처음 60%에 해당하는 파일이 포함됩니다. 두 번째 데이터저장소인 imds40에는 각 레이블에서 나머지 40%에 해당하는 파일이 포함됩니다. 레이블에 적용되는 비율의 결과가 파일의 정수 개수를 나타내지 않는 경우 splitEachLabel은 가장 가까운 정수로 버림합니다.

[imds60,imds40] = splitEachLabel(imds,0.6)
imds60 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\cloudCombined.jpg';
             ' ...\matlab\toolbox\matlab\demos\example.tif';
             ' ...\matlab\toolbox\matlab\demos\landOcean.jpg'
              ... and 2 more
             }
     Labels: [demos; demos; demos ... and 2 more categorical]
    ReadFcn: @readDatastoreImage


imds40 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\street1.jpg';
             ' ...\matlab\toolbox\matlab\demos\street2.jpg';
             ' ...\matlab\toolbox\matlab\imagesci\peppers.png'
             }
     Labels: [demos; demos; imagesci]
    ReadFcn: @readDatastoreImage

ImageDatastore 객체를 만들고 이 객체가 포함되는 폴더의 이름에 따라 각 이미지의 레이블을 지정합니다. 결과로 생성되는 레이블 이름은 demosimagesci입니다.

imds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),...
'LabelSource', 'foldernames', 'FileExtensions', {'.jpg', '.png', '.tif'});

imds.Labels
ans = 

     demos 
     demos 
     demos 
     demos 
     demos 
     demos 
     imagesci 
     imagesci 

imds의 파일에서 2개의 새 데이터저장소를 만듭니다. 첫 번째 데이터저장소인 imds1에는 demos 레이블이 지정된 첫 번째 파일과 imagesci 레이블이 지정된 첫 번째 파일이 포함됩니다. 두 번째 데이터저장소인 imds2에는 각 레이블의 나머지 파일이 포함됩니다.

[imds1,imds2] = splitEachLabel(imds,1)
imds1 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\cloudCombined.jpg';
             ' ...\matlab\toolbox\matlab\imagesci\corn.tif'
             }
     Labels: [demos; imagesci]
    ReadFcn: @readDatastoreImage


imds2 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\example.tif';
             ' ...\matlab\toolbox\matlab\demos\landOcean.jpg';
             ' ...\matlab\toolbox\matlab\demos\ngc6543a.jpg'
              ... and 3 more
             }
     Labels: [demos; demos; demos ... and 3 more categorical]
    ReadFcn: @readDatastoreImage

ImageDatastore 객체를 만들고 이 객체가 포함되는 폴더의 이름에 따라 각 이미지의 레이블을 지정합니다. 결과로 생성되는 레이블 이름은 demosimagesci입니다.

imds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),...
'LabelSource', 'foldernames', 'FileExtensions', {'.jpg', '.png', '.tif'});

imds.Labels
ans = 

     demos 
     demos 
     demos 
     demos 
     demos 
     demos 
     imagesci 
     imagesci 

imds의 파일에서 3개의 새 데이터저장소를 만듭니다. 첫 번째 데이터저장소인 imds60에는 demos 레이블이 지정된 파일 중 처음 60%에 해당하는 파일과 imagesci 레이블이 지정된 파일 중 처음 60%에 해당하는 파일이 포함됩니다. 두 번째 데이터저장소인 imds10에는 각 레이블에서 다음 10%에 해당하는 파일이 포함됩니다. 세 번째 데이터저장소인 imds30에는 각 레이블에서 나머지 30%에 해당하는 파일이 포함됩니다. 레이블에 적용되는 비율의 결과가 파일의 정수 개수를 나타내지 않는 경우 splitEachLabel은 가장 가까운 정수로 버림합니다.

[imds60, imds10, imds30] = splitEachLabel(imds,0.6,0.1)
imds60 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\cloudCombined.jpg';
             ' ...\matlab\toolbox\matlab\demos\example.tif';
             ' ...\matlab\toolbox\matlab\demos\landOcean.jpg'
              ... and 2 more
             }
     Labels: [demos; demos; demos ... and 2 more categorical]
    ReadFcn: @readDatastoreImage


imds10 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\street1.jpg'
             }
     Labels: demos
    ReadFcn: @readDatastoreImage


imds30 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\street2.jpg';
             ' ...\matlab\toolbox\matlab\imagesci\peppers.png'
             }
     Labels: [demos; imagesci]
    ReadFcn: @readDatastoreImage

ImageDatastore 객체를 만들고 이 객체가 포함되는 폴더의 이름에 따라 각 이미지의 레이블을 지정합니다. 결과로 생성되는 레이블 이름은 demosimagesci입니다.

imds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),...
'LabelSource', 'foldernames', 'FileExtensions', {'.jpg', '.png', '.tif'});

imds.Labels
ans = 

     demos 
     demos 
     demos 
     demos 
     demos 
     demos 
     imagesci 
     imagesci 

imds의 파일에서 3개의 새 데이터저장소를 만듭니다. 첫 번째 데이터저장소인 imds1에는 demos 레이블이 지정된 첫 번째 파일과 imagesci 레이블이 지정된 첫 번째 파일이 포함됩니다. 두 번째 데이터저장소인 imds2에는 각 레이블에서 다음 파일이 포함됩니다. 세 번째 데이터저장소인 imds3에는 각 레이블의 나머지 파일이 포함됩니다.

[imds1, imds2, imds3] = splitEachLabel(imds,1,1)
imds1 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\cloudCombined.jpg';
             ' ...\matlab\toolbox\matlab\imagesci\corn.tif'
             }
     Labels: [demos; imagesci]
    ReadFcn: @readDatastoreImage


imds2 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\example.tif';
             ' ...\matlab\toolbox\matlab\imagesci\peppers.png'
             }
     Labels: [demos; imagesci]
    ReadFcn: @readDatastoreImage


imds3 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\landOcean.jpg';
             ' ...\matlab\toolbox\matlab\demos\ngc6543a.jpg';
             ' ...\matlab\toolbox\matlab\demos\street1.jpg'
              ... and 1 more
             }
     Labels: [demos; demos; demos ... and 1 more categorical]
    ReadFcn: @readDatastoreImage

ImageDatastore 객체를 만들고 이 객체가 포함되는 폴더의 이름에 따라 각 이미지의 레이블을 지정합니다. 결과로 생성되는 레이블 이름은 demosimagesci입니다.

imds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),...
'LabelSource', 'foldernames', 'FileExtensions', {'.jpg', '.png', '.tif'});

imds.Labels
ans = 

     demos 
     demos 
     demos 
     demos 
     demos 
     demos 
     imagesci 
     imagesci 

각 레이블에서 무작위로 도출하는 방법으로 imds의 파일에서 2개의 새 데이터저장소를 만듭니다. 첫 번째 데이터저장소인 imds1에는 demos 레이블이 지정된 파일 중 무작위로 선택된 파일 하나와 imagesci 레이블이 지정된 파일 중 무작위로 선택된 파일 하나가 포함됩니다. 두 번째 데이터저장소인 imds2에는 각 레이블의 나머지 파일이 포함됩니다.

[imds1, imds2] = splitEachLabel(imds,1,'randomized')
imds1 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\street2.jpg';
             ' ...\matlab\toolbox\matlab\imagesci\corn.tif'
             }
     Labels: [demos; imagesci]
    ReadFcn: @readDatastoreImage


imds2 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\cloudCombined.jpg';
             ' ...\matlab\toolbox\matlab\demos\example.tif';
             ' ...\matlab\toolbox\matlab\demos\landOcean.jpg'
              ... and 3 more
             }
     Labels: [demos; demos; demos ... and 3 more categorical]
    ReadFcn: @readDatastoreImage

ImageDatastore 객체를 만들고 이 객체가 포함되는 폴더의 이름에 따라 각 이미지의 레이블을 지정합니다. 결과로 생성되는 레이블 이름은 demosimagesci입니다.

imds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),...
'LabelSource', 'foldernames', 'FileExtensions', {'.jpg', '.png', '.tif'});

imds.Labels
ans = 

     demos 
     demos 
     demos 
     demos 
     demos 
     demos 
     imagesci 
     imagesci 

imds의 파일에서 demos 레이블이 지정된 파일만 포함하는 2개의 새 데이터저장소를 만듭니다. 첫 번째 데이터저장소인 imds60에는 demos 레이블이 지정된 파일 중 처음 60%에 해당하는 파일이 포함되고 두 번째 데이터저장소인 imds40에는 demos 레이블이 지정된 파일 중 나머지 40%에 해당하는 파일이 포함됩니다.

[imds60, imds40] = splitEachLabel(imds,0.6,'Include','demos')
imds60 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\cloudCombined.jpg';
             ' ...\matlab\toolbox\matlab\demos\example.tif';
             ' ...\matlab\toolbox\matlab\demos\landOcean.jpg'
              ... and 1 more
             }
     Labels: [demos; demos; demos ... and 1 more categorical]
    ReadFcn: @readDatastoreImage


imds40 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\street1.jpg';
             ' ...\matlab\toolbox\matlab\demos\street2.jpg'
             }
     Labels: [demos; demos]
    ReadFcn: @readDatastoreImage

또는 imagesci 레이블을 제외시켜 demos 레이블만 분할할 수도 있습니다.

[imds60, imds40] = splitEachLabel(imds,0.6,'Exclude','imagesci')
imds60 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\cloudCombined.jpg';
             ' ...\matlab\toolbox\matlab\demos\example.tif';
             ' ...\matlab\toolbox\matlab\demos\landOcean.jpg'
              ... and 1 more
             }
     Labels: [demos; demos; demos ... and 1 more categorical]
    ReadFcn: @readDatastoreImage


imds40 = 

  ImageDatastore with properties:

      Files: {
             ' ...\matlab\toolbox\matlab\demos\street1.jpg';
             ' ...\matlab\toolbox\matlab\demos\street2.jpg'
             }
     Labels: [demos; demos]
    ReadFcn: @readDatastoreImage

입력 인수

모두 축소

입력 데이터저장소로, ImageDatastore 객체로 지정됩니다. 이미지 데이터에서 ImageDatstore를 생성하려면 imageDatastore 함수를 사용하십시오.

분할할 파일의 비율로, 구간 (0,1) 내 스칼라나 양의 정수 스칼라로 지정됩니다.

  • p가 구간 (0,1) 내에 있는 경우 각 레이블에서 imds1에 할당할 파일의 비율을 나타냅니다. p가 파일의 정수 개수를 반환하지 않는 경우 splitEachLabel은 가장 가까운 정수로 버림합니다.

  • p가 정수인 경우 각 레이블에서 imds1에 할당할 파일의 절대 개수를 나타냅니다. 각 레이블마다 연결된 파일이 p개 이상 있어야 합니다.

데이터형: double

비율 목록으로, 구간 (0,1) 내 스칼라이거나 양의 정수 스칼라로 지정됩니다. 비율이 구간 (0,1) 내에 있는 경우 각 레이블에서 출력 데이터저장소에 할당할 파일의 비율을 나타냅니다. 비율이 정수인 경우 각 레이블에서 출력 데이터저장소에 할당할 파일의 절대 개수를 나타냅니다. 비율이 백분율을 나타내는 경우 비율의 합은 1보다 크지 않아야 합니다. 비율이 파일의 개수를 나타내는 경우 각 비율이 충족되도록 충분한 개수의 파일이 각 레이블에 연결되어 있어야 합니다.

데이터형: double

이름-값 인수

선택적 인수 쌍을 Name1=Value1,...,NameN=ValueN으로 지정합니다. 여기서 Name은 인수 이름이고 Value는 대응값입니다. 이름-값 인수는 다른 인수 뒤에 와야 하지만, 인수 쌍의 순서는 상관없습니다.

R2021a 이전 릴리스에서는 쉼표를 사용하여 각 이름과 값을 구분하고 Name을 따옴표로 묶으십시오.

예: [imds1 imds2] = splitEachLabel(imds,0.5,'Exclude','demos')

포함시킬 레이블로, 'Include'와 함께 Labels 속성과 동일한 유형의 레이블 이름으로 구성된 셀형 배열, string형 배열이나 벡터가 쉼표로 구분되어 지정됩니다. 각 이름은 데이터저장소의 Labels 속성에 포함된 레이블 중 하나와 일치해야 합니다.

데이터형: char | cell | string

제외시킬 레이블로, 'Exclude'와 함께 Labels 속성과 동일한 유형의 레이블 이름으로 구성된 셀형 배열, string형 배열이나 벡터가 쉼표로 구분되어 지정됩니다. 각 이름은 데이터저장소와 연결된 레이블을 지정하고 Labels의 이름과 일치해야 합니다. 이 옵션은 'Include' 옵션과 함께 사용할 수 없습니다.

데이터형: char | cell | string

출력 인수

모두 축소

출력 데이터저장소로, ImageDatastore 객체로 반환됩니다. imds1에는 imds에 포함된 각 레이블에서 지정된 비율에 해당하는 파일이 포함되고 imds2에는 나머지 파일이 포함됩니다.

출력 데이터저장소 목록으로, ImageDatastore 객체로 반환됩니다. 목록에 포함된 요소 개수는 나열된 비율 개수보다 하나 더 많습니다. 각각의 새 데이터저장소에는 imds의 각 레이블에서 p1,...,pN로 정의된 비율만큼 포함됩니다. 나머지 파일은 M번째 데이터저장소에 모두 할당됩니다.

확장 기능

버전 내역

R2016a에 개발됨