Ejemplo n.º 1
0
    def loadImage(self, filename):
        """
        Load and return the image referenced to by the filename.  In the
        default implementation this will try to load the image from a path
        relative to the label file's directory.
        """
        try:
            fileIsExist = True
            fullpath = self._fullpath(filename)
            # LOG.info(u"loadImage... filename = {} fullpath = {}".format(filename, fullpath))

            if not os.path.isfile(fullpath):
                LOG.warn("Image file %s does not exist." % fullpath)
                fileIsExist = False
                return None, fileIsExist

            if _use_pil:
                _fullpath = fullpath.encode('utf8')
                LOG.info(u"loadImage... Image.open({})".format(fullpath))
                im = Image.open(fullpath)
                imarr = np.asarray(im)
                return imarr, fileIsExist
            else:
                retcode = okapy.loadImage(fullpath)
                return retcode, fileIsExist
        except Exception as e:
            return None, False
Ejemplo n.º 2
0
    def loadImage(self, filename):
        """
        Load and return the image referenced to by the filename.  In the
        default implementation this will try to load the image from a path
        relative to the label file's directory.
        """
        fullpath = self._fullpath(filename)
        if not os.path.exists(fullpath):
            LOG.warn("Image file %s does not exist." % fullpath)
            return None

        if _use_pil:
            im = Image.open(fullpath)
            return np.asarray(im)
        else:
            return okapy.loadImage(fullpath)
Ejemplo n.º 3
0
    def loadImage(self, filename):
        """
        Load and return the image referenced to by the filename.  In the
        default implementation this will try to load the image from a path
        relative to the label file's directory.
        """
        fullpath = self._fullpath(filename)
        if not os.path.exists(fullpath):
            LOG.warn("Image file %s does not exist." % fullpath)
            return None

        if _use_pil:
            im = Image.open(fullpath)
            return np.asarray(im)
        else:
            return okapy.loadImage(fullpath)
Ejemplo n.º 4
0
    def loadImage(self, filename):
        """
        Load and return the image referenced to by the filename.  In the
        default implementation this will try to load the image from a path
        relative to the label file's directory.
        """
        fullpath = self._fullpath(filename)
        if not os.path.exists(fullpath):
            LOG.warn("Image file %s does not exist." % fullpath)
            return None

        if _use_pil:
            im = Image.open(fullpath)
            im = np.asarray(im)
            if im.shape[0] == 1080 and im.shape[1] == 1920:
                im = im[5:942, 596:1675, :].copy()
            return im
        else:
            return okapy.loadImage(fullpath)