def _read_openjpeg(self, rlevel=<NUM_LIT:0>, verbose=False, area=None):
self._subsampling_sanity_check()<EOL>self._populate_dparams(rlevel)<EOL>with ExitStack() as stack:<EOL><INDENT>try:<EOL><INDENT>self._dparams.decod_format = self._codec_format<EOL>dinfo = opj.create_decompress(self._dparams.decod_format)<EOL>event_mgr = opj.EventMgrType()<EOL>handler = ctypes.cast(_INFO_CALLBACK, ctypes.c_void_p)<EOL>event_mgr.info_handler = handler if self.verbose else None<EOL>event_mgr.warning_handler = ctypes.cast(_WARNING_CALLBACK,<EOL>ctypes.c_void_p)<EOL>event_mgr.error_handler = ctypes.cast(_ERROR_CALLBACK,<EOL>ctypes.c_void_p)<EOL>opj.set_event_mgr(dinfo, ctypes.byref(event_mgr))<EOL>opj.setup_decoder(dinfo, self._dparams)<EOL>with open(self.filename, '<STR_LIT:rb>') as fptr:<EOL><INDENT>src = fptr.read()<EOL><DEDENT>cio = opj.cio_open(dinfo, src)<EOL>raw_image = opj.decode(dinfo, cio)<EOL>stack.callback(opj.image_destroy, raw_image)<EOL>stack.callback(opj.destroy_decompress, dinfo)<EOL>stack.callback(opj.cio_close, cio)<EOL>image = self._extract_image(raw_image)<EOL><DEDENT>except ValueError:<EOL><INDENT>opj2.check_error(<NUM_LIT:0>)<EOL><DEDENT><DEDENT>if area is not None:<EOL><INDENT>x0, y0, x1, y1 = area<EOL>extent = <NUM_LIT:2> ** rlevel<EOL>area = [int(round(float(x) / extent + <NUM_LIT:2> ** -<NUM_LIT:20>)) for x in area]<EOL>rows = slice(area[<NUM_LIT:0>], area[<NUM_LIT:2>], None)<EOL>cols = slice(area[<NUM_LIT:1>], area[<NUM_LIT:3>], None)<EOL>image = image[rows, cols]<EOL><DEDENT>return image<EOL>
Read a JPEG 2000 image using libopenjpeg.

        Parameters
        ----------
        rlevel : int, optional
            Factor by which to rlevel output resolution.  Use -1 to get the
            lowest resolution thumbnail.
        verbose : bool, optional
            Print informational messages produced by the OpenJPEG library.
        area : tuple, optional
            Specifies decoding image area,
            (first_row, first_col, last_row, last_col)

        Returns
        -------
        ndarray
            The image data.

        Raises
        ------
        RuntimeError
            If the image has differing subsample factors.