def _determine_colorspace(self, colorspace=None, **kwargs):
if colorspace is None:<EOL><INDENT>if len(self.shape) < <NUM_LIT:3>:<EOL><INDENT>self._colorspace = opj2.CLRSPC_GRAY<EOL><DEDENT>elif self.shape[<NUM_LIT:2>] == <NUM_LIT:1> or self.shape[<NUM_LIT:2>] == <NUM_LIT:2>:<EOL><INDENT>self._colorspace = opj2.CLRSPC_GRAY<EOL><DEDENT>else:<EOL><INDENT>self._colorspace = opj2.CLRSPC_SRGB<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if colorspace.lower() not in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>msg = '<STR_LIT>'.format(colorspace)<EOL>raise IOError(msg)<EOL><DEDENT>elif colorspace.lower() == '<STR_LIT>' and self.shape[<NUM_LIT:2>] < <NUM_LIT:3>:<EOL><INDENT>msg = '<STR_LIT>'<EOL>raise IOError(msg)<EOL><DEDENT>COLORSPACE_MAP = {'<STR_LIT>': opj2.CLRSPC_SRGB,<EOL>'<STR_LIT>': opj2.CLRSPC_GRAY,<EOL>'<STR_LIT>': opj2.CLRSPC_GRAY,<EOL>'<STR_LIT>': opj2.CLRSPC_YCC}<EOL>self._colorspace = COLORSPACE_MAP[colorspace.lower()]<EOL><DEDENT>
Determine the colorspace from the supplied inputs.

        Parameters
        ----------
        colorspace : str, optional
            Either 'rgb' or 'gray'.