Checks the sanity of the input image numpy array for cnn and converts the grayscale numpy array to rgb by repeating the array thrice along the 3rd dimension if a 2-dimensional image array is provided. Args: image_arr: Image array. Returns: A 3-dimensional numpy ima
(image_arr: np.ndarray)
| 68 | |
| 69 | |
| 70 | def expand_image_array_cnn(image_arr: np.ndarray) -> np.ndarray: |
| 71 | """ |
| 72 | Checks the sanity of the input image numpy array for cnn and converts the grayscale numpy array to rgb by repeating |
| 73 | the array thrice along the 3rd dimension if a 2-dimensional image array is provided. |
| 74 | |
| 75 | Args: |
| 76 | image_arr: Image array. |
| 77 | |
| 78 | Returns: |
| 79 | A 3-dimensional numpy image array. |
| 80 | """ |
| 81 | image_arr_shape = image_arr.shape |
| 82 | if len(image_arr_shape) == 3: |
| 83 | _check_3_dim(image_arr_shape) |
| 84 | return image_arr |
| 85 | elif len(image_arr_shape) == 2: |
| 86 | image_arr_3dim = _add_third_dim(image_arr) |
| 87 | return image_arr_3dim |
| 88 | else: |
| 89 | _raise_wrong_dim_value_error(image_arr_shape) |
| 90 | |
| 91 | |
| 92 | def preprocess_image( |