def test_compose(): img = image_loader(os.path.join(TEST_DATA_PATH, "images", "flower2.jpg")) transforms = ComposeTransforms([Saturation(), np.mean]) res_compose = transforms(img) transform_sat_only = Saturation() res_img = transform_sat_only(img) # compute average brightness res = np.mean(res_img) assert res == res_compose
def test_saturation(): img = image_loader(os.path.join(TEST_DATA_PATH, "images", "flower2.jpg")) transform = Saturation() res_img = transform(img) # compute average brightness res = np.mean(res_img) assert pytest.approx(res, 0.1) == 133.1 res_img = transform(np.array(img)) # compute average brightness res = np.mean(res_img) assert pytest.approx(res, 0.1) == 133.1
from typing import Callable, Dict, List, Union from whylogs.features.transforms import Brightness, Hue, Saturation logger = logging.getLogger(__name__) try: from PIL.Image import Image as ImageType from PIL.TiffImagePlugin import IFDRational from PIL.TiffTags import TAGS except ImportError as e: ImageType = None logger.debug(str(e)) logger.debug("Unable to load PIL; install Pillow for image support") DEFAULT_IMAGE_FEATURES = [Hue(), Saturation(), Brightness()] _METADATA_DEFAULT_ATTRIBUTES = [ "ImageWidth", "ImageLength", "BitsPerSample", "Compression", "Quality", "PhotometricInterpretation" "SamplesPerPixel", "Model", "Software", "ResolutionUnit", "X-Resolution", "Y-Resolution", "Orientation",