{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Note that files are always returned in alphanumerical order. Also note that slicing returns a new "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "skimage.io.ImageCollection",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "skimage",
                "version": "*",
                "kind": "api",
                "path": "skimage.io.collection:ImageCollection"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "not"
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " a view into the data."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "ImageCollection image loading can be customized through "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "load_func"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". For an ImageCollection "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "ic"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "ic[5]"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " calls "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "load_func(load_pattern[5])"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " to load that image."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "For example, here is an ImageCollection that, for each video provided, loads every second frame    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "import imageio.v3 as iio3\nimport itertools\n\ndef vidread_step(f, step):\n    vid = iio3.imiter(f)\n    return list(itertools.islice(vid, None, None, step)\n\nvideo_file = 'no_time_for_that_tiny.gif'\nic = ImageCollection(video_file, load_func=vidread_step, step=2)\n\nic  # is an ImageCollection object of length 1 because 1 video is provided\n\nx = ic[0]\nx[5]  # the 10th frame of the first video",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Alternatively, if "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "load_func"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is provided and "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "load_pattern"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is a sequence, an "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "skimage.io.ImageCollection",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "skimage",
                "version": "*",
                "kind": "api",
                "path": "skimage.io.collection:ImageCollection"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of corresponding length will be created, and the individual images will be loaded by calling "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "load_func"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " with the matching element of the "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "load_pattern"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " as its first argument. In this case, the elements of the sequence do not need to be names of existing files (or strings at all). For example, to create an "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "skimage.io.ImageCollection",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "skimage",
                "version": "*",
                "kind": "api",
                "path": "skimage.io.collection:ImageCollection"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " containing 500 images from a video    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "class FrameReader:\n    def __init__ (self, f):\n        self.f = f\n    def __call__ (self, index):\n        return iio3.imread(self.f, index=index)\n\nic = ImageCollection(range(500), load_func=FrameReader('movie.mp4'))\n\nic  # is an ImageCollection object of length 500",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Another use of "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "load_func"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " would be to convert all images to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "uint8"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "    "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "def imread_convert(f):\n    return imread(f).astype(np.uint8)\n\nic = ImageCollection('/tmp/*.png', load_func=imread_convert)",
          "execution_status": null
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Load and manage a collection of image files."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "files",
              "annotation": "list of str",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If a pattern string is given for "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "load_pattern"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", this attribute stores the expanded file list. Otherwise, this is equal to "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "load_pattern"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "load_pattern",
              "annotation": "str or list of str",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Pattern string or list of strings to load. The filename path can be absolute or relative."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "conserve_memory",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If True, "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "skimage.io.ImageCollection",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "skimage",
                        "version": "*",
                        "kind": "api",
                        "path": "skimage.io.collection:ImageCollection"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " does not keep more than one in memory at a specific time. Otherwise, images will be cached once they are loaded."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "load_func",
              "annotation": "callable",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "imread"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " by default. See Notes below."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "**load_func_kwargs",
              "annotation": "dict",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Any other keyword arguments are passed to "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "load_func"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Returns",
    "Yields",
    "Receives",
    "Raises",
    "Warns",
    "Other Parameters",
    "Attributes",
    "Methods",
    "Notes",
    "Warnings"
  ],
  "item_file": "/dev/scikit-image/src/skimage/io/collection.py",
  "item_line": 101,
  "item_type": "class",
  "aliases": [
    "skimage.io.ImageCollection"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import imageio.v3 as iio3\nimport skimage.io as io\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n# Where your images are located\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "data_dir = os.path.join(os.path.dirname(__file__), '../data')\n",
        "execution_status": "unexpected_exception"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "coll = io.ImageCollection(data_dir + '/chess*.png')\nlen(coll)\ncoll[0].shape\n",
        "execution_status": "unexpected_exception"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "image_col = io.ImageCollection([f'{data_dir}/*.png', '{data_dir}/*.jpg'])\n",
        "execution_status": "unexpected_exception"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "class MultiReader:\n    def __init__ (self, f):\n        self.f = f\n    def __call__ (self, index):\n        return iio3.imread(self.f, index=index)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "filename = data_dir + '/no_time_for_that_tiny.gif'\nic = io.ImageCollection(range(24), load_func=MultiReader(filename))\nlen(image_col)\nisinstance(ic[0], np.ndarray)\n",
        "execution_status": "unexpected_exception"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "load_pattern",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "conserve_memory",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "True"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "load_func",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "load_func_kwargs",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "VAR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "ImageCollection"
  },
  "references": null,
  "qa": "skimage.io.collection:ImageCollection",
  "arbitrary": [],
  "local_refs": [
    "**load_func_kwargs",
    "conserve_memory",
    "files",
    "load_func",
    "load_pattern"
  ]
}