def GFR_extract(path, quality="auto", rotations=32): if quality == "auto": try: p=subprocess.Popen("identify -format '%Q' "+path, \ stdout=subprocess.PIPE, shell=True) quality, err = p.communicate() status = p.wait() except: quality = 95 # suppoted qualities q = numpy.array([75, 85, 95]) params = { "rotations": rotations, "quality": q[numpy.argmin(numpy.abs(q - int(quality)))] } #print params im = Image.open(path) if im.mode in ['RGB', 'RGBA', 'RGBX']: params["channel"] = 1 C1 = _extract('GFR', path, params) params["channel"] = 2 C2 = _extract('GFR', path, params) params["channel"] = 3 C3 = _extract('GFR', path, params) X = numpy.hstack((C1, C2, C3)) return X else: return _extract('GFR', path, params)
def SRM_extract(path): im = Image.open(path) if im.mode in ['RGB', 'RGBA', 'RGBX']: C1 = _extract('SRM', path, params={"channel": 1}) C2 = _extract('SRM', path, params={"channel": 2}) C3 = _extract('SRM', path, params={"channel": 3}) X = numpy.hstack((C1, C2, C3)) return X else: return _extract('SRM', path)
def HILL_MAXSRM_extract(path): return _extract('HILL_MAXSRM', path)
def HILL_sigma_spam_PSRM_extract(path): return _extract('HILL_sigma_spam_PSRM', path)
def SCRMQ1_extract(path): return _extract('SCRMQ1', path)