Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTL recommended changes made in AE and AWB #7

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) <br> - AE stats calculations based on skewness |
| Color Space Conversion | YCbCr digital <br> - BT 601 <br> - Bt 709 <br> |YCbCr digital <br> - BT 601 <br> - Bt 709 <br> |
| 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) <br> - Implements intensity level difference through a LUT|
| RGB Conversion | Converts YCbCr digital image to RGB|
| Invalid Region Crop | Crops image to a fixed size|
Expand Down Expand Up @@ -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
<br >Execute multiple images. Raw image should have its own config file with name `<filename>-configs.yml` where `<filename>` 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
<br> 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:
Expand All @@ -124,7 +126,7 @@ DATASET_PATH = './in_frames/normal/data'

```shell
git submodule add <url> <path>
git submodule update –-init -recursive
git submodule update --init --recursive
```


Expand Down
34 changes: 22 additions & 12 deletions modules/auto_exposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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

Expand All @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion modules/auto_white_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
Loading