### Command-Line Examples Source: https://github.com/steffenhir/graxpert/blob/main/README.md Illustrative examples of how to use GraXpert from the command line. ```APIDOC ## Command-Line Examples These examples demonstrate GraXpert's command-line usage. Note the executable name may vary based on your OS (e.g., `GraXpert-linux`, `GraXpert.app/Contents/MacOS/GraXpert`). ### Basic Usage Performs default background extraction on `my_image.fits`. ```bash GraXpert-win64.exe my_image.fits -cli ``` ### Advanced Background Extraction Applies background extraction using AI version '1.1', 'Division' correction, '0.1' smoothing, and saves the background model. ```bash GraXpert-win64.exe my_image.fits -cli -ai_version 1.1 -correction Division -smoothing 0.1 -bg ``` ### Denoising Example Applies denoising with a strength of 0.8 and a batch size of 8. ```bash GraXpert-win64.exe my_image.fits -cli -cmd denoising -strength 0.8 -batch_size 8 ``` ``` -------------------------------- ### Install Requirements (Windows/Linux) Source: https://github.com/steffenhir/graxpert/blob/main/README.md Install all project dependencies listed in 'requirements.txt' using pip on Windows or Linux. Ensure the virtual environment is activated. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install Requirements (macOS) Source: https://github.com/steffenhir/graxpert/blob/main/README.md Install all project dependencies listed in 'requirements.txt' using pip3 on macOS. Ensure the virtual environment is activated. ```bash pip3 install -r requirements.txt ``` -------------------------------- ### Run GraXpert Application Source: https://github.com/steffenhir/graxpert/blob/main/README.md Execute the GraXpert main module using Python. This command should be run after setting up the virtual environment and installing all required packages. ```bash python -m graxpert.main ``` -------------------------------- ### Check GraXpert Version CLI Source: https://context7.com/steffenhir/graxpert/llms.txt Display the installed version of the GraXpert CLI tool. ```bash GraXpert-linux -v ``` -------------------------------- ### Create Python Virtual Environment (Linux/macOS) Source: https://github.com/steffenhir/graxpert/blob/main/README.md Use this command to create a new virtual environment named 'graxpert-env' on Linux or macOS. Ensure Python 3.10 or later is installed. ```bash python3 -m venv graxpert-env ``` -------------------------------- ### Create Python Virtual Environment (Windows) Source: https://github.com/steffenhir/graxpert/blob/main/README.md Use this command to create a new virtual environment named 'graxpert-env' on Windows. Ensure Python 3.10 or later is installed. ```bash python -m venv graxpert-env ``` -------------------------------- ### Install Tkinter (macOS) Source: https://github.com/steffenhir/graxpert/blob/main/README.md For macOS users, install the Python Tkinter library using Homebrew, specifically version 3.10, to resolve potential compatibility issues with newer macOS versions like Sonoma. ```bash brew install python-tk@3.10 ``` -------------------------------- ### Clone the GraXpert repository Source: https://github.com/steffenhir/graxpert/blob/main/README.md Download the source code from GitHub to begin development. ```bash git clone https://github.com/Steffenhir/GraXpert cd GraXpert ``` -------------------------------- ### Manage Preferences Source: https://context7.com/steffenhir/graxpert/llms.txt Imports for handling application preferences and configuration files. ```python from graxpert.preferences import Prefs, load_preferences, save_preferences import os from appdirs import user_config_dir ``` -------------------------------- ### Make GraXpert executable on Linux Source: https://github.com/steffenhir/graxpert/blob/main/README.md Set the execution permission for the GraXpert binary on Linux systems. ```bash chmod u+x ./GraXpert-linux ``` -------------------------------- ### Complete Image Processing Pipeline Source: https://context7.com/steffenhir/graxpert/llms.txt Demonstrates a full image processing workflow including loading, background extraction, denoising using AI models, and saving. Ensure necessary GraXpert modules and numpy are imported. ```python from graxpert.astroimage import AstroImage from graxpert.background_extraction import extract_background from graxpert.denoising import denoise from graxpert.ai_model_handling import ( ai_model_path_from_version, bge_ai_models_dir, denoise_ai_models_dir, latest_version, download_version, list_local_versions ) from graxpert.s3_secrets import bge_bucket_name, denoise_bucket_name import numpy as np # Load the astronomical image input_image = AstroImage(do_update_display=False) input_image.set_from_file("/path/to/raw_image.fits", None, None) # Ensure AI models are available bge_version = latest_version(bge_ai_models_dir, bge_bucket_name) if bge_version not in [v["version"] for v in list_local_versions(bge_ai_models_dir)]: download_version(bge_ai_models_dir, bge_bucket_name, bge_version) denoise_version = latest_version(denoise_ai_models_dir, denoise_bucket_name) if denoise_version not in [v["version"] for v in list_local_versions(denoise_ai_models_dir)]: download_version(denoise_ai_models_dir, denoise_bucket_name, denoise_version) # Step 1: Background Extraction bge_model_path = ai_model_path_from_version(bge_ai_models_dir, bge_version) background = extract_background( in_imarray=input_image.img_array, background_points=np.array([]), interpolation_type="AI", smoothing=0.1, downscale_factor=1, sample_size=25, RBF_kernel="thin_plate", spline_order=3, corr_type="Subtraction", ai_path=bge_model_path, ai_gpu_acceleration=True ) # Step 2: Denoising denoise_model_path = ai_model_path_from_version(denoise_ai_models_dir, denoise_version) denois ed_array = denoise( image=input_image.img_array, ai_path=denoise_model_path, strength=0.5, batch_size=4, ai_gpu_acceleration=True ) ``` -------------------------------- ### Activate Virtual Environment (Windows) Source: https://github.com/steffenhir/graxpert/blob/main/README.md Activate the 'graxpert-env' virtual environment on Windows to isolate project dependencies. This command should be run after creating the environment. ```bash graxpert-env\Scripts\activate ``` -------------------------------- ### Activate Virtual Environment (Linux/macOS) Source: https://github.com/steffenhir/graxpert/blob/main/README.md Activate the 'graxpert-env' virtual environment on Linux or macOS to isolate project dependencies. This command should be run after creating the environment. ```bash source graxpert-env/bin/activate ``` -------------------------------- ### Execute basic background extraction via CLI Source: https://github.com/steffenhir/graxpert/blob/main/README.md Run the default background extraction on an image file using the command-line interface. ```bash GraXpert-win64.exe my_image.fits -cli ``` -------------------------------- ### Load and Modify User Preferences Source: https://context7.com/steffenhir/graxpert/llms.txt Demonstrates loading preferences from a JSON file, viewing current settings, modifying them, and saving the changes. This is useful for interactive adjustments. ```python prefs_filename = os.path.join(user_config_dir(appname="GraXpert"), "preferences.json") prefs = load_preferences(prefs_filename) # View current settings print(f"Interpolation type: {prefs.interpol_type_option}") print(f"Smoothing: {prefs.smoothing_option}") print(f"Correction type: {prefs.corr_type}") print(f"GPU acceleration: {prefs.ai_gpu_acceleration}") # Modify preferences for processing prefs.interpol_type_option = "AI" prefs.smoothing_option = 0.2 prefs.corr_type = "Subtraction" prefs.bge_ai_version = "1.1.0" prefs.denoise_strength = 0.6 prefs.deconvolution_strength = 0.5 prefs.deconvolution_psfsize = 3.5 prefs.ai_batch_size = 8 prefs.ai_gpu_acceleration = True prefs.saveas_option = "32 bit Fits" # Save preferences save_preferences(prefs_filename, prefs) ``` -------------------------------- ### GraXpert Command-Line Arguments Source: https://github.com/steffenhir/graxpert/blob/main/README.md Overview of the general command-line arguments available for GraXpert's AI operations. ```APIDOC ## GraXpert Command-Line Usage GraXpert offers a command-line interface for its AI-powered operations, allowing for automated processing without the graphical user interface. ### General Arguments - **-cmd [image_operation]** (string) - Specifies the AI operation to perform. Options: "background-extraction" (default), "denoising". - **filename** (string) - The path to the input image file (required). - **-cli** (flag) - Must be included to enable command-line integration; otherwise, the GUI will launch. - **-output [output_file_name]** (string) - Specifies the name for the output image file (without extension). If omitted, '_GraXpert' is appended to the original filename. - **-preferences_file** (string) - Path to a preferences file containing background grid points for extraction methods. - **-gpu** (boolean) - Set to 'false' to disable GPU acceleration for AI inference. Defaults to 'true' to enable it. - **-ai_version [version]** (string) - Specifies the AI model version to use. Defaults to the latest available version. Can be a locally or remotely available version. ``` -------------------------------- ### Apply Image Stretching with Presets Source: https://context7.com/steffenhir/graxpert/llms.txt Applies Midtone Transfer Function (MTF) stretching to astronomical images using predefined stretch options. Ensure numpy and graxpert.stretch are imported. ```python from graxpert.stretch import stretch, StretchParameters, MTF import numpy as np # Create stretch parameters with preset stretch_params = StretchParameters( stretch_option="15% Bg, 3 sigma", # "No Stretch", "10% Bg, 3 sigma", # "15% Bg, 3 sigma", "20% Bg, 3 sigma", # "30% Bg, 2 sigma" channels_linked=False, # Process channels independently images_linked=False ) # Apply stretch to image linear_image = np.random.rand(1000, 1500, 3).astype(np.float32) * 0.3 # Dark image stretched_image = stretch(linear_image, stretch_params) # Manual MTF calculation for custom stretching data = np.random.rand(100, 100).astype(np.float32) midtone = 0.25 # Target midtone level stretched = MTF(data.copy(), midtone) # Access stretch parameters print(f"Background level: {stretch_params.bg}") print(f"Sigma: {stretch_params.sigma}") print(f"Do stretch: {stretch_params.do_stretch}") ``` -------------------------------- ### GraXpert CLI Commands Source: https://context7.com/steffenhir/graxpert/llms.txt This section details the various commands available through the GraXpert command-line interface for batch processing and automation. ```APIDOC ## GraXpert CLI Commands ### Description Provides a comprehensive CLI for automated image processing without the GUI. Supports background extraction, denoising, and deconvolution operations with configurable AI model versions and processing parameters. ### Basic Background Extraction ```bash GraXpert-linux my_image.fits -cli ``` ### Advanced Background Extraction ```bash GraXpert-linux my_image.fits -cli -cmd background-extraction \ -ai_version 1.1.0 \ -correction Division \ -smoothing 0.1 \ -bg \ -output processed_image ``` ### Denoising ```bash GraXpert-linux my_image.fits -cli -cmd denoising \ -strength 0.7 \ -batch_size 4 \ -gpu true ``` ### Object Deconvolution ```bash GraXpert-linux my_image.fits -cli -cmd deconv-obj \ -strength 0.5 \ -psfsize 3.0 \ -batch_size 4 ``` ### Stellar Deconvolution ```bash GraXpert-linux my_image.fits -cli -cmd deconv-stellar \ -strength 0.6 \ -psfsize 2.5 \ -output sharpened_stars ``` ### Check Version ```bash GraXpert-linux -v ``` ``` -------------------------------- ### Stellar Deconvolution CLI Source: https://context7.com/steffenhir/graxpert/llms.txt Sharpen stars using stellar deconvolution via the CLI, specifying strength, PSF size, and output file. ```bash GraXpert-linux my_image.fits -cli -cmd deconv-stellar \ -strength 0.6 \ -psfsize 2.5 \ -output sharpened_stars ``` -------------------------------- ### Basic AI Background Extraction CLI Source: https://context7.com/steffenhir/graxpert/llms.txt Perform basic background extraction using the AI model via the command-line interface. No manual sample points are required. ```bash GraXpert-linux my_image.fits -cli ``` -------------------------------- ### Manage AI Models Source: https://context7.com/steffenhir/graxpert/llms.txt Provides utilities to list, download, and validate AI model versions from local or remote storage. ```python from graxpert.ai_model_handling import ( list_local_versions, list_remote_versions, download_version, latest_version, ai_model_path_from_version, bge_ai_models_dir, denoise_ai_models_dir, deconvolution_object_ai_models_dir, deconvolution_stars_ai_models_dir ) from graxpert.s3_secrets import ( bge_bucket_name, denoise_bucket_name, deconvolution_object_bucket_name, deconvolution_stars_bucket_name ) # List available local AI model versions local_bge_models = list_local_versions(bge_ai_models_dir) print(f"Local BGE models: {[m['version'] for m in local_bge_models]}") local_denoise_models = list_local_versions(denoise_ai_models_dir) print(f"Local denoise models: {[m['version'] for m in local_denoise_models]}") # List available remote versions remote_bge_models = list_remote_versions(bge_bucket_name) print(f"Remote BGE models: {[m['version'] for m in remote_bge_models]}") # Get latest version (checks both local and remote) latest_bge = latest_version(bge_ai_models_dir, bge_bucket_name) print(f"Latest BGE version: {latest_bge}") # Download a specific version download_version( ai_models_dir=denoise_ai_models_dir, bucket_name=denoise_bucket_name, target_version="1.1.0" ) # Get model path for a version model_path = ai_model_path_from_version(bge_ai_models_dir, "1.1.0") # Returns: /path/to/bge-ai-models/1.1.0/model.onnx ``` -------------------------------- ### Denoising with Strength Control CLI Source: https://context7.com/steffenhir/graxpert/llms.txt Apply AI-powered denoising to an image using the CLI, controlling the denoising strength and batch size for GPU processing. ```bash GraXpert-linux my_image.fits -cli -cmd denoising \ -strength 0.7 \ -batch_size 4 \ -gpu true ``` -------------------------------- ### Customized Background Extraction CLI Source: https://context7.com/steffenhir/graxpert/llms.txt Execute background extraction with custom AI model version, correction type, and smoothing parameters. Specify output file. ```bash GraXpert-linux my_image.fits -cli -cmd background-extraction \ -ai_version 1.1.0 \ -correction Division \ -smoothing 0.1 \ -bg \ -output processed_image ``` -------------------------------- ### Background Extraction Command-Line Options Source: https://github.com/steffenhir/graxpert/blob/main/README.md Specific arguments for the background extraction AI operation. ```APIDOC ### Background Extraction Specific Arguments - **-correction [type]** (string) - Selects the background correction method. Options: "Subtraction" (default), "Division". - **-smoothing [strength]** (float) - Adjusts the strength of smoothing applied during background extraction. Range: 0.0 (no smoothing) to 1.0 (maximum smoothing). - **-bg** (flag) - If present, the generated background model will also be saved. ``` -------------------------------- ### Execute advanced background extraction via CLI Source: https://github.com/steffenhir/graxpert/blob/main/README.md Perform background extraction with specific AI version, correction type, smoothing, and background model saving. ```bash GraXpert-win64.exe my_image.fits -cli -ai_version 1.1 -correction Division -smoothing 0.1 -bg ``` -------------------------------- ### Denoising Command-Line Options Source: https://github.com/steffenhir/graxpert/blob/main/README.md Specific arguments for the denoising AI operation. ```APIDOC ### Denoising Specific Arguments - **-strength [value]** (float) - Adjusts the strength of the denoising effect. Range: 0.0 (minimum) to 1.0 (maximum). Default: "0.5". - **-batch_size [value]** (integer) - Sets the number of image tiles to denoise in parallel. Warning: Increasing this value may lead to out-of-memory errors. Valid Range: 1 to 32. Default: "4". ``` -------------------------------- ### Create Preferences JSON for CLI Batch Processing Source: https://context7.com/steffenhir/graxpert/llms.txt Generates a JSON file containing preferences specifically for command-line interface (CLI) batch processing. This allows for reproducible and automated workflows. ```python import json batch_prefs = { "interpol_type_option": "RBF", "RBF_kernel": "thin_plate", "smoothing_option": 0.3, "corr_type": "Subtraction", "sample_size": 25, "background_points": [[100, 200], [500, 300], [900, 400]], "ai_gpu_acceleration": True } with open("batch_preferences.json", "w") as f: json.dump(batch_prefs, f) ``` -------------------------------- ### Object Deconvolution CLI Source: https://context7.com/steffenhir/graxpert/llms.txt Perform object deconvolution for nebulae and galaxies using the CLI, adjusting strength and PSF size. ```bash GraXpert-linux my_image.fits -cli -cmd deconv-obj \ -strength 0.5 \ -psfsize 3.0 \ -batch_size 4 ``` -------------------------------- ### Manage Astronomical Images Source: https://context7.com/steffenhir/graxpert/llms.txt Handles loading, processing, and saving of astronomical images including FITS header manipulation. ```python from graxpert.astroimage import AstroImage from graxpert.stretch import StretchParameters # Load an astronomical image astro_img = AstroImage(do_update_display=False) astro_img.set_from_file( directory="/path/to/image.fits", stretch_params=None, saturation=1.0 ) # Access image properties print(f"Image dimensions: {astro_img.width} x {astro_img.height}") print(f"Number of channels: {astro_img.img_array.shape[-1]}") print(f"Image format: {astro_img.img_format}") # Access and modify FITS header if astro_img.fits_header: print(f"Object: {astro_img.fits_header.get('OBJECT', 'Unknown')}") astro_img.fits_header['COMMENT'] = 'Processed with GraXpert' # Create output image from processed array output_img = AstroImage(do_update_display=False) output_img.set_from_array(processed_array) output_img.fits_header = astro_img.fits_header # Save in different formats output_img.save("/path/to/output.fits", "32 bit Fits") output_img.save("/path/to/output.xisf", "32 bit XISF") output_img.save("/path/to/output.tiff", "16 bit Tiff") # Crop image astro_img.crop(startx=100, endx=900, starty=50, endy=750) # Get local median at a point (useful for sample point selection) median_rgb = astro_img.get_local_median([500, 300]) ``` -------------------------------- ### Denoising Python Source: https://context7.com/steffenhir/graxpert/llms.txt Apply AI-powered denoising to an image array. Specify the AI model path, denoising strength, and batch size for GPU acceleration. ```python from graxpert.denoising import denoise import numpy as np # Load image data (normalized 0-1 float32) image_array = np.random.rand(2000, 3000, 3).astype(np.float32) ai_model_path = "/path/to/denoise-ai-models/1.0.0/model.onnx" # Apply denoising with medium strength denois ed_image = denoise( image=image_array, ai_path=ai_model_path, strength=0.5, # 0.0 (minimum) to 1.0 (maximum) batch_size=4, # Tiles processed in parallel (1-32, power of 2) window_size=256, # Tile size stride=128, # Tile overlap ai_gpu_acceleration=True ) ``` -------------------------------- ### Perform AI Deconvolution Source: https://context7.com/steffenhir/graxpert/llms.txt Applies AI-based deconvolution for sharpening nebulae, galaxies, or stars. Requires specifying the model path and PSF size. ```python from graxpert.deconvolution import deconvolve import numpy as np # Load image data image_array = np.random.rand(2000, 3000, 3).astype(np.float32) # Object deconvolution for nebulae/galaxies obj_model_path = "/path/to/deconvolution-object-ai-models/1.0.1/model.onnx" deconvolved = deconvolve( image=image_array, ai_path=obj_model_path, strength=0.5, # 0.0 to 1.0 effect strength psfsize=5.0, # Point spread function size (seeing in pixels) batch_size=4, window_size=512, stride=448, ai_gpu_acceleration=True ) # Stellar deconvolution for sharper stars stellar_model_path = "/path/to/deconvolution-stars-ai-models/1.0.0/model.onnx" deconvolved = deconvolve( image=image_array, ai_path=stellar_model_path, strength=0.7, psfsize=3.0, # Typical seeing conditions batch_size=4, ai_gpu_acceleration=True ) ``` -------------------------------- ### Save processed images and background models Source: https://context7.com/steffenhir/graxpert/llms.txt Use the AstroImage class to save processed arrays to FITS files. Ensure the FITS header is updated to maintain metadata continuity. ```python output_image = AstroImage(do_update_display=False) output_image.set_from_array(denoised_array) output_image.fits_header = input_image.fits_header output_image.fits_header['HISTORY'] = 'Background extracted with GraXpert AI' output_image.fits_header['HISTORY'] = 'Denoised with GraXpert AI' output_image.fits_header['BGE-AI-VER'] = bge_version output_image.fits_header['DENOISE-VER'] = denoise_version output_image.save("/path/to/processed_image.fits", "32 bit Fits") # Also save the background model background_image = AstroImage(do_update_display=False) background_image.set_from_array(background) background_image.fits_header = input_image.fits_header background_image.save("/path/to/background_model.fits", "32 bit Fits") print("Processing complete!") ``` -------------------------------- ### Strong Denoising Python Source: https://context7.com/steffenhir/graxpert/llms.txt Apply strong AI-powered denoising for very noisy images. Increase batch size for potentially faster GPU processing. ```python # Strong denoising for very noisy images denois ed_image = denoise( image=image_array, ai_path=ai_model_path, strength=0.9, batch_size=8, # Increase for faster GPU processing ai_gpu_acceleration=True ) ``` -------------------------------- ### Perform AI Denoising Source: https://context7.com/steffenhir/graxpert/llms.txt Executes AI-based denoising on an image array. Set ai_gpu_acceleration to False for CPU-only processing. ```python denoised_image = denoise( image=image_array, ai_path=ai_model_path, strength=0.5, batch_size=2, ai_gpu_acceleration=False ) ``` -------------------------------- ### Denoising Function (Python API) Source: https://context7.com/steffenhir/graxpert/llms.txt The `denoise` function applies AI-powered noise reduction to astronomical images with adjustable strength. ```APIDOC ## Denoising Function (Python API) ### Description The `denoise` function applies AI-powered noise reduction to astronomical images with adjustable strength. It processes images in tiles for memory efficiency and supports batch processing for GPU optimization. ### Method ```python from graxpert.denoising import denoise import numpy as np ``` ### Parameters - **image** (numpy.ndarray) - Input image data (normalized 0-1 float32). - **ai_path** (str) - Path to the denoising AI model. - **strength** (float) - Denoising strength (0.0 to 1.0). - **batch_size** (int) - Number of tiles processed in parallel (1-32, power of 2). - **window_size** (int) - Size of the processing tiles. - **stride** (int) - Overlap between tiles. - **ai_gpu_acceleration** (bool) - Enable GPU acceleration for AI. ### Request Example (Medium Strength) ```python image_array = np.random.rand(2000, 3000, 3).astype(np.float32) ai_model_path = "/path/to/denoise-ai-models/1.0.0/model.onnx" denois ed_image = denoise( image=image_array, ai_path=ai_model_path, strength=0.5, batch_size=4, window_size=256, stride=128, ai_gpu_acceleration=True ) ``` ### Request Example (Strong Strength) ```python image_array = np.random.rand(2000, 3000, 3).astype(np.float32) ai_model_path = "/path/to/denoise-ai-models/1.0.0/model.onnx" denois ed_image = denoise( image=image_array, ai_path=ai_model_path, strength=0.9, batch_size=8, ai_gpu_acceleration=True ) ``` ``` -------------------------------- ### Background Extraction Function (Python API) Source: https://context7.com/steffenhir/graxpert/llms.txt The `extract_background` function is the core processing function that removes gradients from astronomical images using either AI or traditional interpolation methods. ```APIDOC ## Background Extraction Function (Python API) ### Description The `extract_background` function removes gradients from astronomical images using either AI or traditional interpolation methods. It supports multiple interpolation types and correction methods with configurable smoothing. ### Method ```python from graxpert.background_extraction import extract_background import numpy as np ``` ### AI-based Background Extraction #### Parameters - **in_imarray** (numpy.ndarray) - Input image data. - **background_points** (numpy.ndarray) - Empty array for AI method. - **interpolation_type** (str) - Set to "AI". - **smoothing** (float) - Smoothing factor (0.0 to 1.0). - **downscale_factor** (int) - Factor to downscale the image for processing. - **sample_size** (int) - Size of samples for interpolation. - **RBF_kernel** (str) - Kernel type for RBF interpolation (not used for AI). - **spline_order** (int) - Order of splines (not used for AI). - **corr_type** (str) - Correction type: "Subtraction" or "Division". - **ai_path** (str) - Path to the AI model. - **ai_gpu_acceleration** (bool) - Enable GPU acceleration for AI. #### Request Example ```python image_array = np.random.rand(2000, 3000, 3).astype(np.float32) ai_model_path = "/path/to/ai-models/1.1.0/model.onnx" background = extract_background( in_imarray=image_array, background_points=np.array([]), # Empty for AI method interpolation_type="AI", smoothing=0.1, downscale_factor=1, sample_size=25, RBF_kernel="thin_plate", spline_order=3, corr_type="Subtraction", ai_path=ai_model_path, ai_gpu_acceleration=True ) ``` ### Traditional RBF Interpolation #### Parameters - **in_imarray** (numpy.ndarray) - Input image data. - **background_points** (numpy.ndarray) - Array of [x, y] coordinates for background sample points. - **interpolation_type** (str) - Set to "RBF", "Splines", or "Kriging". - **smoothing** (float) - Smoothing factor. - **downscale_factor** (int) - Factor to downscale the image for processing. - **sample_size** (int) - Size of samples for interpolation. - **RBF_kernel** (str) - Kernel type for RBF interpolation: "thin_plate", "linear", "cubic". - **spline_order** (int) - Order of splines. - **corr_type** (str) - Correction type: "Subtraction" or "Division". - **ai_path** (str) - Path to the AI model (set to None for traditional methods). - **ai_gpu_acceleration** (bool) - Enable GPU acceleration for AI (set to False for traditional methods). #### Request Example ```python image_array = np.random.rand(2000, 3000, 3).astype(np.float32) background_points = np.array([ [100, 200], [500, 300], [800, 150], [1200, 400], [300, 600], [900, 550] ]) background = extract_background( in_imarray=image_array, background_points=background_points, interpolation_type="RBF", smoothing=0.5, downscale_factor=4, sample_size=25, RBF_kernel="thin_plate", spline_order=3, corr_type="Subtraction", ai_path=None, ai_gpu_acceleration=False ) ``` ``` -------------------------------- ### AI Background Extraction Python Source: https://context7.com/steffenhir/graxpert/llms.txt Extract background gradients from an image array using AI. No background sample points are needed. Ensure the AI model path is correct. ```python from graxpert.background_extraction import extract_background import numpy as np # AI-based background extraction (no sample points needed) image_array = np.random.rand(2000, 3000, 3).astype(np.float32) # RGB image ai_model_path = "/path/to/ai-models/1.1.0/model.onnx" background = extract_background( in_imarray=image_array, background_points=np.array([]), # Empty for AI method interpolation_type="AI", smoothing=0.1, # 0.0 to 1.0 downscale_factor=1, sample_size=25, RBF_kernel="thin_plate", spline_order=3, corr_type="Subtraction", # "Subtraction" or "Division" ai_path=ai_model_path, ai_gpu_acceleration=True ) # image_array is modified in-place with gradient removed ``` -------------------------------- ### RBF Background Extraction Python Source: https://context7.com/steffenhir/graxpert/llms.txt Perform background extraction using Radial Basis Functions (RBF) interpolation with manually selected background sample points. Specify RBF kernel and smoothing. ```python # Traditional RBF interpolation with manual sample points background_points = np.array([ [100, 200], [500, 300], [800, 150], [1200, 400], [300, 600], [900, 550] ]) background = extract_background( in_imarray=image_array, background_points=background_points, interpolation_type="RBF", # "RBF", "Splines", or "Kriging" smoothing=0.5, downscale_factor=4, # Downscale for faster processing sample_size=25, RBF_kernel="thin_plate", # "thin_plate", "linear", "cubic" spline_order=3, corr_type="Subtraction", ai_path=None, ai_gpu_acceleration=False ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.