### Basic Demosaic usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/demosaic.md Creates a Demosaic instance and executes it to get a uint16 RGB image. ```python from modules.demosaic.demosaic import Demosaic sensor_info = {"bayer_pattern": "rggb", "bit_depth": 12} dem = Demosaic(raw_img, platform, sensor_info, {"is_save": False}) rgb = dem.execute() # (height, width, 3) uint16 ``` -------------------------------- ### Install dependencies with pip Source: https://github.com/10x-engineers/infinite-isp/blob/main/README.md Install all required Python packages from the requirements file. ```shell pip install -r requirements.txt ``` -------------------------------- ### Basic AutoExposure usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-exposure.md Creates AutoExposure instance with sample config, calls execute() to get feedback. Feedback is -1 underexposed, 0 correct, 1 overexposed, or None if disabled. ```python from modules.auto_exposure.auto_exposure import AutoExposure parm_ae = {"is_enable": True, "is_debug": True, "center_illuminance": 90, "histogram_skewness": 0.9} sensor_info = {"bit_depth": 12} ae = AutoExposure(rgb_img, sensor_info, parm_ae) feedback = ae.execute() # -1 underexposed | 0 correct | 1 overexposed | None if disabled if feedback is not None: print("AE feedback:", feedback) ``` -------------------------------- ### Basic AutoWhiteBalance usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-white-balance.md Shows how to instantiate AutoWhiteBalance with a config, call execute(), and print the resulting gains. The example uses algorithm 'norm_2' and a 12-bit rggb sensor. ```python from modules.auto_white_balance.auto_white_balance import AutoWhiteBalance parm_awb = { "is_enable": True, "is_debug": True, "underexposed_percentage": 5, "overexposed_percentage": 5, "algorithm": "norm_2", "percentage": 3.5, } sensor_info = {"bit_depth": 12, "bayer_pattern": "rggb"} awb = AutoWhiteBalance(raw_img, sensor_info, parm_awb) gains = awb.execute() # np.array([rgain, bgain]) or None if gains is not None: print("RGain", gains[0], "BGain", gains[1]) ``` -------------------------------- ### Basic usage example with BT.601 and saturation Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/color-space-conversion.md Shows how to instantiate ColorSpaceConversion with BT.601 (conv_standard=2) and saturation gain 1.5, then call execute() to get the YUV image. ```python from modules.color_space_conversion.color_space_conversion import ColorSpaceConversion parm_csc = {"conv_standard": 2, "is_save": False} parm_cse = {"is_enable": True, "saturation_gain": 1.5} sensor_info = {"bit_depth": 12} csc = ColorSpaceConversion(rgb_img, platform, sensor_info, parm_csc, parm_cse) yuv = csc.execute() # uint8 YCbCr (H, W, 3), BT.601, saturation gain 1.5 ``` -------------------------------- ### Dataset run example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/drivers.md Example of editing constants at the top of isp_pipeline_mulitple_images.py to run a dataset processing. Set VIDEO_MODE = False, DATASET_PATH to the folder with RAW images, and CONFIG_PATH to the config file, then run the script. Each processed image is saved to out_frames/ as PNG + YAML config. ```python # Edit the constants at the top of isp_pipeline_mulitple_images.py, then: # VIDEO_MODE = False # DATASET_PATH = "./in_frames/normal/data" # CONFIG_PATH = "./config/configs.yml" # Run: python isp_pipeline_mulitple_images.py ``` -------------------------------- ### Basic non-hardware scaling example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/scale.md Configures the Scale class with software scaling (is_hardware=False) using Bilinear algorithm. The output is (1080, 1920, 3) for a 1920x1080 input. ```python from modules.scale.scale import Scale parm_sca = { "is_enable": True, "is_debug": True, "is_save": False, "new_width": 1920, "new_height": 1080, "is_hardware": False, "algorithm": "Bilinear", "upscale_method": "Nearest_Neighbor", "downscale_method": "Bilinear", } scale = Scale(rgb_img, platform, sensor_info, parm_sca, conv_std=2) scaled = scale.execute() # (1080, 1920, 3) ``` -------------------------------- ### Example with BT.709 without saturation Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/color-space-conversion.md Shows configuration for BT.709 (conv_standard=1) with saturation disabled. The Y channel gets an offset of 2**(bit_depth/2) and U/V get 2**(bit_depth-1) before normalization. ```python parm_csc = {"conv_standard": 1, "is_save": False} parm_cse = {"is_enable": False, "saturation_gain": 1.0} csc = ColorSpaceConversion(rgb_img, platform, sensor_info, parm_csc, parm_cse) yuv = csc.execute() # BT.709, Y offset 64 (2**(12/2)), U/V offset 2048 before normalize ``` -------------------------------- ### Basic usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/bayer-noise-reduction.md Shows how to instantiate BayerNoiseReduction and execute denoising on a raw image. ```python from modules.bayer_noise_reduction.bayer_noise_reduction import BayerNoiseReduction parm_bnr = { "is_enable": True, "filter_window": 9, "is_save": False, "r_std_dev_s": 1, "r_std_dev_r": 0.1, "g_std_dev_s": 1, "g_std_dev_r": 0.08, "b_std_dev_s": 1, "b_std_dev_r": 0.1, } sensor_info = {"bayer_pattern": "rggb", "width": 2592, "height": 1536, "bit_depth": 12} platform = {"in_file": "frame.raw", "disable_progress_bar": False, "leave_pbar_string": False} bnr = BayerNoiseReduction(raw_img, sensor_info, parm_bnr, platform) denoised = bnr.execute() # uint16, same shape as input ``` -------------------------------- ### YUV stream round trip example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/util-utils.md Simulates flattened YUV data, rebuilds it, and converts to RGB using yuv_to_rgb. ```python import numpy as np, util.utils as util yuv = np.random.default_rng(0).integers(0, 256, (16, 32, 3), dtype=np.uint8) flat = yuv[:, 0::2, :].reshape(-1) # simulated 4:4:4-like flattened data rebuilt = util.get_image_from_yuv_format_conversion(flat, 16, 32, "444") rgb = util.yuv_to_rgb(rebuilt, conv_std=2) ``` -------------------------------- ### PCAIlluminEstimation usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-white-balance.md Creates a PCAIlluminEstimation instance with 100,000 random float32 pixels and pixel_percentage=3.5, then computes gains. ```python from modules.auto_white_balance.pca import PCAIlluminEstimation import numpy as np pixels = np.random.default_rng(0).random((100_000, 3)).astype(np.float32) pca = PCAIlluminEstimation(pixels, pixel_percentage=3.5) rgain, bgain = pca.calculate_gains() ``` -------------------------------- ### Basic RGBConversion example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/rgb-conversion.md Creates an RGBConversion instance with BT.601 standard and executes conversion, returning uint8 RGB image. ```python from modules.rgb_conversion.rgb_conversion import RGBConversion parm_rgb = {"is_enable": True, "is_save": False} parm_csc = {"conv_standard": 2} rgbc = RGBConversion(yuv_img, platform, sensor_info, parm_rgb, parm_csc) out = rgbc.execute() # uint8 RGB, BT.601 inverse matrix ``` -------------------------------- ### Basic cropping example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/crop.md Shows how to instantiate Crop and execute it with a valid configuration. The new size (1280x720) is pattern-safe, resulting in a cropped image of shape (720, 1280). ```python from modules.crop.crop import Crop import numpy as np config = { "crop": {"is_enable": True, "is_debug": True, "is_save": False, "new_width": 1280, "new_height": 720}, "sensor_info": {"width": 2592, "height": 1536}, "platform": {"in_file": "frame_2592x1536.raw"}, } raw = np.zeros((1536, 2592), dtype=np.uint16) crop = Crop(raw, config["platform"], config["sensor_info"], config["crop"]) cropped = crop.execute() # (720, 1280) — 816/4 x 636/4 removals: pattern-safe ``` -------------------------------- ### Basic Sharpening example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/sharpen.md Example of using the Sharpening class with parm_sha configuration. The execute() method returns the sharpened image (H, W, 3) uint8, with luma sharpened in place. ```python from modules.sharpen.sharpen import Sharpening parm_sha = {"is_enable": True, "sharpen_sigma": 5, "sharpen_strength": 1, "is_save": False} sharp = Sharpening(yuv_img, platform, sensor_info, parm_sha, conv_std=2) out = sharp.execute() # (H, W, 3) uint8, luma sharpened in place ``` -------------------------------- ### NLM with bad window/patch params example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/noise-reduction-2d.md Example with wts=0 and even patch_size; wts coerced to 1, patch made odd with printed warning; still runs. ```python from modules.noise_reduction_2d.non_local_means import NLM parm_bad = {"wts": 0, "window_size": 9, "patch_size": 6} # wts -> 1, patch -> 7 (printed) nlm = NLM(yuv_img, sensor_info, parm_bad, platform) out = nlm.apply_nlm() # still runs; warnings via print, not exceptions ``` -------------------------------- ### OECF basic example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/oecf.md Basic usage of OECF with a 12-bit LUT. Creates OECF instance and calls execute() to get LUT-mapped uint16 RAW. ```python from modules.oecf.oecf import OECF import numpy as np parm_oecf = { "is_enable": True, "is_save": False, "r_lut": [round(4095 * (v / 4095) ** 0.6) for v in range(4096)], # 12-bit LUT } sensor_info = {"bayer_pattern": "rggb", "bit_depth": 12} oecf = OECF(raw_img, platform, sensor_info, parm_oecf) out = oecf.execute() # LUT-mapped uint16 RAW ``` -------------------------------- ### Example: basic static gain usage Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/digital-gain.md Shows how to instantiate DigitalGain with static gain (is_auto=False) and execute it. The gain_array is used with current_gain=0, so gain 1.0 is applied and gain_idx is 0. ```python from modules.digital_gain.digital_gain import DigitalGain parm_dga = { "is_auto": False, "is_debug": True, "is_save": False, "gain_array": [1, 2, 4, 6, 8, 10, 12, 16, 32, 64], "current_gain": 0, "ae_feedback": 0, } sensor_info = {"bit_depth": 12} dg = DigitalGain(raw_img, platform, sensor_info, parm_dga) gained_img, gain_idx = dg.execute() # gain 1.0 applied; gain_idx == 0 ``` -------------------------------- ### Basic LDCI usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/ldci.md Shows how to instantiate LDCI with a parm_ldci dict and execute CLAHE equalization on the Y channel. Requires yuv_img, platform, and sensor_info variables. ```python from modules.ldci.ldci import LDCI parm_ldci = {"is_enable": True, "clip_limit": 1, "wind": 16, "is_save": False} ldci = LDCI(yuv_img, platform, sensor_info, parm_ldci, conv_std=2) out = ldci.execute() # Y channel CLAHE-equalized, U/V unchanged ``` -------------------------------- ### Basic YUVConvFormat usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/yuv-conversion-format.md Shows how to instantiate YUVConvFormat with a YUV image and execute conversion to 4:2:2 format. Writes the flattened stream to out_frames/out_frame.raw.yuv. ```python from modules.yuv_conv_format.yuv_conv_format import YUVConvFormat parm_yuv = {"is_enable": True, "conv_type": "422", "is_save": False} platform = {"in_file": "frame.raw", "rgb_output": False, "save_format": "both"} yuvf = YUVConvFormat(yuv_img, platform, sensor_info, parm_yuv) stream = yuvf.execute() # flattened uint8 4:2:2 stream; out_frames/out_frame.raw.yuv written ``` -------------------------------- ### Basic WhiteBalance usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/white-balance.md Creates a WhiteBalance instance with manual gains and executes. R pixels multiplied by 1.246, B by 2.808. Output is uint16. ```python from modules.white_balance.white_balance import WhiteBalance parm_wbc = { "is_enable": True, "is_auto": False, "is_debug": True, "is_save": False, "r_gain": 1.24609375, "b_gain": 2.80859375, } sensor_info = {"bayer_pattern": "rggb", "bit_depth": 12} wb = WhiteBalance(raw_img, platform, sensor_info, parm_wbc) out = wb.execute() # uint16; R pixels multiplied by 1.246, B by 2.808 ``` -------------------------------- ### Visualization path example for InfiniteISP Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/rgb-conversion.md When RGB conversion is disabled, manually inject YUV and call yuv_to_rgb() directly for display without execute(). ```python # RGB conversion disabled: YUV must be converted back manually for display parm_rgb = {"is_enable": False, "is_save": False} rgbc = RGBConversion(yuv_img, platform, sensor_info, parm_rgb, parm_csc) rgbc.yuv_img = yuv_img # caller can inject the YUV to convert out_rgb = rgbc.yuv_to_rgb() # direct conversion without execute() ``` -------------------------------- ### Unsupported bit depth example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/gamma-correction.md Demonstrates handling of an unsupported bit depth (16) where no gamma LUT key exists. The constructor would raise KeyError for gamma_lut_16, and execute() may raise UnboundLocalError. The example catches both exceptions. ```python sensor_16 = {"bit_depth": 16} # no 16-bit LUT key exists in the config section gc = GammaCorrection(rgb_img, platform, sensor_16, parm_gmm) # gamma_lut_16 would KeyError try: gc.execute() except (KeyError, UnboundLocalError) as e: print(f"Gamma failed for bit depth 16: {e}") ``` -------------------------------- ### Save module output example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/util-utils.md Saves raw image as .npy and .png using save_output_array with platform config. ```python platform = {"save_format": "both"} util.save_output_array("frame_2592x1536.raw", raw_img, "Out_crop_", platform, 12, "rggb") # writes module_output/Out_crop_frame_2592x1536.npy (and .png) ``` -------------------------------- ### Low-level UnsharpMasking example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/sharpen.md Example of using the UnsharpMasking class directly. The apply_sharpen() method returns the same object as yuv_img with luma enhanced. ```python from modules.sharpen.unsharp_masking import UnsharpMasking usm = UnsharpMasking(yuv_img, sharpen_sigma=1.0, sharpen_strength=2.0) out = usm.apply_sharpen() # same object as yuv_img, luma enhanced ``` -------------------------------- ### extract_raw_metadata usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/config-utils.md Example of using extract_raw_metadata to read metadata from a DNG file and update the ISP with BLC and WB gains. Raises rawpy.imread exceptions on unreadable files. ```python from util.config_utils import extract_raw_metadata try: meta = extract_raw_metadata("./in_frames/photos/capture.dng") isp.update_sensor_info(meta, update_blc_wb=True) # width, height, bit_depth, bayer_pattern, BLC offsets/sats and WB gains updated except Exception as e: print(f"Metadata extraction failed: {e}") ``` -------------------------------- ### Disabled AWB and error handling example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-white-balance.md Shows that when is_enable is False, execute() returns None. Also demonstrates that an unknown algorithm falls through to GrayWorld, and that a fully black image after filtering raises IndexError or ValueError. ```python parm_awb = {**parm_awb, "is_enable": False} awb = AutoWhiteBalance(raw_img, sensor_info, parm_awb) assert awb.execute() is None # no gains computed parm_awb["is_enable"] = True parm_awb["algorithm"] = "unknown_algorithm" # falls through to GrayWorld (else branch) awb = AutoWhiteBalance(raw_img, sensor_info, parm_awb) try: gains = awb.execute() except (IndexError, ValueError) as e: print(f"AWB failed: {e}") # e.g. RAW all-black after bad-pixel filtering ``` -------------------------------- ### execute() error handling for missing raw file Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/infinite-isp.md Usage example showing error handling when the raw file is missing. Catches FileNotFoundError and prints a message. ```python from pathlib import Path from infinite_isp import InfiniteISP isp = InfiniteISP(".", "./config/configs.yml") try: isp.execute(img_path="does_not_exist.raw") except FileNotFoundError as e: print(f"RAW frame missing: {e}") ``` -------------------------------- ### Example: auto mode driven by AE feedback Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/digital-gain.md Shows auto mode where ae_feedback=-1 (underexposed) steps the gain index up. After execution, gain_idx becomes 1, using gain_array[1] == 2.0. ```python from modules.digital_gain.digital_gain import DigitalGain parm_dga = { "is_auto": True, "is_debug": False, "is_save": False, "gain_array": [1, 2, 4, 6, 8, 10, 12, 16, 32, 64], "current_gain": 0, "ae_feedback": -1, # underexposed -> step gain up } dg = DigitalGain(raw_img, platform, sensor_info, parm_dga) gained_img, gain_idx = dg.execute() # uses gain_array[1] == 2.0 assert gain_idx == 1 ``` -------------------------------- ### Kernel-size coercion warnings example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/bayer-noise-reduction.md Demonstrates the warning when an even filter_window is passed; the window is coerced to odd. ```python from modules.bayer_noise_reduction.joint_bf import JointBF import warnings jbf = JointBF(raw_img, sensor_info, {**parm_bnr, "filter_window": 8}, platform) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") out = jbf.apply_jbf() # even window 8 -> 9, warning: "...cannot be even..." print([str(x.message) for x in w]) ``` -------------------------------- ### Gain clamping example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/white-balance.md Shows that gains are clipped to keep values in range. With r_gain 4.0 and b_gain 0.5, output values are clipped to [0, 4095]. ```python parm_wbc = {**parm_wbc, "r_gain": 4.0, "b_gain": 0.5} wb = WhiteBalance(raw_img, platform, sensor_info, parm_wbc) out = wb.execute() # values clipped to [0, 4095] ``` -------------------------------- ### parse_file_name usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/config-utils.md Example of using parse_file_name to get sensor info from a filename and update the ISP. Returns [width, height, bit_depth, bayer_pattern] or False on mismatch. ```python from util.config_utils import parse_file_name info = parse_file_name("Indoor1_2592x1536_12bit_RGGB.raw") # [2592, 1536, 12, "rggb"] if not info: print("no sensor info in filename") else: isp.update_sensor_info(info) # updates width/height/bit_depth/bayer only ``` -------------------------------- ### Inline comment example for code commenting Source: https://github.com/10x-engineers/infinite-isp/blob/main/docs/CONTRIBUTIONS.md Shows the required inline comment style: a complete sentence with a period, starting with an uppercase letter, placed just before the code line it explains. ```python # Increment x by 1 x = x + 1 ``` -------------------------------- ### Import AutoWhiteBalance and gain algorithms Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-white-balance.md Import the AutoWhiteBalance class and the three selectable gain algorithms from the modules.auto_white_balance package. ```python from modules.auto_white_balance.auto_white_balance import AutoWhiteBalance from modules.auto_white_balance.gray_world import GrayWorld from modules.auto_white_balance.norm_gray_world import NormGrayWorld from modules.auto_white_balance.pca import PCAIlluminEstimation ``` -------------------------------- ### Inline comment example: increment x by 1 Source: https://github.com/10x-engineers/infinite-isp/blob/main/CONTRIBUTIONS.md Shows the required inline comment style: a complete sentence with a period, starting with an uppercase letter, placed just before the code line it explains. ```python # Increment x by 1 x = x + 1 ``` -------------------------------- ### Configure pipeline for a sample image Source: https://github.com/10x-engineers/infinite-isp/blob/main/README.md Set the config file path and raw data directory in isp_pipeline.py to run on a specific sample image. ```python CONFIG_PATH = './config/Indoor1_2592x1536_12bit_RGGB-configs.yml' RAW_DATA = './in_frames/normal/data' ``` -------------------------------- ### Detection count via DynamicDPC Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/dead-pixel-correction.md Example of using DynamicDPC directly to get the detection count. Prints 'Number of corrected pixels = N' when is_debug is True. Raises ValueError if input is not 2D or empty. ```python from modules.dead_pixel_correction.dynamic_dpc import DynamicDPC dpc = DynamicDPC(raw_img, sensor_info, {"dp_threshold": 80, "is_debug": True}) try: out = dpc.dynamic_dpc() # prints "Number of corrected pixels = N" when is_debug except ValueError as e: print(f"DPC failed: {e}") # e.g. input not 2D or empty ``` -------------------------------- ### Basic NoiseReduction2d usage example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/noise-reduction-2d.md Example of using NoiseReduction2d with typical parameters; Y denoised, U/V unchanged. ```python from modules.noise_reduction_2d.noise_reduction_2d import NoiseReduction2d parm_2dnr = {"is_enable": True, "window_size": 9, "patch_size": 5, "wts": 10, "is_save": False} platform = {"disable_progress_bar": False, "leave_pbar_string": False} nr2d = NoiseReduction2d(yuv_img, sensor_info, parm_2dnr, platform, conv_std=2) out = nr2d.execute() # Y denoised, U/V unchanged ``` -------------------------------- ### Example usage of LensShadingCorrection Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/lens-shading-correction.md Example showing how to instantiate and use the LensShadingCorrection class. The output is identical to the input because it is a pass-through stub. ```python from modules.lens_shading_correction.lens_shading_correction import LensShadingCorrection parm_lsc = {"is_enable": True, "is_save": False} lsc = LensShadingCorrection(raw_img, platform, sensor_info, parm_lsc) out = lsc.execute() # identical to raw_img (pass-through stub) assert out is raw_img # no copy is made; execute returns self.img unchanged ``` -------------------------------- ### execute(img_path=None) Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/infinite-isp.md Main entry point for a whole run. It optionally overrides the platform filename, loads the raw image, runs the pipeline (once or with 3A statistics), prints AE statistics and elapsed time. ```APIDOC ## execute(img_path=None) ### Description Main entry point for a whole run. It optionally overrides the platform filename, loads the raw image, runs the pipeline (once or with 3A statistics), prints AE statistics and elapsed time. ### Method N/A (Python method) ### Endpoint N/A ### Parameters - `img_path` (str) - Optional - Overrides `platform.filename` and updates `self.c_yaml["platform"]["filename"]`. ### Request Example ```python from infinite_isp import InfiniteISP isp = InfiniteISP("./in_frames/normal", "./config/configs.yml") isp.execute(img_path=None) # uses config platform.filename ``` ### Response Returns `None`. ### Error Handling Raises `FileNotFoundError` if the raw file is missing. ### Response Example ```python from pathlib import Path from infinite_isp import InfiniteISP isp = InfiniteISP(".", "./config/configs.yml") try: isp.execute(img_path="does_not_exist.raw") except FileNotFoundError as e: print(f"RAW frame missing: {e}") ``` ``` -------------------------------- ### OECF error handling example (LUT too short) Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/oecf.md Example showing IndexError when LUT length does not cover sensor range. Uses an 8-bit LUT with a 12-bit sensor and catches the error. ```python parm_oecf = {"is_enable": True, "is_save": False, "r_lut": list(range(256))} # 8-bit LUT oecf = OECF(raw_img, platform, sensor_info, parm_oecf) # sensor is 12-bit try: out = oecf.execute() except IndexError as e: print(f"LUT does not cover sensor range: {e}") ``` -------------------------------- ### Run the ISP pipeline Source: https://github.com/10x-engineers/infinite-isp/blob/main/README.md Execute the main ISP pipeline script. ```shell python isp_pipeline.py ``` -------------------------------- ### PCAIlluminEstimation constructor Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-white-balance.md Initializes PCA-based illuminant estimation with flattened RGB pixels and a pixel percentage for selecting darkest/brightest pixels. ```python def __init__(self, flatten_img, pixel_percentage): ``` -------------------------------- ### isp_pipeline_mulitple_images.py module-level constants Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/drivers.md Configuration constants for the dataset/video-mode driver. DATASET_PATH is the folder scanned for RAW images, CONFIG_PATH is the default config, VIDEO_MODE selects between video_processing() and dataset_processing(), EXTRACT_SENSOR_INFO enables sensor info extraction in dataset mode, and UPDATE_BLC_WB is passed to InfiniteISP.update_sensor_info(). ```python DATASET_PATH = "./in_frames/normal/data/" CONFIG_PATH = "./config/configs.yml" VIDEO_MODE = False EXTRACT_SENSOR_INFO = True UPDATE_BLC_WB = True ``` -------------------------------- ### isp_pipeline.py __main__ block Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/drivers.md Instantiates InfiniteISP with RAW_DATA and CONFIG_PATH, then executes with optional img_path override. Run with 'python isp_pipeline.py'; output is saved to out_frames/Out__.png and .yaml, with 3A statistics and elapsed time printed to stdout. ```python infinite_isp = InfiniteISP(RAW_DATA, CONFIG_PATH) infinite_isp.execute(img_path=FILENAME) ``` -------------------------------- ### AutoExposure.__init__(img, sensor_info, parm_ae) Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-exposure.md Constructor for the AutoExposure class. Initializes the module with the input image, sensor configuration, and auto-exposure parameters. ```APIDOC ## AutoExposure.__init__(img, sensor_info, parm_ae) ### Description Constructor for the AutoExposure class. Initializes the module with the input image, sensor configuration, and auto-exposure parameters. ### Method Constructor ### Signature ```python def __init__(self, img, sensor_info, parm_ae): ``` ### Parameters - **img** (numpy.ndarray (H, W, 3)) - Required - RGB image (pre-CSC gamma-corrected in the pipeline) - **sensor_info** (dict) - Required - Sensor config (read: `bit_depth`) - **parm_ae** (dict) - Required - `auto_exposure` config (read: `is_enable`, `is_debug`, `center_illuminance`, `histogram_skewness`) ### Returns None ``` -------------------------------- ### InfiniteISP.__init__(data_path, config_path) Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/infinite-isp.md Constructor for the InfiniteISP pipeline. Initializes the pipeline with a data directory and YAML configuration path, loading the configuration and storing key attributes. ```APIDOC ## InfiniteISP.__init__(data_path, config_path) ### Description Constructor for the InfiniteISP pipeline. Initializes the pipeline with a data directory and YAML configuration path, loading the configuration and storing key attributes. ### Method Constructor ### Signature ```python def __init__(self, data_path, config_path): ``` ### Parameters - **data_path** (str / Path) - Required - Directory that contains the RAW file named by `platform.filename` in the config - **config_path** (str / Path) - Required - Path to the YAML pipeline configuration ### Behavior Stores `self.data_path` and calls `load_config(config_path)`. Raises `FileNotFoundError`/`yaml.YAMLError` if the config path is invalid. ``` -------------------------------- ### Clone the Infinite-ISP repository Source: https://github.com/10x-engineers/infinite-isp/blob/main/README.md Clone the Infinite-ISP reference model repository from GitHub. ```shell git clone https://github.com/10xEngineersTech/Infinite-ISP_ReferenceModel ``` -------------------------------- ### apply_cfa implementation Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/demosaic.md Implementation of apply_cfa: gets masks, applies Malvar, clips to bit depth, and returns uint16 array. ```python masks = self.masks_cfa_bayer() mal = MAL(self.img, masks) demos_out = mal.apply_malvar() demos_out = np.clip(demos_out, 0, 2**self.bit_depth - 1) demos_out = np.uint16(demos_out) return demos_out ``` -------------------------------- ### dataset_processing() signature Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/drivers.md Function signature for dataset-mode processing. For each RAW image (suffix in ['.raw', '.NEF', '.dng', '.nef']) in DATASET_PATH, it loads a per-image config if '-configs.yml' exists, otherwise reloads the default config and optionally extracts sensor info (parse_file_name for .raw, extract_raw_metadata for others). Executes each frame via infinite_isp.execute(raw); returns None. ```python def dataset_processing(): ``` -------------------------------- ### execute() Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-white-balance.md Executes the AWB pipeline and returns the white balance gains as a numpy array, or None if disabled. ```APIDOC ## execute() ### Description Executes the AWB pipeline and returns the white balance gains as a numpy array, or None if disabled. ### Method Method ### Signature ```python def execute(self): ``` ### Parameters None ### Returns - **numpy.ndarray** - Array of [rgain, bgain] if enabled, else None. ``` -------------------------------- ### Pattern-safety violation example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/crop.md Shows a configuration where new dimensions are not multiple-of-4 compatible, causing the crop to print a warning and return the image unchanged. ```python bad = {"crop": {"is_enable": True, "is_debug": False, "is_save": False, "new_width": 1290, "new_height": 726}, # not multiple-of-4 compatible "sensor_info": {"width": 2592, "height": 1536}, "platform": {"in_file": "frame.raw"}} crop = Crop(raw, bad["platform"], bad["sensor_info"], bad["crop"]) out = crop.execute() # prints warning; returns image unchanged (1536, 2592) ``` -------------------------------- ### InfiniteISP.run_pipeline(visualize_output=True) Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/infinite-isp.md Executes all 20 pipeline stages in fixed order, including 3A feedback when enabled. Optionally converts the output back to RGB for display or saving. ```APIDOC ## InfiniteISP.run_pipeline(visualize_output=True) ### Description Executes all 20 pipeline stages in fixed order, including 3A feedback when enabled. Optionally converts the output back to RGB for display or saving. ### Method Method ### Signature ```python def run_pipeline(self, visualize_output=True): ``` ### Parameters - **visualize_output** (bool) - Optional - Default: `True` - When `True`, converts the final output back to RGB for display/saving ### Behavior Executes all 20 stages in the order documented in the index. The 3A modules (`AutoWhiteBalance`, `AutoExposure`) are executed for statistics: results are stored in `self.awb_gains` and `self.ae_feedback` (and `self.dga_current_gain` from `DigitalGain`). When `visualize_output` is `True`, the output is converted back to RGB (via `RGBConversion.yuv_to_rgb()` for YUV outputs, or used directly for RGB output) and saved to `out_frames/` with `util.save_pipeline_output`. ``` -------------------------------- ### execute() basic usage Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/infinite-isp.md Basic usage mirroring isp_pipeline.py. Creates an InfiniteISP instance with input directory and config file, then calls execute() with default img_path=None to use config platform.filename. ```python from infinite_isp import InfiniteISP isp = InfiniteISP("./in_frames/normal", "./config/configs.yml") isp.execute(img_path=None) # uses config platform.filename ``` -------------------------------- ### DigitalGain.__init__ Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/digital-gain.md Constructor for the DigitalGain class. Initializes the module with the raw Bayer image, platform config, sensor info, and digital gain parameters. ```APIDOC ## DigitalGain.__init__ ### Description Constructor for the DigitalGain class. Initializes the module with the raw Bayer image, platform config, sensor info, and digital gain parameters. ### Method Constructor ### Signature ```python def __init__(self, img, platform, sensor_info, parm_dga): ``` ### Parameters - `img` (numpy.ndarray, 2D) - Required - Raw Bayer image (stored as a copy: `self.img = img.copy()`) - `platform` (dict) - Required - Platform config - `sensor_info` (dict) - Required - Sensor config (read: `bit_depth`) - `parm_dga` (dict) - Required - `digital_gain` config (read: `is_save`, `is_debug`, `is_auto`, `gain_array`, `current_gain`, `ae_feedback`) ``` -------------------------------- ### Invalid input example (RGB image) Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/yuv-conversion-format.md Demonstrates behavior when the input image is RGB. The module prints an error message and self-disables by setting parm_yuv['is_enable'] to False. ```python platform_rgb = {**platform, "rgb_output": True} yuvf = YUVConvFormat(rgb_img, platform_rgb, sensor_info, parm_yuv) out = yuvf.execute() # prints "Invalid input for YUV conversion: RGB image format." assert parm_yuv["is_enable"] is False # module disabled itself ``` -------------------------------- ### Example: offset-only without linearization, with invalid sensor config Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/black-level-correction.md Shows usage with is_linear=False and a try/except for KeyError. The KeyError is raised in __init__ if a required key is absent from the config. ```python parm_blc = { "is_enable": True, "is_linear": False, "is_save": False, "r_offset": 64, "gr_offset": 64, "gb_offset": 64, "b_offset": 64, "r_sat": 1023, "gr_sat": 1023, "gb_sat": 1023, "b_sat": 1023, } try: blc = BlackLevelCorrection(raw_img, platform, sensor_info, parm_blc) out = blc.execute() except KeyError as e: print(f"Config missing key: {e}") # raised in __init__ if a required key is absent ``` -------------------------------- ### Import NearestNeighbor and BilinearInterpolation Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/scale.md Imports the NearestNeighbor and BilinearInterpolation classes from their respective modules for scaling operations. ```python from modules.scale.nearest_neighbor import NearestNeighbor from modules.scale.bilinear_interpolation import BilinearInterpolation ``` -------------------------------- ### Constructor signature Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/crop.md Initializes the Crop object with image, platform, sensor_info, and parm_cro. Sets old_size and new_size, and calls update_sensor_info. ```python def __init__(self, img, platform, sensor_info, parm_cro): ``` -------------------------------- ### Basic usage example of ColorCorrectionMatrix Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/color-correction-matrix.md Creates a ColorCorrectionMatrix with a 3x3 CCM and executes it. Expects rgb_img and platform to be defined. Returns uint16 image of shape (H, W, 3). ```python from modules.color_correction_matrix.color_correction_matrix import ColorCorrectionMatrix parm_ccm = { "is_enable": True, "is_save": False, "corrected_red": [1.660, -0.527, -0.133], "corrected_green": [-0.408, 1.563, -0.082], "corrected_blue": [-0.055, -1.641, 2.695], } sensor_info = {"bit_depth": 12} ccm = ColorCorrectionMatrix(rgb_img, platform, sensor_info, parm_ccm) out = ccm.execute() # uint16, (H, W, 3) ``` -------------------------------- ### update_sensor_info() usage with metadata extraction Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/infinite-isp.md Usage example with dataset metadata extraction, pattern used in isp_pipeline_mulitple_images.py. Extracts raw metadata from a DNG file and updates sensor info with BLC/WB enabled. ```python from util.config_utils import extract_raw_metadata isp = InfiniteISP("./in_frames/normal/data", "./config/configs.yml") meta = extract_raw_metadata("./in_frames/normal/data/photo.dng") isp.update_sensor_info(meta, update_blc_wb=True) isp.execute() ``` -------------------------------- ### Sharpening.__init__ Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/sharpen.md Constructor for the Sharpening class. Initializes the sharpening operation with the input YUV image, platform and sensor configuration, sharpen parameters, and CSC standard. ```APIDOC ## Sharpening.__init__ ### Description Constructor for the Sharpening class. Initializes the sharpening operation with the input YUV image, platform and sensor configuration, sharpen parameters, and CSC standard. ### Method Constructor ### Signature ```python def __init__(self, img, platform, sensor_info, parm_sha, conv_std): ``` ### Parameters - **img** (numpy.ndarray (H, W, 3)) - Required - YUV image - **platform** (dict) - Required - Platform config - **sensor_info** (dict) - Required - Sensor config - **parm_sha** (dict) - Required - `sharpen` config (read: `is_enable`, `is_save`, `sharpen_sigma`, `sharpen_strength`) - **conv_std** (int) - Required - CSC standard, used for output saving ``` -------------------------------- ### AutoWhiteBalance constructor signature Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-white-balance.md Constructor for AutoWhiteBalance. Takes the raw Bayer image, sensor info (bit_depth, bayer_pattern), and auto_white_balance config (is_enable, is_debug, underexposed_percentage, overexposed_percentage, algorithm, percentage). ```python def __init__(self, raw, sensor_info, parm_awb): ``` -------------------------------- ### AutoExposure feeding the 3A loop example Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-exposure.md Iterative exposure correction loop: creates AutoExposure, passes feedback to DigitalGain, executes DigitalGain, updates current_gain. Breaks when feedback is 0 (correct exposure). ```python from modules.auto_exposure.auto_exposure import AutoExposure from modules.digital_gain.digital_gain import DigitalGain parm_ae = {"is_enable": True, "is_debug": False, "center_illuminance": 90, "histogram_skewness": 0.9} parm_dga = {"is_auto": True, "is_debug": False, "is_save": False, "gain_array": [1, 2, 4, 8], "current_gain": 0, "ae_feedback": 0} for _ in range(4): # iterative exposure correction ae = AutoExposure(rgb_img, sensor_info, parm_ae) parm_dga["ae_feedback"] = ae.execute() or 0 dg = DigitalGain(raw_img, platform, sensor_info, parm_dga) raw_img, parm_dga["current_gain"] = dg.execute() if parm_dga["ae_feedback"] == 0: break ``` -------------------------------- ### Basic usage of DeadPixelCorrection Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/dead-pixel-correction.md Example of using the DeadPixelCorrection class to correct dead pixels. Configures module parameters, sensor info, and platform settings, then executes the correction. The output has the same dtype as the input. ```python from modules.dead_pixel_correction.dead_pixel_correction import DeadPixelCorrection parm_dpc = {"is_enable": True, "dp_threshold": 80, "is_debug": True, "is_save": False} sensor_info = {"bit_depth": 12, "bayer_pattern": "rggb"} platform = {"in_file": "frame.raw", "disable_progress_bar": False, "leave_pbar_string": False} dpc = DeadPixelCorrection(raw_img, sensor_info, parm_dpc, platform) clean_img = dpc.execute() # dead pixels replaced, same dtype as input ``` -------------------------------- ### Crop.__init__ Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/crop.md Initializes the Crop object with the input image, platform config, sensor info, and crop parameters. Sets the old and new sizes and updates the sensor info dictionary when enabled. ```APIDOC ## Crop.__init__ ### Description Initializes the Crop object with the input image, platform config, sensor info, and crop parameters. Sets the old and new sizes and updates the sensor info dictionary when enabled. ### Method Constructor ### Signature ```python def __init__(self, img, platform, sensor_info, parm_cro): ``` ### Parameters - **img** (numpy.ndarray, 2D uint16) - Required - Raw Bayer image `(height, width)` - **platform** (dict) - Required - `platform` config section - **sensor_info** (dict) - Required - `sensor_info` config section (read: `height`, `width`) - **parm_cro** (dict) - Required - `crop` config section (read: `is_enable`, `is_debug`, `is_save`, `new_height`, `new_width`) ### Behavior Sets `self.old_size = (sensor_info["height"], sensor_info["width"])`, `self.new_size = (parm_cro["new_height"], parm_cro["new_width"])` and calls `update_sensor_info(sensor_info)` which mutates the passed `sensor_info` dict (height/width, plus `orig_size`) when enabled. ``` -------------------------------- ### AutoWhiteBalance constructor Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-white-balance.md Creates an AutoWhiteBalance instance to compute white balance gains from a RAW Bayer image. ```APIDOC ## AutoWhiteBalance.__init__ ### Description Initializes the AutoWhiteBalance object with the raw Bayer image, sensor information, and AWB parameters. ### Method Constructor ### Signature ```python def __init__(self, raw, sensor_info, parm_awb): ``` ### Parameters - **raw** (numpy.ndarray, 2D) - Required - Raw Bayer image. - **sensor_info** (dict) - Required - Sensor configuration; reads `bit_depth` and `bayer_pattern`. - **parm_awb** (dict) - Required - AWB configuration; reads `is_enable`, `is_debug`, `underexposed_percentage`, `overexposed_percentage`, `algorithm`, `percentage`. ### Returns None ``` -------------------------------- ### apply_gray_world() Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/auto-white-balance.md Applies the Gray World algorithm to compute white balance gains. ```APIDOC ## apply_gray_world() ### Description Applies the Gray World algorithm to compute white balance gains. ### Method Method ### Signature ```python def apply_gray_world(self): ``` ### Parameters None ### Returns - **gains** - Result of `GW(self.flatten_img).calculate_gains()`. ``` -------------------------------- ### Hardware-friendly scaling with invalid combination warning Source: https://github.com/10x-engineers/infinite-isp/blob/main/_autodocs/api-reference/scale.md Uses hardware scaling (is_hardware=True) with an unsupported output size (1000x563). The execute() method prints "Invalid output size." and returns the channel unchanged. ```python parm_sca = { "is_enable": True, "is_debug": False, "is_save": False, "new_width": 1000, "new_height": 563, # not in the supported tables "is_hardware": True, "algorithm": "Nearest_Neighbor", "upscale_method": "Nearest_Neighbor", "downscale_method": "Bilinear", } scale = Scale(rgb_img, platform, sensor_info, parm_sca, conv_std=2) scaled = scale.execute() # prints "Invalid output size."; returns channel unchanged ```