From 98c257cd503705634e5a786d7e3e60c50fbd1422 Mon Sep 17 00:00:00 2001 From: bakhtawar-10xe Date: Thu, 21 Sep 2023 13:28:46 +0500 Subject: [PATCH 1/5] rtl cecommended changes mae in AE and AWB --- modules/auto_exposure.py | 34 ++++++++++++++++++++++------------ modules/auto_white_balance.py | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/modules/auto_exposure.py b/modules/auto_exposure.py index ada3b50..bafd965 100644 --- a/modules/auto_exposure.py +++ b/modules/auto_exposure.py @@ -48,7 +48,7 @@ def apply_window_offset_crop(self): """ Get AE Stats window by cropping the offsets """ - offsets = np.ceil(self.stats_window_offset / 4) * 4 + offsets = self.stats_window_offset top = int(offsets[0]) bottom = None if offsets[1] == 0 else -int(offsets[1]) left = int(offsets[2]) @@ -104,7 +104,7 @@ def get_luminance_histogram_skewness(self, img): Zwillinger, D. and Kokoska, S. (2000). CRC Standard Probability and Statistics Tables and Formulae. Chapman & Hall: New York. 2000. Section 2.2.24.1 """ - + img_orig = np.copy(img) # First subtract central luminance to calculate skewness around it img = img.astype(np.float64) - self.center_illuminance @@ -120,18 +120,28 @@ def get_luminance_histogram_skewness(self, img): if self.is_debug: print(" - AE - Actual_Skewness = ", skewness) - sign_m3 = np.sign(m_3) - - m_2 = m_2 >> 6 - m_3 = abs(m_3) >> 9 - - approx_sqrt_m_2 = approx_sqrt(m_2) - new_skewness, _ = get_approximate(m_3 / (m_2 * approx_sqrt_m_2), 16, 8) - new_skewness = sign_m3 * new_skewness + # all integer calc + img_int = img_orig.astype(np.int64) - self.center_illuminance + img_int_size = img_int.size + m_2_int = np.sum(np.power(img_int, 2)).astype(np.int64) + m_3_int = np.sum(np.power(img_int, 3)).astype(np.int64) + m_2_int = np.int64(m_2_int / img_int_size) + m_3_int = np.int64(m_3_int / img_int_size) + sign_m3_int = np.sign(m_3_int) + # all integer calc + + m_2_int = m_2_int >> 6 + m_3_int = abs(m_3_int) >> 9 + + approx_sqrt_m_2_int = approx_sqrt(m_2_int) + new_skewness_int = ( + np.int64((m_3_int * 256) / (m_2_int * approx_sqrt_m_2_int)) / 256 + ) + # new_skewness_int = sign_m3_int * new_skewness_int if self.is_debug: - print(" - AE - Approx_Skewness = ", new_skewness) + print(" - AE - Approx_Skewness Int = ", new_skewness_int) - return new_skewness + return new_skewness_int def execute(self): """ diff --git a/modules/auto_white_balance.py b/modules/auto_white_balance.py index 1f0fb95..d58d9fb 100644 --- a/modules/auto_white_balance.py +++ b/modules/auto_white_balance.py @@ -34,7 +34,7 @@ def apply_window_offset_crop(self): """ Get AWB Stats window by cropping the offsets """ - offsets = np.ceil(self.stats_window_offset / 4) * 4 + offsets = self.stats_window_offset top = int(offsets[0]) bottom = None if offsets[1] == 0 else -int(offsets[1]) left = int(offsets[2]) From 422303d65c55215f6ea27d5eadd87e64130ed180 Mon Sep 17 00:00:00 2001 From: bakhtawar-10xe Date: Thu, 21 Sep 2023 14:27:24 +0500 Subject: [PATCH 2/5] FIxed readme --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ac28265..6dcd51f 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ ISP pipeline for `InfiniteISP_ReferenceModel v1.0` 4. **Video Processing**: The model also features a video processing script that allows for sequential frame processing, with operational 3A Statistics data flowing between frames. - +5. **Support Multiple RAW formats**: The model supports supports renowned raw formats, for example, DNG (predominantly employed by Android devices), NEF (specific to Nikon devices), and CR2 (Canon's signature format). It can also process the .raw image format, a one-dimensional pixel data array with no metadata header. ## Objectives @@ -59,6 +59,7 @@ The table below provides a feature list of the model. The version `1.0` of the m | Gamma Correction |Implements a LUT from config | | Auto Exposure | [Auto Exposure](https://www.atlantis-press.com/article/25875811.pdf)
- AE stats calculations based on skewness | | Color Space Conversion | YCbCr digital
- BT 601
- Bt 709
|YCbCr digital
- BT 601
- Bt 709
| +| Edge Enhancement / Sharpeining | Simple unsharp masking with strength control| | Noise Reduction | [Non-local means filter](https://www.ipol.im/pub/art/2011/bcm_nlm/article.pdf)
- Implements intensity level difference through a LUT| | RGB Conversion | Converts YCbCr digital image to RGB| | Invalid Region Crop | Crops image to a fixed size| @@ -103,14 +104,15 @@ RAW_DATA = './in_frames/normal/data' ## How to Run on Pipeline on Multiple Images/Dataset -There are two scripts that run Infinite-ISP on multiple images: +There is another script [isp_pipeline_multiple_images.py](isp_pipeline_multiple_images.py) that runs Infinite-ISP on multiple images with two modes: -1. [isp_pipeline_dataset.py](isp_pipeline_dataset.py) +1. DATASET PROCESSING
Execute multiple images. Raw image should have its own config file with name `-configs.yml` where `` is raw filename otherwise the default configuration file [configs.yml](config/configs.yml) is used. + For raw image format such as, NEF, DNG and CR2 we have also provided a funcationality to extract sensor information provided in these raw files metadata and update default config file. -2. [video_processing.py](video_processing.py) +2. VIDEO MODE
Each image in the dataset is considered as video frame in sequence. All images use the same configuration parameters from [configs.yml](config/configs.yml) and 3A Stats calculated on a frame are applied to the next frame. After cloning the repository and installing all the dependencies follow the following steps: @@ -124,7 +126,7 @@ DATASET_PATH = './in_frames/normal/data' ```shell git submodule add -git submodule update –-init –-recursive +git submodule update --init --recursive ``` From cdd6d1fe86f64f2edf220fdf803c813577b124d9 Mon Sep 17 00:00:00 2001 From: Maria_Nadeem-10x Date: Thu, 21 Sep 2023 15:58:48 +0500 Subject: [PATCH 3/5] updated readme in main directory. --- README.md | 14 +++++++------- Sample_Dataset | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) create mode 160000 Sample_Dataset diff --git a/README.md b/README.md index 6dcd51f..170c99b 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ ISP pipeline for `InfiniteISP_ReferenceModel v1.0` 3. **Dataset Processing**: The model facilitates execution for multiple images with different or same configuration files. -4. **Video Processing**: The model also features a video processing script that allows for sequential frame processing, with operational 3A Statistics data flowing between frames. +4. **Video Processing**: The model also includes a video processing feature that allows for sequential frame processing, with operational 3A Statistics data flowing between frames. -5. **Support Multiple RAW formats**: The model supports supports renowned raw formats, for example, DNG (predominantly employed by Android devices), NEF (specific to Nikon devices), and CR2 (Canon's signature format). It can also process the .raw image format, a one-dimensional pixel data array with no metadata header. +5. **Support Multiple RAW formats**: The model supports renowned raw formats, for example, DNG (predominantly employed by Android devices), NEF (specific to Nikon devices), and CR2 (Canon's signature format). It can also process the .raw image format, a one-dimensional pixel data array with no metadata header. ## Objectives @@ -59,7 +59,7 @@ The table below provides a feature list of the model. The version `1.0` of the m | Gamma Correction |Implements a LUT from config | | Auto Exposure | [Auto Exposure](https://www.atlantis-press.com/article/25875811.pdf)
- AE stats calculations based on skewness | | Color Space Conversion | YCbCr digital
- BT 601
- Bt 709
|YCbCr digital
- BT 601
- Bt 709
| -| Edge Enhancement / Sharpeining | Simple unsharp masking with strength control| +| Edge Enhancement / Sharpening | Simple unsharp masking with strength control| | Noise Reduction | [Non-local means filter](https://www.ipol.im/pub/art/2011/bcm_nlm/article.pdf)
- Implements intensity level difference through a LUT| | RGB Conversion | Converts YCbCr digital image to RGB| | Invalid Region Crop | Crops image to a fixed size| @@ -113,11 +113,11 @@ There is another script [isp_pipeline_multiple_images.py](isp_pipeline_multiple_ For raw image format such as, NEF, DNG and CR2 we have also provided a funcationality to extract sensor information provided in these raw files metadata and update default config file. 2. VIDEO MODE -
Each image in the dataset is considered as video frame in sequence. All images use the same configuration parameters from [configs.yml](config/configs.yml) and 3A Stats calculated on a frame are applied to the next frame. +
Each image in the dataset is considered as video frame in sequence. All images use the same configuration parameters from [configs.yml](config/configs.yml) and 3A stats calculated on a frame are applied to the next frame. After cloning the repository and installing all the dependencies follow the following steps: -1. Set `DATASET_PATH` to dataset folder. For example if images are in in [in_frames/normal/data](in_frames/normal/data) folder +1. Set `DATASET_PATH` to dataset folder. For example if images are in [in_frames/normal/data](in_frames/normal/data) folder ```python DATASET_PATH = './in_frames/normal/data' ``` @@ -130,13 +130,13 @@ git submodule update --init --recursive ``` -4. After adding git repository as a submodule update `DATASET_PATH` variable in [isp_pipeline_dataset.py](isp_pipeline_dataset.py) to `./in_frames/normal/`. Git does not allow to import a repository’s subfolder using a submodule. You can only add an entire repository and then access the folder. If you want to use images from a subfolder of a submodule modify the `DATASET_PATH` variable in [isp_pipeline_dataset.py](isp_pipeline_dataset.py) or [video_processing.py](video_processing.py) accordingly. +4. After adding git repository as a submodule update `DATASET_PATH` variable in [isp_pipeline_multiple_images.py ](isp_pipeline_multiple_images.py ) to `./in_frames/normal/`. Git does not allow to import a repository’s subfolder using a submodule. You can only add an entire repository and then access the folder. If you want to use images from a subfolder of a submodule modify the `DATASET_PATH` variable in [isp_pipeline_multiple_images.py](isp_pipeline_multiple_images.py) accordingly. ```python DATASET_PATH = './in_frames/normal/' ``` -5. Run `isp_pipeline_dataset.py` or `video_processing.py` +5. Run `isp_pipeline_multiple_images.py` 6. The processed images are saved in [out_frames](out_frames/) folder. ## Test Vector Generation diff --git a/Sample_Dataset b/Sample_Dataset new file mode 160000 index 0000000..88de172 --- /dev/null +++ b/Sample_Dataset @@ -0,0 +1 @@ +Subproject commit 88de1723ead9eeb1fe75feee2abfd1506619a3f0 From d972e62f0e1c36e11f622261c4cbceea2bc42ca8 Mon Sep 17 00:00:00 2001 From: bakhtawar-10xe Date: Thu, 21 Sep 2023 17:02:36 +0500 Subject: [PATCH 4/5] Bug Fixing in AE. --- modules/auto_exposure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/auto_exposure.py b/modules/auto_exposure.py index bafd965..0f70d5c 100644 --- a/modules/auto_exposure.py +++ b/modules/auto_exposure.py @@ -137,7 +137,7 @@ def get_luminance_histogram_skewness(self, img): new_skewness_int = ( np.int64((m_3_int * 256) / (m_2_int * approx_sqrt_m_2_int)) / 256 ) - # new_skewness_int = sign_m3_int * new_skewness_int + new_skewness_int = sign_m3_int * new_skewness_int if self.is_debug: print(" - AE - Approx_Skewness Int = ", new_skewness_int) From cce9c738c6580b04ad60bda31c15f0730411d5b1 Mon Sep 17 00:00:00 2001 From: taimur-10xe Date: Fri, 22 Sep 2023 18:24:23 +0500 Subject: [PATCH 5/5] modulo 4 check on AWB internal crop window added back --- modules/auto_white_balance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/auto_white_balance.py b/modules/auto_white_balance.py index d58d9fb..1f0fb95 100644 --- a/modules/auto_white_balance.py +++ b/modules/auto_white_balance.py @@ -34,7 +34,7 @@ def apply_window_offset_crop(self): """ Get AWB Stats window by cropping the offsets """ - offsets = self.stats_window_offset + offsets = np.ceil(self.stats_window_offset / 4) * 4 top = int(offsets[0]) bottom = None if offsets[1] == 0 else -int(offsets[1]) left = int(offsets[2])