Example #1
0
 def __init__(
         self, name: str,
         image_tilesets: MutableMapping[str, TileSet]
 ) -> None:
     self._images: MutableMapping[str, TileSet] = dict()
     self._name = name
     self.aligned_coordinate_groups: Dict[str, List[CropParameters]] = dict()
     for name, tileset in image_tilesets.items():
         self.aligned_coordinate_groups[name] = CropParameters.parse_coordinate_groups(tileset)
     self._images = image_tilesets
Example #2
0
    def from_url(cls,
                 url: str,
                 baseurl: Optional[str],
                 aligned_group: int = 0):
        """
        Constructs an ImageStack object from a URL and a base URL.

        The following examples will all load from the same location:

        - url: https://www.example.com/images/primary_images.json  baseurl: None
        - url: https://www.example.com/images/primary_images.json  baseurl: I_am_ignored
        - url: primary_images.json  baseurl: https://www.example.com/images
        - url: images/primary_images.json  baseurl: https://www.example.com

        Parameters
        ----------
        url : str
            Either an absolute URL or a relative URL referring to the image to be read.
        baseurl : Optional[str]
            If url is a relative URL, then this must be provided.  If url is an absolute URL, then
            this parameter is ignored.
        aligned_group: int
            Which aligned tile group to load into the Imagestack, only applies if the
            tileset is unaligned. Default 0 (the first group)

        Returns
        -------
        ImageStack :
            An ImageStack representing encapsulating the data from the TileSet.
        """
        config = StarfishConfig()
        tileset = Reader.parse_doc(url,
                                   baseurl,
                                   backend_config=config.slicedimage)
        coordinate_groups = CropParameters.parse_coordinate_groups(tileset)
        crop_params = coordinate_groups[aligned_group]
        return cls.from_tileset(tileset, crop_parameters=crop_params)