from typing import Literal
from functools import partial
from pepeline import ResizesAlg, ResizesFilter, resize
from pepedpid import dpid_resize

FILTER_MAP = {
    'nearest': partial(resize, resize_alg=ResizesAlg.Nearest()),
    'box': partial(resize, resize_alg=ResizesAlg.Conv(ResizesFilter.Box)),
    'sbox4': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Box, 4)),
    'sbox8': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Box, 8)),
    'ibox': partial(resize, resize_alg=ResizesAlg.Interpolation(ResizesFilter.Box)),
    'linear': partial(resize, resize_alg=ResizesAlg.Conv(ResizesFilter.Bilinear)),
    'slinear4': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Bilinear, 4)),
    'slinear8': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Bilinear, 8)),
    'ilinear': partial(resize, resize_alg=ResizesAlg.Interpolation(ResizesFilter.Bilinear)),
    'hamming': partial(resize, resize_alg=ResizesAlg.Conv(ResizesFilter.Hamming)),
    'shamming4': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Hamming, 4)),
    'shamming8': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Hamming, 8)),
    'ihamming': partial(resize, resize_alg=ResizesAlg.Interpolation(ResizesFilter.Hamming)),
    'catmullrom': partial(resize, resize_alg=ResizesAlg.Conv(ResizesFilter.CatmullRom)),
    'scatmullrom4': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.CatmullRom, 4)),
    'scatmullrom8': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.CatmullRom, 8)),
    'icatmullrom': partial(resize, resize_alg=ResizesAlg.Interpolation(ResizesFilter.CatmullRom)),
    'mitchell': partial(resize, resize_alg=ResizesAlg.Conv(ResizesFilter.Mitchell)),
    'smitchell4': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Mitchell, 4)),
    'smitchell8': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Mitchell, 8)),
    'imitchell': partial(resize, resize_alg=ResizesAlg.Interpolation(ResizesFilter.Mitchell)),
    'lanczos': partial(resize, resize_alg=ResizesAlg.Conv(ResizesFilter.Lanczos3)),
    'slanczos4': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Lanczos3, 4)),
    'slanczos8': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Lanczos3, 8)),
    'ilanczos': partial(resize, resize_alg=ResizesAlg.Interpolation(ResizesFilter.Lanczos3)),
    'gauss': partial(resize, resize_alg=ResizesAlg.Conv(ResizesFilter.Gaussian)),
    'sgauss4': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Gaussian, 4)),
    'sgauss8': partial(resize, resize_alg=ResizesAlg.SuperSampling(ResizesFilter.Gaussian, 8)),
    'igauss': partial(resize, resize_alg=ResizesAlg.Interpolation(ResizesFilter.Gaussian)),
    'dpid_0.25': partial(dpid_resize,l=0.25),
    'dpid_0.5': partial(dpid_resize, l=0.5),
    'dpid_0.75': partial(dpid_resize, l=0.75),
    'dpid_1': partial(dpid_resize, l=1)
}

FilterType = Literal[
    'nearest',
    'box',
    'sbox4',
    'sbox8',
    'ibox8',
    'linear',
    'slinear4',
    'slinear8',
    'ilinear',
    'hamming',
    'shamming4',
    'shamming8',
    'ihamming',
    'catmullrom',
    'scatmullrom4',
    'scatmullrom8',
    'icatmullrom',
    'mitchell',
    'smitchell4',
    'smitchell8',
    'imitchell',
    'lanczos',
    'slanczos4',
    'slanczos8',
    'ilanczos',
    'gauss',
    'sgauss4',
    'sgauss8',
    'igauss',
    'dpid_0.25',
    'dpid_0.5',
    'dpid_0.75',
    'dpid_1',
]
