Randomly changes jpeg encoding quality for inducing jpeg noise. `min_jpeg_quality` must be in the interval `[0, 100]` and less than `max_jpeg_quality`. `max_jpeg_quality` must be in the interval `[0, 100]`. Args: image: RGB image or images. Size of the last dimension must be 3. min
(image, min_jpeg_quality, max_jpeg_quality, seed=None)
| 1965 | # pylint: disable=invalid-name |
| 1966 | @tf_export('image.random_jpeg_quality') |
| 1967 | def random_jpeg_quality(image, min_jpeg_quality, max_jpeg_quality, seed=None): |
| 1968 | """Randomly changes jpeg encoding quality for inducing jpeg noise. |
| 1969 | |
| 1970 | `min_jpeg_quality` must be in the interval `[0, 100]` and less than |
| 1971 | `max_jpeg_quality`. |
| 1972 | `max_jpeg_quality` must be in the interval `[0, 100]`. |
| 1973 | |
| 1974 | Args: |
| 1975 | image: RGB image or images. Size of the last dimension must be 3. |
| 1976 | min_jpeg_quality: Minimum jpeg encoding quality to use. |
| 1977 | max_jpeg_quality: Maximum jpeg encoding quality to use. |
| 1978 | seed: An operation-specific seed. It will be used in conjunction with the |
| 1979 | graph-level seed to determine the real seeds that will be used in this |
| 1980 | operation. Please see the documentation of set_random_seed for its |
| 1981 | interaction with the graph-level random seed. |
| 1982 | |
| 1983 | Returns: |
| 1984 | Adjusted image(s), same shape and DType as `image`. |
| 1985 | |
| 1986 | Raises: |
| 1987 | ValueError: if `min_jpeg_quality` or `max_jpeg_quality` is invalid. |
| 1988 | """ |
| 1989 | if (min_jpeg_quality < 0 or max_jpeg_quality < 0 or min_jpeg_quality > 100 or |
| 1990 | max_jpeg_quality > 100): |
| 1991 | raise ValueError('jpeg encoding range must be between 0 and 100.') |
| 1992 | |
| 1993 | if min_jpeg_quality >= max_jpeg_quality: |
| 1994 | raise ValueError('`min_jpeg_quality` must be less than `max_jpeg_quality`.') |
| 1995 | |
| 1996 | if compat.forward_compatible(2019, 4, 4): |
| 1997 | jpeg_quality = random_ops.random_uniform([], |
| 1998 | min_jpeg_quality, |
| 1999 | max_jpeg_quality, |
| 2000 | seed=seed, |
| 2001 | dtype=dtypes.int32) |
| 2002 | else: |
| 2003 | np.random.seed(seed) |
| 2004 | jpeg_quality = np.random.randint(min_jpeg_quality, max_jpeg_quality) |
| 2005 | return adjust_jpeg_quality(image, jpeg_quality) |
| 2006 | |
| 2007 | |
| 2008 | @tf_export('image.adjust_jpeg_quality') |
nothing calls this directly
no test coverage detected