CAST-LUT: Tokenizer-Guided HSV Look-Up Tables for Purple Flare Removal
Extracted source text · arXiv 2511.06764
%File: anonymous-submission-latex-2026.tex
\documentclass[letterpaper]{article} % DO NOT CHANGE THIS
%\usepackage[submission]{aaai2026} % DO NOT CHANGE THIS
\usepackage{aaai2026}
\usepackage{times} % DO NOT CHANGE THIS
\usepackage{helvet} % DO NOT CHANGE THIS
\usepackage{courier} % DO NOT CHANGE THIS
\usepackage[hyphens]{url} % DO NOT CHANGE THIS
\usepackage{graphicx} % DO NOT CHANGE THIS
\usepackage{multirow} % 用于合并多行单元格
\usepackage{makecell}
\urlstyle{rm} % DO NOT CHANGE THIS
\def\UrlFont{\rm} % DO NOT CHANGE THIS
\usepackage{natbib} % DO NOT CHANGE THIS AND DO NOT ADD ANY OPTIONS TO IT
\usepackage{caption} % DO NOT CHANGE THIS AND DO NOT ADD ANY OPTIONS TO IT
\frenchspacing % DO NOT CHANGE THIS
\setlength{\pdfpagewidth}{8.5in} % DO NOT CHANGE THIS
\setlength{\pdfpageheight}{11in} % DO NOT CHANGE THIS
%
% These are recommended to typeset algorithms but not required. See the subsubsection on algorithms. Remove them if you don't have algorithms in your paper.
\usepackage{algorithm}
%\usepackage{algorithmic}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage{amssymb}
\usepackage{amsmath} % 数学公式支持
\usepackage{bm} % 更好的粗体控制
\usepackage{tabularx}
% 添加代码高亮支持
\usepackage{listings}
\usepackage{xcolor}
\lstset{
basicstyle=\ttfamily,
keywordstyle=\color{blue},
commentstyle=\color{green},
stringstyle=\color{red},
showstringspaces=false,
breaklines=true
}
\usepackage{booktabs}
%
% These are are recommended to typeset listings but not required. See the subsubsection on listing. Remove this block if you don't have listings in your paper.
\usepackage{newfloat}
\usepackage{listings}
\DeclareCaptionStyle{ruled}{labelfont=normalfont,labelsep=colon,strut=off} % DO NOT CHANGE THIS
\lstset{%
basicstyle={\footnotesize\ttfamily},% footnotesize acceptable for monospace
numbers=left,numberstyle=\footnotesize,xleftmargin=2em,% show line numbers, remove this entire line if you don't want the numbers.
aboveskip=0pt,belowskip=0pt,%
showstringspaces=false,tabsize=2,breaklines=true}
\floatstyle{ruled}
\newfloat{listing}{tb}{lst}{}
\floatname{listing}{Listing}
%
% Keep the \pdfinfo as shown here. There's no need
% for you to add the /Title and /Author tags.
\pdfinfo{
/TemplateVersion (2026.1)
}
% DISALLOWED PACKAGES
% \usepackage{authblk} -- This package is specifically forbidden
% \usepackage{balance} -- This package is specifically forbidden
% \usepackage{color (if used in text)
% \usepackage{CJK} -- This package is specifically forbidden
% \usepackage{float} -- This package is specifically forbidden
% \usepackage{flushend} -- This package is specifically forbidden
% \usepackage{fontenc} -- This package is specifically forbidden
% \usepackage{fullpage} -- This package is specifically forbidden
% \usepackage{geometry} -- This package is specifically forbidden
% \usepackage{grffile} -- This package is specifically forbidden
% \usepackage{hyperref} -- This package is specifically forbidden
% \usepackage{navigator} -- This package is specifically forbidden
% (or any other package that embeds links such as navigator or hyperref)
% \indentfirst} -- This package is specifically forbidden
% \layout} -- This package is specifically forbidden
% \multicol} -- This package is specifically forbidden
% \nameref} -- This package is specifically forbidden
% \usepackage{savetrees} -- This package is specifically forbidden
% \usepackage{setspace} -- This package is specifically forbidden
% \usepackage{stfloats} -- This package is specifically forbidden
% \usepackage{tabu} -- This package is specifically forbidden
% \usepackage{titlesec} -- This package is specifically forbidden
% \usepackage{tocbibind} -- This package is specifically forbidden
% \usepackage{ulem} -- This package is specifically forbidden
% \usepackage{wrapfig} -- This package is specifically forbidden
% DISALLOWED COMMANDS
% \nocopyright -- Your paper will not be published if you use this command
% \addtolength -- This command may not be used
% \balance -- This command may not be used
% \baselinestretch -- Your paper will not be published if you use this command
% \clearpage -- No page breaks of any kind may be used for the final version of your paper
% \columnsep -- This command may not be used
% \newpage -- No page breaks of any kind may be used for the final version of your paper
% \pagebreak -- No page breaks of any kind may be used for the final version of your paper
% \pagestyle -- This command may not be used
% \tiny -- This is not an acceptable font size.
% \vspace{- -- No negative value may be used in proximity of a caption, figure, table, section, subsection, subsubsection, or reference
% \vskip{- -- No negative value may be used to alter spacing above or below a caption, figure, table, section, subsection, subsubsection, or reference
\newcommand{\dist}{\text{dist}}
\setcounter{secnumdepth}{0} %May be changed to 1 or 2 if section numbers are desired.
% The file aaai2026.sty is the style file for AAAI Press
% proceedings, working notes, and technical reports.
%
% Title
% Your title must be in mixed case, not sentence case.
% That means all verbs (including short verbs like be, is, using, and go),
% nouns, adverbs, and adjectives should be capitalized, including both words in hyphenated terms, while
% articles, conjunctions, and prepositions are lower case unless they
% directly follow a colon or long dash
% \title{A Novel Network Based on Decoupled HSV Look-Up Tables to Reduce Purple Flare}
\title{CAST-LUT: Tokenizer-Guided HSV Look-Up Tables for Purple Flare Removal}
\author {
% Authors
Pu Wang \textsuperscript{\rm 1},
Shuning Sun\textsuperscript{\rm 2},
Jialang Lu\textsuperscript{\rm 3},
Chen Wu\textsuperscript{\rm 4},
Zhihua Zhang\textsuperscript{\rm 1},
Youshan Zhang\textsuperscript{\rm 5},
Chenggang Shan\textsuperscript{\rm 6},
Dianjie Lu\textsuperscript{\rm 7},
Guijuan Zhang\textsuperscript{\rm 7},
Zhuoran Zheng\textsuperscript{\rm 8 }
}
\affiliations {
% Affiliations
\textsuperscript{\rm 1} Shandong University\\
\textsuperscript{\rm 2}University of the Chinese Academy of Sciences\\
\textsuperscript{\rm 3}Hubei University\\
\textsuperscript{\rm 4}University of Science and Technology of China\\
\textsuperscript{\rm 5} Yeshiva University\\
\textsuperscript{\rm 6} Zaozhuang University\\
\textsuperscript{\rm 7} Shandong Normal University\\
\textsuperscript{\rm 8} Qilu University of Technology\\
wangou@mail.sdu.edu.cn, sunshuning23@mails.ucas.ac.cn, lujialang@stu.hubu.edu.cn,
wuchen5X@mail.ustc.edu.cn,
zhangzhihua@sdu.edu.cn,
yz945@cornell.edu,
shanchenggang@uzz.edu.cn,
\{ludianjie, zhangguijuan\}@sdnu.edu.cn,
zhengzr@njust.edu.cn
}
%CAST-LUT: Guiding Decoupled HSV Lookup Tables with a Chroma-Aware Spectral Tokenizer for Purple Flare Removal
% \author{
% %Authors
% % All authors must be in the same font size and format.
% Written by AAAI Press Staff\textsuperscript{\rm 1}\thanks{With help from the AAAI Publications Committee.}\\
% AAAI Style Contributions by Pater Patel Schneider,
% Sunil Issar,\\
% J. Scott Penberthy,
% George Ferguson,
% Hans Guesgen,
% Francisco Cruz\equalcontrib,
% Marc Pujol-Gonzalez\equalcontrib
% }
% \affiliations{
% %Afiliations
% \textsuperscript{\rm 1}Association for the Advancement of Artificial Intelligence\\
% % If you have multiple authors and multiple affiliations
% % Use superscripts in text and roman font to identify them.
% % For example,
% % Sunil Issar\textsuperscript{\rm 2},
% % J. Scott Penberthy\textsuperscript{\rm 3},
% % George Ferguson\textsuperscript{\rm 4},
% % Hans Guesgen\textsuperscript{\rm 5}
% % Note that the comma should be placed after the superscript
% 1101 Pennsylvania Ave, NW Suite 300\\
% Washington, DC 20004 USA\\
% % email address must be in roman text type, not monospace or sans serif
% proceedings-questions@aaai.org
% %
% % See more examples next
% }
%Example, Single Author, ->> remove \iffalse,\fi and place them surrounding AAAI title to use it
\iffalse
\title{My Publication Title --- Single Author}
\author {
Author Name
}
\affiliations{
Affiliation\\
Affiliation Line 2\\
name@example.com
}
\fi
\iffalse
%Example, Multiple Authors, ->> remove \iffalse,\fi and place them surrounding AAAI title to use it
\title{My Publication Title --- Multiple Authors}
\author {
% Authors
First Author Name\textsuperscript{\rm 1},
Second Author Name\textsuperscript{\rm 2},
Third Author Name\textsuperscript{\rm 1}
}
\affiliations {
% Affiliations
\textsuperscript{\rm 1}Affiliation 1\\
\textsuperscript{\rm 2}Affiliation 2\\
firstAuthor@affiliation1.com, secondAuthor@affilation2.com, thirdAuthor@affiliation1.com
}
\fi
% REMOVE THIS: bibentry
% This is only needed to show inline citations in the guidelines document. You should not need it and can safely delete it.
\usepackage{bibentry}
% END REMOVE bibentry
\begin{document}
\maketitle
%HSV-LUT和RGB—LUT不同,Loss fuaction,3DLut在RGB上的,我可以在HSV上试一下(讨论部分,HSVLUT,总结),手机部署
\begin{abstract}
% Purple flare is a diffuse chromatic aberration artifact commonly found around highlight areas, which severely degrades the tone transition and color of the image.
Purple flare, a diffuse chromatic aberration artifact commonly found around highlight areas, severely degrades the tone transition and color of the image. Existing traditional methods are based on hand-crafted features, which lack flexibility and rely entirely on fixed priors,
while the scarcity of paired training data critically hampers deep learning. To address this issue, we propose a novel network built upon decoupled HSV Look-Up Tables (LUTs). The method aims to simplify color correction by adjusting the Hue (H), Saturation (S), and Value (V) components independently. This approach resolves the inherent color coupling problems in traditional methods. Our model adopts a two-stage architecture: First, a Chroma-Aware Spectral Tokenizer (CAST) converts the input image from RGB space to HSV space and independently encodes the Hue (H) and Value (V) channels into a set of semantic tokens describing the Purple flare status; second, the HSV-LUT module takes these tokens as input and dynamically generates independent correction curves (1D-LUTs) for the three channels H, S, and V. To effectively train and validate our model, we built the first large-scale purple flare dataset with diverse scenes. We also proposed new metrics and a loss function specifically designed for this task. Extensive experiments demonstrate that our model not only significantly outperforms existing methods in visual effects but also achieves state-of-the-art performance on all quantitative metrics.
% Purple flare, a common chromatic aberration, degrades image quality by corrupting color fidelity and detail. Existing methods often fail, as operating in the coupled RGB space leads to color crosstalk, while naive HSV transformations can introduce new artifacts. We propose the CAST-LUT, a novel framework operating on a ``perceive-then-correct'' principle within the decoupled HSV space. It first uses a Chroma-Aware Spectral Tokenizer (CAST) to diagnose the flare as semantic tokens. These tokens then guide a lightweight module to generate independent, per-channel 1D Look-Up Tables (LUTs) for precise correction, with the model being optimized by a custom flare-suppression loss. To enable robust evaluation, we created the first large-scale dataset for this task and propose novel flare-specific metrics, including PSNR-F/NF and HAE. Experiments confirm that CAST-LUT establishes a new state-of-the-art in both quantitative and visual results. Code is available at .
% Purple flare, a diffuse chromatic aberration common in highlight regions, severely degrades tonal transitions and color fidelity. Existing methods often treat it as a generic image restoration task in RGB space, resulting in suboptimal color separation and detail loss. To address this challenge, we propose a purple flare removal network based on decoupled HSV Look-Up Tables (LUTs). Its core idea is to transform the complex color correction task into an independent adjustment process targeting the three key elements: Hue (H), Saturation (S), and Value (V), thus resolving the color coupling problems inherent in conventional methods. The model employs a two-stage architecture: a Chroma-Aware Spectral Tokenizer (CAST) first converts the input image from RGB to HSV space and independently encodes the H and V channels into a set of semantic tokens that describe the flare's state. These tokens then guide the HSV-LUT module to generate independent correction curves (1D-LUTs) for each of the H, S, and V channels. This ``perception-correction'' strategy allows the model to precisely remove the purple flare while maximally preserving the image's original texture and details. To effectively train and validate our model, we have constructed the first large-scale dataset for purple flare, featuring a diverse range of scenes. Evaluated on our new dataset, our model achieves state-of-the-art (SOTA) performance, surpassing existing methods both visually and in quantitative metrics.
\end{abstract}
% Uncomment the following to link to your code, datasets, an extended version or similar.
% You must keep this block between (not within) the abstract and the main body of the paper.
\begin{links}
\link{Code}{https://github.com/Pu-Wang-alt/Reduce-Purple-Flare/}
\link{Datasets}{https://huggingface.co/datasets/PuWang0/purple_flare}
\link{Formal version}{}
\end{links}
\section{Introduction}
In complex lighting environments, images are often affected by various color artifacts~\cite{yu2017low, abbasi2024enhancing}, with the purple flare being one of the most common. Unlike general image degradations such as noise or blur, purple flare presents a unique challenge due to its diffuse nature, color specificity, and strong spatial correlation with highlight regions, severely impacting the image's color fidelity~\cite{min2025exploring, chen2024topiq}. This issue is especially prominent in mobile photography, consumer-grade cameras, and low-cost optical systems, primarily caused by factors such as internal lens reflections, sensor saturation, and chromatic dispersion~\cite{spencer1995physically}.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{fig1.pdf}
\caption{%\textbf{Purple Flare Analysis.} The HSV color space offers a superior decomposition of purple flare's properties compared to RGB, where the H channel clearly renders the glare area as a specific piece of purple, the V channel shows a highlighted area in exactly the same position
\textbf{Color space analysis and CAST-guided correction comparison.} (a) RGB vs. HSV: HSV decouples purple flare characteristics more clearly. % ; the H channel highlights purple flare regions, while the V channel shows corresponding high-brightness areas.
(b) CAST-guided effect: The CAST module significantly improves performance.%CAST-guided effect: The network’s correction performance is significantly improved with the CAST module.
}%\colortext{xx.....}
\label{fig1}
\vspace{-4mm}
\end{figure}
Recently, image enhancement techniques have made significant progress in areas such as deraining~\cite{liu2025deraings}, dehazing~\cite{sabitha2024restoration, kumari2024real, agrawal2024fog}, and color restoration~\cite{chen2021pre, liang2021swinir}. However, the purple flare has not been systematically studied yet. Early attempts relied on traditional methods utilizing decoupled color spaces like HSV or Lab~\cite{lee2011purple,kim2010detection,ware2018measuring}. These methods are constrained by their reliance on hand-crafted, fixed thresholds, which causes them to lack flexibility and generalization capability in complex scenes, limiting their practical application.
%
To overcome the limitations of traditional methods, researchers have turned to deep learning. Wu et al.~\shortcite{wu2021train} pioneered the application of end-to-end CNNs to general flare removal by constructing a large-scale semi-synthetic dataset.
To further bridge the domain gap between synthetic data and real-world flares, Deng et al.~\shortcite{deng2024towards} proposed a knowledge-driven hybrid approach that utilizes a flare-level estimator as prior knowledge to guide the restoration network.
While these methods represent the state-of-the-art, they are essentially pixel-to-pixel restoration networks operating in the coupled RGB color space, lacking precise control over color decoupling for specific chromatic artifacts. Among them, driven by the need for efficiency, LUT-based methods have emerged as a prominent choice for lightweight architectures. However, existing LUT methods rely on the RGB space and are not sensitive to capturing the purple flare of local region transformation (see Fig.~\ref{fig1}(a)). We observed that the HSV space can amplify the characteristic of local purple flare. Still, the non-linear transformation from RGB to HSV can amplify local color space noise, creating new artifacts in the final result~\cite{gevers2012color}.
%To leverage the advantages of the decoupled HSV color space while avoiding the instability introduced by the traditional HSV conversion, we propose CAST-LUT, which employs a Chroma-Aware Spectral Tokenizer (CAST) to analyze the image and generate stable, high-level semantic representations of the purple flare characteristics.
To leverage the benefits of the decoupled HSV color space without incurring the instability of traditional conversion, we propose CAST-LUT. This method employs a Chroma-Aware Spectral Tokenizer (CAST) to generate stable, high-level semantic representations of the purple flare.
Fig.~\ref{fig1}(b) illustrates the critical guiding role of the CAST module. These semantic tokens then guide the generation of independent 1D-LUTs for the H, S, and V channels. %This enables the model to achieve precise, targeted flare removal in the decoupled HSV space, avoiding the noise amplification problem of a direct RGB-to-HSV conversion.
Additionally, we constructed the Purple Flare Synthesis Dataset (PFSD), comprising 4,987 training pairs, 608 validation pairs, and 618 testing pairs. To simulate optical lens characteristics, we identify highlight regions at object contour edges as candidates, apply a Gaussian blur, and fuse purple flare into raw images. This is the first large-scale paired image collection for this task. Due to the localized nature of purple flare, averaging errors across the entire image can mask residual artifacts in small regions, making traditional global metrics ineffective for accurate evaluation. We therefore introduce new metrics: using a purple flare mask, we separate flare-region PSNR (PSNR-F) and non-flare-region PSNR (PSNR-NF) to assess flare restoration and clean-region fidelity, respectively. For color correction, we propose Hue Alignment Error (HAE), which quantifies hue differences in flare regions to evaluate color recovery.
%Additionally, we constructed the Purple Flare Synthesis Dataset (PFSD), which consists of 4,987 pairs for training, 608 pairs for validation, and 618 pairs for testing. To simulate the characteristics of optical lenses, we locate highlight regions at the contour edges of objects in an image as candidate regions, apply Gaussian blur to them, and fuse the purple flare into the raw image. This constitutes the first large-scale paired image collection for this task. Due to the localized nature of purple flare, averaging the error over the entire image can mask residual artifacts in small regions, making it difficult for traditional global metrics (such as PSNR, SSIM) to accurately evaluate the purple flare removal effect. We construct new metrics. Using a purple flare mask, we distinguish flare-region PSNR (PSNR-F) and non-flare-region PSNR (PSNR-NF) to separately assess the model’s restoration of flare areas and fidelity in clean regions. For color correction, we propose Hue Alignment Error (HAE), which quantifies hue differences within flare regions to evaluate color recovery.%We constructed new metrics. We utilize a purple flare mask to distinguish between PSNR for the flare region (PSNR-F) and the non-flare region (PSNR-NF), to respectively evaluate the model's restoration performance on flare regions and its fidelity capability in clean regions. For color correction evaluation, we propose the Hue Alignment Error (HAE) by calculating the hue difference within the flare regions.
\begin{itemize}
\item %We propose CAST-LUT, avoiding the noise amplification problem of traditional RGB-to-HSV conversions. It uses a Chroma-Aware Spectral Tokenizer to diagnose purple flare into semantic tokens, which then guides an adaptive 1D-LUT module for precise correction of each HSV channel.
We propose CAST-LUT, which avoids traditional RGB-to-HSV noise amplification. Its Chroma-Aware Spectral Tokenizer (CAST) diagnoses purple flare into semantic tokens that guide an adaptive 1D-LUT for precise correction of each HSV channel.
\item To address the data scarcity for the purple flare removal task, we construct a large-scale, high-quality purple flare dataset containing diverse scenes and devices, providing a fair benchmark for training and evaluation.%分词器
\item %For a more accurate evaluation, new evaluation metrics and a loss function are introduced. PSNR for flare/non-flare regions (PSNR-F/NF) is used to evaluate purple flare removal and detail preservation capability, respectively. Furthermore, to specifically measure color fidelity, we also propose the Hue Alignment Error (HAE) metric.
We introduce a new loss function and metrics for accurate evaluation. PSNR-F/NF assesses flare removal and detail preservation, respectively, while our proposed Hue Alignment Error (HAE) metric measures color fidelity.
%We design based on HSV decoupling type 1D-LUT module introduces a new mechanism, using CAST semantic token is generated dynamically generated and used multiple, independent, weighted fusion of 1D-LUT, thus realized the H and S and V channel of precise and controllable lightness and targeted color correction.%To address the critical data gap in this specific field, we have constructed and will release the first large-scale, high-quality purple flare dataset, featuring diverse scenes and devices. This provides a fair benchmark for community training and evaluation.
%Extensive experiments on our dataset demonstrate that our model significantly outperforms existing state-of-the-art methods both qualitatively and quantitatively.
\end{itemize}
% \begin{figure}[t]
% \centering
% \includegraphics[width=0.9\columnwidth]{figure1} % Reduce the figure size so that it is slightly narrower than the column. Don't use precise values for figure width.This setup will avoid overfull boxes.
% \caption{Using the trim and clip commands produces fragile layers that can result in disasters (like this one from an actual paper) when the color space is corrected or the PDF combined with others for the final proceedings. Crop your figures properly in a graphics program -- not in LaTeX.}
% \label{fig1}
% \end{figure}
% \begin{figure*}[t]
% \centering
% \includegraphics[width=0.8\textwidth]{figure2} % Reduce the figure size so that it is slightly narrower than the column.
% \caption{Adjusting the bounding box instead of actually removing the unwanted data resulted multiple layers in this paper. It also needlessly increased the PDF size. In this case, the size of the unwanted layer doubled the paper's size, and produced the following surprising results in final production. Crop your figures properly in a graphics program. Don't just alter the bounding box.}
% \label{fig2}
% \end{figure*}
% \begin{algorithm}[tb]
% \caption{Example algorithm}
% \label{alg:algorithm}
% \textbf{Input}: Your algorithm's input\\
% \textbf{Parameter}: Optional list of parameters\\
% \textbf{Output}: Your algorithm's output
% \begin{algorithmic}[1] %[1] enables line numbers
% \STATE Let $t=0$.
% \WHILE{condition}
% \STATE Do some action.
% \IF {conditional}
% \STATE Perform task A.
% \ELSE
% \STATE Perform task B.
% \ENDIF
% \ENDWHILE
% \STATE \textbf{return} solution
% \end{algorithmic}
% \end{algorithm}
% \begin{figure}[t]
% \centering
% \includegraphics[width=0.45\textwidth]{fig2.png} % Reduce the figure size so that it is slightly narrower than the column.
% \caption{\textbf{Key difference between our decoupled HSV correction and conventional RGB correction.} Left (RGB): Histogram shows coupled R, G, B channels with entangled color and luminance. Learned 1D-LUTs (small picture) use crude global suppression, imprecisely targeting purple flares and damaging normal colors. Right (HSV): Histogram decouples the image into three independent dimensions (H, S, V). This decoupling our core innovation enables functionally specific, independent 1D-LUTs per channel (small picture).}
% \label{fig2}
% \end{figure}
\section{Related Work}
\textbf{Chromatic Aberration and Flare Removal.}
Traditional methods note limitations in processing purple flare directly in sRGB space, as intense luminance variations interfere with color assessment. Researchers have explored other color spaces~\cite{malik2018iterative}. Chung et al.~\shortcite{chung2009detecting} identified chromatic fringes by comparing R, G, B channel intensities but faced false positives due to ambiguous purple definitions. To better separate chrominance from luminance, subsequent works shifted to other color spaces. Kim et al.~\shortcite{kim2010detection} used CIExy for luminance normalization, while Ju et al. leveraged YCbCr's chrominance channels (Cb-Cr) to analyze color deviations independently~\cite{ju2013colour}. However, a common bottleneck is their reliance on static, experimentally determined absolute thresholds to filter high-contrast or near-saturated areas. Given varied purple flare characteristics across cameras and scenes, fixed thresholds lack universality and robustness. Considering degraded image representation reconstruction ability, we propose using a word segmenter to aid in detail reconstruction.
%Traditional methods note that processing purple flare directly in sRGB space is limited, as intense luminance variations can interfere with color assessment~\cite{malik2018iterative}. Thus, researchers have explored other color spaces. Chung et al. identified chromatic fringes by comparing R, G, and B channel intensities but faced many false positives due to ambiguous ``purple'' definitions~\cite{chung2009detecting}. To better separate chrominance from luminance, subsequent works shifted to other color spaces. Kim et al. used CIExy for luminance normalization~\cite{kim2010detection}, and Ju et al. leveraged YCbCr's chrominance channels (Cb-Cr) to analyze color deviations independently~\cite{ju2013colour}. However, a common bottleneck is that these methods rely on static, experimentally determined absolute thresholds to filter high-contrast or near-saturated areas. Given the varied purple flare characteristics across cameras and scenes, fixed thresholds lack universality and robustness. Considering the reconstruction ability of degraded image representation, here, we consider using a word segmenter to help us reconstruct details.
\noindent \textbf{Discrete Semantic Representation with Vector Quantization.}
%Semantic token generation, key to modern perceptual systems, is often achieved via Vector Quantization (VQ).
Vector Quantization (VQ) is widely used to generate semantic tokens, a key component of modern perceptual systems.
Its core principle maps high-dimensional feature vectors to a finite set of learned codebook embeddings. This technique gained prominence with VQ-VAE~\cite{van2017neural}, which established a discrete latent space in an autoencoder architecture and integrated a discrete latent bottleneck into such frameworks. A discrete latent space offers significant advantages: it enables learning rich, semantically meaningful representations, where each codebook entry captures distinct perceptual patterns analogous to vocabulary words~\cite{schwettmann2021toward}. Additionally, discretization improves generative model stability and efficiency by mitigating issues like posterior collapse, a challenge in traditional VAEs~\cite{xue2019supervised}. The discretization of visual data into tokens has enabled powerful architectures like Transformers~\cite{han2022survey} and inspired token or prompt-guided approaches for other vision tasks, such as few-shot learning \cite{li2024knn, li2025vt}.
%Converting complex visual data into discrete token sequences also allows direct application of powerful cross-domain architectures (e.g., Transformer~\cite{han2022survey}) to vision tasks.
%Semantic token generation, key to modern perceptual systems, is often achieved through Vector Quantization (VQ). Its core principle is to map high-dimensional feature vectors to a finite set of learned embeddings within a codebook. This technique gained significant prominence with the introduction of VQ-VAE~\cite{van2017neural}, which established a discrete latent space within an autoencoder architecture, and integrates a discrete latent bottleneck into autoencoder frameworks. The use of a discrete latent space offers several significant advantages. It facilitates the learning of rich, semantically meaningful representations, where each codebook entry can capture a distinct perceptual pattern, analogous to words in a vocabulary~\cite{seo2024raq}. Furthermore, this discretization has been shown to improve the stability and efficiency of generative models by mitigating issues such as posterior collapse, a challenge in traditional VAEs~\cite{xue2019supervised}. By converting complex visual data into sequences of discrete tokens, VQ also enables the direct application of powerful architectures from other domains, like the Transformer, to vision tasks.
%Semantic token generation, key to modern perceptual systems, is often achieved through Vector Quantization (VQ), notably in VQ-VAE~\cite{van2017neural}. By introducing a discrete latent space via a learnable codebook, VQ-VAE addresses traditional VAE limitations like posterior collapse~\cite{xue2019supervised} and aligns with discrete natural data structures (e.g., words, phonemes)~\cite{seo2024raq}, enabling efficient latent space use and rich semantic learning. In our CAST module, this idea learns a "semantic vocabulary" for chromatic aberration artifacts: vector quantization on H and V channel features yields a codebook where each embedding codeword corresponds to a specific H/V pattern (e.g., "high-brightness purple cast"). Thus, an image with purple flare transforms into discrete token sequences with advanced semantics, guiding subsequent corrections concisely and powerfully.
% Semantic token generation, a critical component in modern perceptual systems, is often realized through Vector Quantization (VQ) technology, notably employed in the Vector Quantization Variational Autoencoder (VQ-VAE)~\cite{van2017neural}. By introducing a discrete latent space via a learnable codebook, VQ-VAE addresses limitations of traditional VAEs, such as posterior collapse~\cite{xue2019supervised}, while aligning with the discrete nature of many natural data structures (e.g., language words, speech phonemes)~\cite{seo2024raq}. This approach enables efficient latent space utilization and facilitates the learning of semantically rich representations. In the CAST module we proposed, this idea is used to learn the "semantic vocabulary" representing chromatic aberration artifacts. By performing vector quantization on the features of H and V channels, the network can learn a codebook where each embedding codeword corresponds to a specific type or intensity of H/V pattern. %For instance, in a codebook, there might be one codeword specifically representing "purple color cast at high brightness", and another codeword representing "normal blue at medium brightness".
% In this way, an image with purple flare can be transformed into a series of discrete token sequences with advanced semantics, thereby providing concise and powerful guidance for subsequent corrections.
\begin{figure*}[t]
\centering
\includegraphics[width=0.95\textwidth]{fig2.pdf} % Reduce the figure size so that it is slightly narrower than the column.
\caption{Overall architecture of the decoupled CAST-LUT network. The CAST module first extracts semantic tokens from the input image's H and V channels via an Encoder-VQ pipeline. These tokens then guide the dynamic generation and weighted fusion of multiple, decoupled 1D-LUTs for the H, S, and V channels to obtain the final corrected image.}
\label{fig2}
\end{figure*}
\noindent \textbf{LUT-based Color Image Enhancement.} %lut 和现有lut的区别,引出文章动机
Recently, the LUT paradigm has shown significant potential across image restoration tasks, evolving into complex task-specific architectures. For color image denoising, where high color fidelity is critical, early LUT methods were limited by independent color channel processing. Therefore, DnLUT~\cite{yang2025dnlut} introduced a Pairwise Channel Mixer, which explicitly models inter-channel correlations by processing RGB channel pairs in parallel, boosting color denoising performance. For complex mixed-degradation scenarios (e.g., low-light enhancement), the LUT framework has advanced further. DPLUT~\cite{lin2025dplut} proposed a two-stage approach, using a Light-Adjustment LUT and Noise-Suppression LUT to decouple brightening and denoising sub-tasks. However, despite SOTA performance in their domains, these advanced LUT methods are not designed for purple flare removal.
Their model priors are inconsistent with the unique characteristics and spatial distribution of flare, and they are confined to operating in the RGB space.%Their model priors misalign with flare’s unique chromatic signature and spatial distribution. More fundamentally, they operate in RGB space, leaving precise, localized artifact correction in a perceptually decoupled color space as a core open question.
%In recent years, the Look-Up Table (LUT) paradigm has demonstrated significant potential across various image restoration tasks, evolving into complex architectures tailored for specific challenges. In color image denoising where high color fidelity is critical, early LUT methods were limited by their independent processing of color channels. To address this, DnLUT~\cite{yang2025dnlut} introduced a novel Pairwise Channel Mixer(PCM), which explicitly models inter-channel correlations by processing RGB channel pairs (e.g., RG, GB) in parallel, significantly improving color denoising performance.For more complex, mixed-degradation scenarios like low-light enhancement, the LUT framework has been further developed.DPLUT~\cite{lin2025dplut} proposed a two-stage approach, using a Light-Adjustment LUT (LLUT) and a Noise-Suppression LUT (NLUT) to decouple the sub-tasks of brightening and denoising. However, while these advanced LUT methodologies achieve state-of-the-art performance in their respective domains (e.g., denoising and low-light enhancement), they are not designed for the specific problem of purple flare removal. Their model priors do not align with the unique chromatic signature and spatial distribution of flare. More fundamentally, their operational domain remains the RGB space. herefore, how to perform precise, localized artifact correction within a perceptually decoupled color space remains a core open question.
%While deep learning has significantly advanced general image restoration tasks~\cite{yuan2024plug,zamir2022restormer}, since direct pixel-to-pixel conversion is performed in the sRGB space, the color channels cannot be decoupled, which may lead to global color imbalance when correcting local distortion, and the computational efficiency is also very high.
%While deep learning has advanced general image restoration~\cite{yuan2024plug,zamir2022restormer}, direct pixel-to-pixel conversion in sRGB space fails to decouple color channels, risking global color imbalance when correcting local distortions and incurring high computational costs. In color correction, LUT-based methods are popular for tasks like photo enhancement and style transfer. LUTs are precomputed numerical tables that accelerate image transformations by replacing costly runtime computations with cheap memory addressing. Recent works propose dynamic LUTs, where lightweight CNNs or transformers predict a 3D LUT conditioned on the input image~\cite{li2025d,vakili2024dyrecmul}.
%In the domain of color correction, LUT based methods have gained popularity for tasks such as photo enhancement and style transfer. The essence of LUT is a pre-calculated numerical table. In image processing, it accelerates transformation by replacing expensive runtime function computations with inexpensive memory addressing operations. Recent works propose dynamic LUTs, where lightweight CNNs or transformers predict a 3D LUT conditioned on the input image~\cite{li2025d,vakili2024dyrecmul}.
%Despite effectiveness in global tone mapping, these methods struggle with localized, irregular distortions like purple flare and operate mainly in sRGB space, failing to meet decoupled correction needs. In contrast, we propose a new generative LUT framework, which is guided by high-level semantic tokens (not low-level pixel features), it performs fully decoupled correction in perceptual HSV space, enabling targeted purple flare removal something traditional RGB-space LUTs cannot achieve.
%Despite their effectiveness in global tone mapping, these approaches are not well-suited for correcting spatially localized and irregular color distortions like purple flare. Moreover, they also primarily operate in sRGB space, failing to fundamentally address the need for decoupled correction. In contrast, we propose a new LUT framework, a generative LUT guided by high-level semantic tokens rather than directly regressing from the low-level pixel features of the image, and performing fully decoupled color correction in the perceptual HSV space, thereby being able to specifically remove purple flasiness, which is something that traditional RGB space LUTs cannot handle.
%With the rise of deep learning, some studies have begun to employ end-to-end neural networks for image restoration tasks~\cite{yuan2024plug}. These general-purpose models (e.g., U-Net or Transformer architectures~\cite{zamir2022restormer}) can learn complex mappings from degraded to clean images. However, is that they often perform a "black-box" pixel-to-pixel transformation in sRGB space. This approach re-introduces the channel coupling problem, where correcting the local color cast can easily have a bad effect on the global color balance. Another related class of deep learning techniques is Look-Up Table (LUT) based color correction. Recently, dynamic LUT methods have succeeded in global photo enhancement and style transfer by using a small CNN to predict a 3D-LUT for the entire image~\cite{li2025d,vakili2024dyrecmul}. However, these methods are designed for global adjustments and are ill-suited for localized, irregular artifacts like purple flare. Moreover, they also primarily operate in sRGB space, failing to fundamentally address the need for decoupled correction.
%In summary, traditional methods lack generalizability due to their reliance on static thresholds, while existing deep learning methods are either too generic, ignoring the unique properties of purple flare, or designed for global enhancement, precluding precise local processing. There is a clear research gap for a framework that combines the decoupling advantages of perceptual spaces with the adaptive adjustment capabilities of deep learning. This paper proposes a novel "perceive-then-correct" model. It first analyzes the spectral characteristics of the purple flare in HSV space using a Chroma-Aware Spectral Tokenizer (CAST) to extract high-level semantic tokens. These tokens then guide the subsequent generation of decoupled 1D-LUTs, we bridges high-level scene understanding with low-level pixel manipulation to correct purple flare.
%------------------------------------------------
\section{Methodology}
Our proposed purple flare removal network, named \textbf{Decoupled HSV-LUT Network}, adopts a novel two-stage ``perceive-then-correct" paradigm. %This architecture is specifically designed to address the inherent color coupling issues of RGB-based methods by operating primarily within the perceptually decoupled HSV color space.
An overview of our framework is illustrated in Figure \ref{fig2}.
\subsection{Chroma-Aware Spectral Tokenizer (CAST)}
%The CAST module serves as the perception engine of our framework, designed to diagnose the specific characteristics of purple flare. Its core strategy is to operate within the perceptually decoupled HSV color space, enabling a targeted analysis based on the artifact's physical properties. Given that purple flare is defined by its abnormal hue and its location in highlight regions, we adopt a targeted processing strategy: the Hue (H) channel, representing the chromatic signature, and the Value (V) channel, providing the spatial context, are processed independently by a shared deep encoder. The Saturation (S) channel is passed through directly to preserve the original image's color richness.
%The CAST module, the framework’s perception engine, diagnoses purple flare characteristics by operating in the perceptually decoupled HSV space—enabling targeted analysis aligned with the artifact’s physical properties. Since purple flare is defined by abnormal hue and highlight-region location, we process the Hue (H) channel (chromatic signature) and Value (V) channel (spatial context) independently via a shared deep encoder, while passing the Saturation (S) channel directly to preserve color richness.
The CAST module acts as the framework’s perception engine, tasked with diagnosing purple flare features by translating complex visual artifacts into discrete semantic tokens.
%The module first converts the input RGB image $\mathbf{I}^\text{RGB} \in \mathbb{R}^{8 \times 3 \times H \times W}$ to the HSV color space. The \textbf{H} and \textbf{V} channels are then processed by an encoder network, which uses convolutional layers to downsample the inputs and extract hierarchical feature maps $\mathbf{F}_\textbf{H}, \mathbf{F}_\textbf{V} \in \mathbb{R}^{8 \times 256 \times H' \times W'}$.
Recognizing that purple flare is characterized by abnormal hue in highlight regions, we adopt a targeted approach. The $\textbf{H}$ channel (chromatic signature) and $\textbf{V}$ channel (highlight spatial context) undergo 4$\times$ downsampling via a shared-weight CNN encoder, which processes them independently to extract hierarchical feature maps $\mathbf{F}_\textbf{H}, \mathbf{F}_\textbf{V} \in \mathbb{R}^{8 \times 256 \times H' \times W'}$. The $\textbf{S}$ channel undergoes no encoding processing and remains in its original state to preserve the image’s inherent color richness. The encoder extracts hierarchical feature maps for each channel:
\begin{equation}
\mathbf{F}_\textbf{H} = \text{Encoder}(\mathbf{H}), \quad \mathbf{F}_\textbf{V} = \text{Encoder}(\mathbf{V}).
\end{equation}
%Subsequently, the continuous feature maps are discretized by a Vector Quantizer (VQ) module, which is core to the flare recognition mechanism. The VQ maps each feature vector to its nearest neighbor in a learnable codebook, optimized via backpropagation from the reconstruction loss. During end-to-end training, codebook vectors specialize into a semantic vocabulary: specific tokens learn to represent recurring purple flare characteristics (e.g., high-intensity purple hues). At inference time, the VQ module classifies the encoder's feature vector by finding the closest learned token. This mapping of a continuous visual pattern to a discrete semantic token constitutes the act of recognizing the purple flare. This process yields discrete token indices $\mathbf{T}_\textbf{H}, \mathbf{T}_\textbf{V}$ and their quantized feature maps $\mathbf{F}_{\text{quant}}^{\textbf{H}},\mathbf{F}_{\text{quant}}^{\textbf{V}}$:
To bridge low-level visual features and high-level semantic understanding, these continuous feature maps $\mathbf{F}_\textbf{H}$ and $\mathbf{F}_\textbf{V}$ are discretized into semantic tokens via a Vector Quantization (VQ) module, where specific tokens learn to represent recurring purple flare characteristics (e.g., ``high-intensity purple on edges"). Specifically, the VQ module maps each feature vector to the nearest codebook entry, thereby effectively categorizing visual patterns and generating discrete token indices and quantized representations:
\begin{equation}
\mathbf{T}_\textbf{H}, \mathbf{F}_{\text{quant}}^{\textbf{H}} = \text{VQ}(\mathbf{F}_\textbf{H}), \quad \mathbf{T}_\textbf{V}, \mathbf{F}_{\text{quant}}^{\textbf{V}} = \text{VQ}(\mathbf{F}_\textbf{V}).
\end{equation}
Next, a decoder network reconstructs the H and V channels from the quantized features.
\begin{equation}
\hat{\mathbf{H}} = \text{Decoder}(\mathbf{F}_{\text{quant}}^{\textbf{H}}), \quad \hat{\mathbf{V}} = \text{Decoder}(\mathbf{F}_{\text{quant}}^{\textbf{V}}).
\label{eq:decoder}
\end{equation}
%The reconstructed HSV image is assembled by combining the reconstructed channels with the original \textbf{S} channel and converting back to RGB. This reconstruction, yielding a preliminary image $\mathbf{I}_{\text{recon}}^{\text{RGB}}$, mainly provides supervisory signals for training the encoder and codebook, ensuring tokens retain key visual information. However, CAST’s critical output is the semantic token indices ($\mathbf{T}_\textbf{H}, \mathbf{T}_\textbf{V}$), they represent high-level flare diagnoses and are passed to the LUT module for correction guidance.
The original \textbf{S} channel is combined with $\hat{\mathbf{H}}$ and $\hat{\mathbf{V}}$ to form a reconstructed HSV image, which is then converted back to RGB to obtain the initial reconstructed image $\mathbf{I}_{\text{recon}}^{\text{RGB}}$. The training of CAST is supervised by the reconstruction error between $\mathbf{I}_{\text{recon}}^{\text{RGB}}$ and $\mathbf{I}^{\text{RGB}}$, ensuring that quantized features preserve key information from the input image. In the subsequent color correction stage, we treat the discrete token indices $\mathbf{T}_{\text{combined}}=[\mathbf{T}_H, \mathbf{T}_V]$ as high-level semantic representations of purple flare characteristics and feed them into the LUT module.
%The reconstructed HSV image is then assembled by combining the reconstructed channels with the original S channel and converting back to RGB. This reconstruction path, yielding a preliminary image $\mathbf{I}_{recon}^{RGB}$, serves primarily to provide a supervisory signal for training the encoder and codebook, ensuring the tokens retain essential visual information. The crucial output of CAST, however, is the set of semantic token indices ($\mathbf{T}_H, \mathbf{T}_V$), which represent a high-level diagnosis of the flare and are passed to the LUT module to guide the correction.
% \begin{figure}[t]
% \centering
% \includegraphics[width=0.5\textwidth]{fig3.png} % Reduce the figure size so that it is slightly narrower than the column.
% \caption{Visualization of generated 1D-LUTs and their fusion weights. The upper part shows example LUT sets, each containing three independent H, S, V curves demonstrating the model's diverse and decoupled correction strategies. The lower bar chart shows corresponding weights $\mathbf{W}$, which fuse all $N_L$ LUT transformation results into the final corrected image via weighted averaging.}
% \label{fig3}
% \end{figure}
\subsection{HSV-LUT Color Correction}
%Our method's core innovation is the HSV-based Decoupled 1D-LUT Module, which leverages CAST-generated semantic tokens for precise, image-adaptive color correction. It takes three inputs: combined tokens $\mathbf{T}_{\text{combined}} = [\mathbf{T}_\textbf{H}, \mathbf{T}_\textbf{V}]$, the original image $\mathbf{I}^{\text{RGB}}$, and CAST’s reconstructed image $\mathbf{I}_{\text{recon}}^{\text{RGB}}$. Guided by $\mathbf{T}_{\text{combined}}$, color correction is applied to $\mathbf{I}_{\text{recon}}^{\text{RGB}}$.
The color correction step of our method is executed by the HSV-based decoupled 1D-LUT module. Guided by the semantic tokens $\mathbf{T}_{\text{combined}}$ generated by CAST, this module performs color correction on the reconstructed image $\mathbf{I}_{\text{recon}}^{\text{RGB}}$ while leveraging residual information from the original image $\mathbf{I}^{\text{RGB}}$ to preserve high-frequency details.
\noindent \textbf{Token-Guided LUT Generation.}
%First, the semantic tokens $\mathbf{T}_{\text{combined}}$ are converted into continuous feature vectors, which are then aggregated into a single global feature vector $\mathbf{f}_{\text{token}}$. This vector encapsulates the input image's overall characteristics, particularly purple flare presence and properties.
First, the semantic tokens $\mathbf{T}_{\text{combined}}$ are converted into a global feature vector $\mathbf{f}_{\text{token}}$ containing purple flare characteristics through embedding and aggregation operations, which drives two parallel sub-networks: the LUT generator and the weight generator.
\begin{equation}
\mathbf{f}_{\text{token}} = \text{Aggregate}(\text{Embed}(\mathbf{T}_{\text{combined}})).
\end{equation}
(1) \textbf{LUT Generator:} This network processes $\mathbf{f}_{\text{token}}$ using an MLP to generate and reshape parameters $\mathbf{P}$ for $N_L$ groups of LUTs. Each group contains three independent 1D-LUTs tailored to the H, S, and V channels, respectively. This decoupled design enables targeted adjustments for each color attribute.%To enable image-adaptive color correction, this network processes the content-aware $\mathbf{f}_{\text{token}}$ and generates parameters for $N_L$ sets of 1D-LUTs (where $N_L$ is a hyperparameter for the number of sets). Each set contains three independent 1D-LUTs (one for H, S, V channels), enabling targeted adjustments via this decoupled design. The generator outputs all parameters, which are reshaped into a structured tensor $\mathbf{P}$.
\begin{equation}
\mathbf{P} = \text{Reshape}(\text{MLP}(\mathbf{f}_{\text{token}})).
\end{equation}
(2) \textbf{Weight Generator.} Parallel to the LUT generator, the weight generator processes $\mathbf{f}_{\text{token}}$ using an MLP and normalizes via Softmax to predict dynamic fusion weights $W \in \mathbb{R}^{N_L}$. These weights determine the contribution of the $N_L$ LUT groups. %Parallel to the LUT Generator, this lightweight Multi-Layer Perceptron (MLP) takes the same global feature vector $\mathbf{f}_{\text{token}}$ as input. Its task is to predict dynamic fusion weights for each of the $N_L$ LUT sets. The network outputs $N_L$ raw scores, normalized via Softmax to produce the final weight vector $\mathbf{W}$. This enables the final correction to be a flexible, weighted combination of multiple transformations, supporting nuanced and robust image enhancement.
\begin{equation}
\mathbf{W} = \text{Softmax}(\text{MLP}(\mathbf{f}_{\text{token}})).
\end{equation}
\noindent\textbf{Decoupled HSV Correction via 1D-LUTs.}
%Our core correction process is applied to the reconstructed image $\mathbf{I}_{\text{recon}}^{\text{RGB}}$ from the CAST module. To enable channel-specific adjustments, this image is first converted to the HSV color space and split into its three constituent channels:
First, the reconstructed image $\mathbf{I}_{\text{recon}}^{\text{RGB}}$ generated by CAST is converted to the HSV color space and decomposed into its three channels $[\mathbf{H}_\text{in}, \mathbf{S}_\text{in}, \mathbf{V}_\text{in}]$.
% \begin{equation}
% [\mathbf{H}_\text{in}, \mathbf{S}_\text{in}, \mathbf{V}_\text{in}] = \text{Split}(\text{RGBtoHSV}(\mathbf{I}_{\text{recon}}^{\text{RGB}}))
% \end{equation}
% For each of the $N_L$ generated LUT sets, the corresponding 1D-LUT is then independently applied to its respective input channel. Let $\text{LUT}_{H,i}$, $\text{LUT}_{S,i}$, and $\text{LUT}_{V,i}$ denote the $i$-th LUT for each channel. This application yields $N_L$ intermediate corrected versions for each channel $\mathbf{C}_{out,i}$:
% \begin{equation}
% \mathbf{C}_{out,i} = \text{ApplyLUT}([\mathbf{H_{in},S_{in},V_{in}}], \text{LUT}_{(H,i),(S,i),(V,i)})
% \end{equation}
% A key detail is handling the circular nature of the Hue channel. To prevent abrupt visual artifacts, continuity is enforced by ensuring the first and last points of each $\text{LUT}_{H,i}$ are identical.
% These $N_L$ corrected versions are then fused into a single, definitive channel via a weighted average, guided by the dynamically predicted fusion weights $\mathbf{W}$. This fusion is described by:
Our correction process operates on each channel independently within the HSV color space. For each LUT set $i=1, \dots, N_L$, its corresponding three 1D-LUTs ($\text{LUT}_{\textbf{H},i}, \text{LUT}_{\textbf{S},i}, \text{LUT}_{\textbf{V},i}$) are applied to the three input channels $[\mathbf{H}_\text{in}, \mathbf{S}_\text{in}, \mathbf{V}_\text{in}]$ respectively. These results are then fused into the final corrected channels $\mathbf{C}_\text{final}$ via weighted averaging with the predicted weight vector $\mathbf{W}$. This process can be described by the following equation:
\begin{equation}
\mathbf{C}_\text{final} = \sum_{i=1}^{N_L} \mathbf{W}_i \cdot \text{ApplyLUT}(\mathbf{C}_\text{in}, \text{LUT}_{\textbf{C},i}),
\end{equation}
where $\mathbf{C}_\text{in} \in \{\mathbf{H}_\text{in}, \mathbf{S}_\text{in}, \mathbf{V}_\text{in}\}$.
% \begin{equation}
% \mathbf{C}_{final} = \sum_{i=1}^{N_L} (\mathbf{C}_{out,i} \cdot \mathbf{W}_i),
% \end{equation}
Finally, the final corrected channels $\mathbf{C}_\text{final}$ are re-combined and converted back to the RGB color space, yielding the LUT-corrected image $\mathbf{I}_{\text{fused}}^{\text{RGB}}$. %This decoupled approach is critical as it allows for targeted manipulation of hue, saturation, and value.
\noindent \textbf{Residual Branch and Final Fusion.}
To preserve details, a residual branch processes the original input image $\mathbf{I}^{\text{RGB}}$ to extract complementary high-frequency features, denoted as $\mathbf{I}_{\text{residual}}$. The color-corrected image from the main path, $\mathbf{I}_{\text{fused}}^{\text{RGB}}$, is then concatenated with these residual features to seamlessly integrate the information from both paths. A global skip connection adds the original image $\mathbf{I}^{\text{RGB}}$ to this fused result, producing the final corrected image $\mathbf{I}_{\text{output}}$.
\begin{equation}
\mathbf{I}_{\text{output}} = \text{Fusion}(\text{Concat}(\mathbf{I}_{\text{fused}}^{\text{RGB}}, \mathbf{I}_{\text{residual}})) + \mathbf{I}^{\text{RGB}}.
\end{equation}
This architecture stabilizes training and focuses the network on learning necessary corrections to the residual instead of reconstructing the entire image from scratch. This approach stabilizes training and allows the two branches to specialize: the main branch focuses on complex color correction, while the residual branch ensures high-fidelity detail preservation.
% \subsection{Loss Function}
% Our model is trained end-to-end using a composite loss function $L_{total}$. This loss is designed to achieve two distinct goals: ensuring the visual quality of the final corrected image and regularizing the internal tokenization process within the CAST module.
% For Reconstruction Loss $\mathcal{L}_{recon}$,to ensure the final output is visually faithful to the ground truth, we employ a pixel-wise L1 loss. This loss measures the absolute difference between our model's final output $I_{output}$, and the ground-truth clean image $I_{GT}$. The L1 loss is chosen as it is less sensitive to outliers than L2 loss and often results in sharper images.
% \begin{equation}
% \mathcal{L}_{recon} = ||\mathbf{I}_{output} - \mathbf{I}_{GT}||_1
% \end{equation}
% To guide the CAST module in generating a meaningful and stable set of semantic tokens, we employ a quantization loss $\mathcal{L}_{q}$. This loss regularizes the shared encoder within the CAST module. Specifically, this loss minimizes the distance between the feature vectors $F_H, F_V$ produced by the encoder and their corresponding codebook embeddings. This prevents the encoder's feature space from diverging during training and ensures that the codebook is utilized effectively.
% The total loss is a weighted sum of these two components:
% \begin{equation}
% \mathcal{L}{total} = \mathcal{L}_{recon} + \lambda \mathcal{L}_{q}
% \end{equation}
% where $\lambda$ is a hyperparameter that balances the contribution of the reconstruction and quantization loss terms. This composite loss function effectively guides the entire framework, ensuring that the model learns to produce high-quality images while simultaneously developing a meaningful semantic representation of the image content.
\subsection{Loss Function}
Our model is trained using a composite loss function $\mathcal{L}_{total}$:
\begin{equation}
\mathcal{L}_{total} = \lambda_{1} \mathcal{L}_{L1} + \lambda_{p} \mathcal{L}_{p} + \lambda_{f} \mathcal{L}_{f} + \lambda_{q} \mathcal{L}_{q},
\end{equation}
where $\lambda_{1}, \lambda_{p}, \lambda_{f}, \lambda_{q}$ balance contributions from pixel accuracy, perceptual similarity, artifact suppression, and representation stability. $\mathcal{L}_{L1} = ||\mathbf{I}_\text{output} - \mathbf{I}_\text{GT} ||_1$ ensures pixel-level fidelity, while $\mathcal{L}_{p} = || \phi(\mathbf{I}_\text{output}) - \phi(\mathbf{I}_\text{GT})||_1$ uses VGG-16 features~\cite{simonyan2014very} to enhance perceptual quality. Finally, $\mathcal{L}_{q} = ||\text{sg}(\mathbf{F}) - \mathbf{e}||_2^2$ regularizes the codebook by penalizing the distance between the encoder's output feature $\mathbf{F}$, and its nearest codebook vector $\mathbf{e}$, ensuring stable token representations.
\noindent \textbf{Purple Flare Suppression Loss $\mathcal{L}_{f}$.}
We have introduced a purple flare suppression loss specifically targeting the purple flare.
Standard L1 or L2 losses treat errors across all pixels equally, failing to focus on addressing specific color artifacts in targeted regions. To tackle this, we introduce a weighted loss term that amplifies errors in purple flare regions through a penalty mask $\mathbf{M}$, as shown in Figure \ref{fig:mask}. This mask is obtained by element-wise multiplication of two components:
\begin{equation}
\mathbf{M} = \mathbf{M}_\text{flare} \odot \mathbf{M}_\text{edge},
\end{equation}
where $\odot$ denotes element-wise multiplication, $\mathbf{M}_\text{flare}$ is a color feature map used to identify pixels in the image with purple hue and high saturation, $\mathbf{M}_\text{edge}$ is an edge map generated by edge detection operators such as Sobel. In this way, the loss is significantly amplified only in regions that simultaneously satisfy the two conditions of ``purple color" and ``being located at edges". The final suppression loss is defined as:
\begin{equation}
\mathcal{L}_f = || \mathbf{M} \odot (\mathbf{I}_\text{output} - \mathbf{I}_\text{GT}) ||_1.
\end{equation}
%Standard L1 loss treats all pixel errors indiscriminately and cannot specifically focus on errors in specific areas (such as purple flares and other artifact areas). To distinguish purple artifacts from normal purple content, we constructed a penalty mask to selectively magnify the errors on the pseudo-image elements.
%This mask is the product of a color feature map (identifying purple, saturated pixels) and an edge map, as shown in Figure \ref{fig:loss}. This ensures that the loss is selectively amplified only at the high-contrast boundaries that exhibit the specific colors of the flares, thereby achieving precise correction without damaging other areas of the image.
%To specifically suppress purple flare artifacts, we introduce a specialized loss term, $\mathcal{L}_{f}$. The core of our method is to enhance the standard L1 error with a precisely constructed penalty mask that targets the unique signature of purple flare. The construction of this mask is visualized in Figure 1. Given an input image (Fig. 1a) with artifacts, our method computes two key components. First, it generates an edge map (Fig. 1b) using a Sobel filter to identify high-contrast boundaries where flare typically originates. Second, it analyzes the input's color properties in HSV space to create a purple saturation weight map (Fig. 1c), which highlights pixels matching the flare's specific color signature (a purple hue with high saturation). These two maps are then multiplied element-wise to produce the final penalty mask (Fig. 1d). This resulting mask robustly isolates only the pixels that are both on a high-contrast boundary and exhibit the purple flare's color. This final mask is then used to amplify the loss on these specific pixels, compelling the optimizer to correct them without affecting other regions of the image.
%\noindent \textbf{Quantization Loss.}
%Finally, to regularize the internal representation of our CAST module, we include the quantization loss, $\mathcal{L}_{q}$, from the VQ-VAE framework. This ensures that the codebook is utilized effectively and that the learned semantic tokens remain stable throughout training.
% \begin{equation}
% \mathcal{L}_{q} = ||\text{sg}(\mathbf{F}) - \mathbf{e}||_2^2
% \end{equation}
%where $\mathbf{F}$ is the encoder output, $\mathbf{e}$ is the chosen codebook vector, and $\text{sg}(\cdot)$ is the stop-gradient operator.
\begin{figure}[t]
\centering
\includegraphics[width=0.95\columnwidth]{fig3.pdf} % You'll need to create this figure
\caption{The generation process of the penalty mask $\mathbf{M}$ used in our flare suppression loss $\mathcal{L}_f$. The final mask (d) is obtained by element-wise multiplication of the edge map (b) and the purple weight map (c), which can precisely locate flare artifacts and apply targeted loss.}%Visualization of the $\mathcal{L}_{f}$ loss.
\label{fig:mask}
\vspace{-4mm}
\end{figure}
\begin{table*}[t]
\centering
\footnotesize
\setlength{\tabcolsep}{2pt}
\resizebox{\textwidth}{!}{
\begin{tabular}{l l l cccc ccc cc}
\toprule
\multirow{2}{*}{Category} & \multirow{2}{*}{Method} & \multirow{2}{*}{\makecell{Venue \& \\ Year}} & \multicolumn{4}{c}{\makecell{Global Quality \\ Metrics}} & \multicolumn{3}{c}{\makecell{Artifact Specific \\ Metrics}} & \multicolumn{2}{c}{\makecell{Efficiency \\ Metrics \\($256^2$)}} \\
\cmidrule(lr){4-7} \cmidrule(lr){8-10} \cmidrule(lr){11-12}
& & & PSNR $\uparrow$ & SSIM $\uparrow$ & LPIPS $\downarrow$ & $\Delta E$ $\downarrow$ & PSNR-F $\uparrow$ & PSNR-NF $\uparrow$ & HAE $\downarrow$ & \makecell{FLOPs \\ (G) $\downarrow$} & \makecell{Runtime \\ (ms) $\downarrow$} \\
\midrule
\multirow{5}{*}{LUT-based} & 3DLUT~\cite{zeng2020learning} & TPAMI'20 & 30.34 & 0.96 & 0.06 & 4.17 & 23.87 & 30.34 & 19.12 & 26.34 & 9.36 \\
& SR-LUT~\cite{jo2021practical} & CVPR'21 & 29.76 & 0.85 & 0.12 & 5.66 & 21.35 & 29.58 & 10.21 & 25.39 & 8.25 \\
& SPF-LUT~\cite{li2024look} & CVPR'24 & 32.19 & 0.94 & 0.09 & 5.18 & 21.93 & 33.19 & 7.57 & 34.38 & 9.12 \\
& NILUT~\cite{conde2024nilut} & AAAI'24 & 32.31 & 0.95 & 0.07 & 4.50 & 24.86 & 32.93 & 4.87 & 30.89 & 7.12 \\
& DnLUT~\cite{yang2025dnlut} & CVPR'25 & 30.52 & 0.88 & 0.10 & 5.17 & 23.31 & 30.25 & 9.51 & 25.16 & 8.71 \\
% & ENNELUT & AAAI'25 & 30.97 & 0.90 & 0.08 & 4.5 & 31.86 & 30.89 & 8.5 & 2.0 & 30.8 & 0.08 \\
& CAST-LUT (Ours) & - & \textbf{34.96} & \textbf{0.99} & \textbf{0.03} & \textbf{2.71} & \textbf{30.74} & \textbf{34.96} & \textbf{4.10} & \textbf{23.32} & \textbf{6.09} \\
\midrule
\multirow{2}{*}{Classical} & CBM3D~\cite{dabov2007color} & TIP'07 & 30.57 & 0.90 & 0.22 & 4.73 & 27.49 & 31.57 & 18.53 & - & 43.11 \\
& MC-WNNM~\cite{xu2017multi} & ICCV'17 & 27.98 & 0.80 & 0.20 & 9.53 & 26.23 & 28.00 & 18.01 & - & 121.23 \\
\midrule
\multirow{2}{*}{\makecell{Scene\\Specific \\ Restoration}}
& Zero-DCE~\cite{guo2020zero} & CVPR'20 & 14.92 & 0.84 & 0.13 & 19.59 & 13.34 & 14.92 & 40.16 & 34.79 & 10.73 \\
& RUAS~\cite{liu2021retinex} & CVPR'21 & 19.96 & 0.68 & 0.35 & 31.30 & 8.73 & 9.96 & 28.49 & 43.84 & 11.34 \\
&
LightenDiffusion~\cite{Jiang_2024_ECCV} & ECCV'24 & 30.59 & 0.97 & 0.08 & 5.01 & 24.66 & 30.59 & 27.25 & 27.01 & 10.25 \\
& BPAM~\cite{lou2025learning} & ICCV'25 & 29.93 & 0.95 & 0.12 & 5.10 & 27.26 & 28.93 & 24.75 & 15.21& 13.04 \\
& HVI-CIDNet~\cite{yan2025hvi} & CVPR'25 & 32.17 & 0.98 & 0.04 & 2.92 & 26.10 & 33.17 & 17.39 & 27.50 & 14.94 \\
\bottomrule
\end{tabular}}
\caption{Quantitative comparison with state-of-the-art methods on our purple flare dataset. $\uparrow$ indicates higher is better, and $\downarrow$ indicates lower is better.
}
\label{tab:sota_comparison}
\end{table*}
% \begin{table*}[t]
% \centering
% \caption{Quantitative comparison with state-of-the-art methods on our purple flare dataset. $\uparrow$ indicates higher is better, and $\downarrow$ indicates lower is better.}
% \label{tab:sota_comparison}
% \footnotesize
% \setlength{\tabcolsep}{3pt}
% \begin{tabular}{l l l cccc ccc ccc}
% \toprule
% \multirow{2}{*}{Category} & \multirow{2}{*}{Method} & \multirow{2}{*}{\makecell{Venue \& \\ Year}} & \multicolumn{4}{c}{\makecell{Global Quality \\ Metrics}} & \multicolumn{3}{c}{\makecell{Artifact-Specific \\ Metrics}} & \multicolumn{3}{c}{\makecell{Efficiency \\ Metrics}} \\
% \cmidrule(lr){4-7} \cmidrule(lr){8-10} \cmidrule(lr){11-13}
% & & & PSNR $\uparrow$ & SSIM $\uparrow$ & LPIPS $\downarrow$ & $\Delta E$ $\downarrow$ & PSNR-F $\uparrow$ & PSNR-NF $\uparrow$ & HAE $\downarrow$ & \makecell{Params \\ (M) $\downarrow$} & \makecell{FLOPs \\ (G) $\downarrow$} & \makecell{Runtime \\ (s) $\downarrow$} \\
% \midrule
% \multirow{5}{*}{LUT-based} & SR-LUT~\cite{jo2021practical} & CVPR'21 & 29.76 & 0.85 & 0.12 & 5.66 & 21.35 & 29.58 & 10.2 & 0.047 & 25.39 & 8.25 \\
% & DnLUT~\cite{yang2025dnlut} & CVPR'25 & 30.52 & 0.88 & 0.10 & 5.17 & 23.31 & 30.25 & 9.51 & 1.53 & 25.16 & 8.71 \\
% & 3DLUT~\cite{zeng2020learning} & TPAMI'20 & 30.34 & 0.96 & 0.06 & 4.17 & 23.87 & 30.34 & 19.12 & 0.59 & 26.34 & 9.36 \\
% & SPF-LUT~\cite{li2024look} & CVPR'24 & 32.19 & 0.94 & 0.09 & 5.18 & 21.93 & 33.19 & 7.57 & 2.03 & 34.38 & 9.12 \\
% & NILUT~\cite{conde2024nilut} & AAAI'24 & 32.31 & 0.95 & 0.07 & 4.50 & 24.86 & 32.93 & 4.87 & 2.70 & 30.89 & 7.12 \\
% % & ENNELUT & AAAI'25 & 30.97 & 0.90 & 0.08 & 4.5 & 31.86 & 30.89 & 8.5 & 2.0 & 30.8 & 0.08 \\
% & CAST-LUT(Ours) & - & \textbf{34.96} & \textbf{0.99} & \textbf{0.03} & \textbf{2.71} & \textbf{30.74} & \textbf{34.96} & \textbf{4.10} & \textbf{0.355} & \textbf{23.32} & \textbf{6.09} \\
% \midrule
% \multirow{2}{*}{Classical} & CBM3D~\cite{dabov2007color} & TIP'07 & 30.57 & 0.90 & 0.22 & 4.73 & 27.49 & 31.57 & 18.53 & - & - & 43.11 \\
% & MC-WNNM~\cite{xu2017multi} & ICCV'17 & 27.98 & 0.80 & 0.20 & 9.53 & 26.23 & 28.00 & 18.0 & - & - & 121.23 \\
% \midrule
% \multirow{2}{*}{\makecell{Scene-Specific \\ Restoration}}
% &
% LightenDiffusion~\cite{Jiang_2024_ECCV} & ECCV'24 & 30.59 & 0.97 & 0.08 & 5.01 & 24.66 & 30.59 & 27.25 & 0.48 & 27.01 & 10.25 \\
% & RUAS~\cite{liu2021retinex} & CVPR'21 & 19.96 & 0.68 & 0.35 & 31.30 & 8.73 & 9.96 & 28.49 & 0.003 & 43.84 & 11.34 \\
% & Zero-DCE~\cite{guo2020zero} & CVPR'20 & 14.92 & 0.84 & 0.13 & 19.59 & 13.34 & 14.92 & 40.16 & 0.075 & 34.79 & 10.73 \\
% & BPAM~\cite{lou2025learning} & ICCV'25 & 29.93 & 0.95 & 0.12 & 5.10 & 27.26 & 28.93 & 24.75 & 0.62 & 15.21& 13.04 \\
% & HVI-CIDNet~\cite{yan2025hvi} & CVPR'25 & 32.17 & 0.976 & 0.04 & 2.92 & 26.10 & 33.17 & 17.39 & 1.88 & 27.50 & 14.94 \\
% \bottomrule
% \end{tabular}
% \end{table*}
\begin{figure*}[h!]
\centering
\includegraphics[width=\textwidth]{fig4.pdf} % You'll need to create this figure
\caption{Qualitative comparison with state-of-the-art methods on our PFSD dataset.}
\label{fig:SOTA}
\vspace{-2mm}
\end{figure*}
\section{Experiments}
\subsection{Experimental Settings}
\noindent \textbf{Datasets and Baselines. }
We conduct experiments on our new Purple Flare Synthesis Dataset (PFSD), created by applying a parametric synthesis pipeline to high-resolution frames from the DAVIS dataset. Our dataset consists of 4,987 pairs for training, 608 pairs for validation, and 618 pairs for testing. Further details on the dataset construction and the source code can be found in the supplementary material. For a comprehensive evaluation, we compare our method against state-of-the-art (SOTA) baselines from three distinct categories: classical, LUT-based, and scene-specific restoration methods.
\begin{figure*}[t]
\centering
\includegraphics[width=\textwidth]{fig5.pdf} % \columnwidth You'll need to create this figure
\caption{Visualization of learned semantic tokens from the CAST module.}
\label{fig:cast_viz}
\end{figure*}
\noindent \textbf{Metrics.}
To comprehensively evaluate our method, we report standard metrics: PSNR and SSIM for image fidelity, LPIPS for perceptual quality, and $\Delta E$ in the CIELAB space for color difference and efficiency measures: model parameters, FLOPs, and runtime. However, since global metrics fail to simultaneously evaluate targeted artifact removal and the preservation of clean regions, we propose a more fine-grained protocol.
we introduce two specialized metrics: Flare Region PSNR (\textbf{PSNR-F}) to measure removal effectiveness and Non-Flare Region PSNR (\textbf{PSNR-NF}) to quantify detail preservation in unaffected areas.
%However, we argue that these global metrics are fundamentally limited when evaluating the nuanced task of purple flare removal. Their limitations are twofold: on one hand, their full-image error averaging can mask residual artifacts, allowing a high-scoring model to still exhibit noticeable flare. On the other hand, they fail to measure "collateral damage” such as blurred textures or color distortion to unaffected regions caused by the removal process. Consequently, a single global score cannot simultaneously assess the effectiveness of targeted artifact removal and the preservation of background details.
%To enable a more fine-grained and decoupled evaluation that mirrors our model's design philosophy, we propose a new evaluation protocol. We first use a flare mask, $\mathbf{M}_{flare}$ (see Appendix), to partition the evaluation area and introduce two specialized metrics: (1) Flare Region PSNR (PSNR-F), which specifically measures the model's effectiveness at artifact removal within the masked region; and (2) Non-Flare Region PSNR (PSNR-NF), which quantifies the model's ability to preserve image details in the surrounding clean areas.
%While this decoupled PSNR provides a better assessment of spatial fidelity, as a signal-level metric, it cannot precisely measure the accuracy of chromatic restoration, the very core of this task. To address this, we further propose the Hue Alignment Error (HAE), a metric designed to better align with human visual perception. HAE calculates the circular hue difference between the output and ground truth within the flare region, weighted by saturation. This design is based on the perceptual principle that the human eye is far more sensitive to hue deviations in highly saturated areas than in less saturated, near-achromatic ones. HAE can therefore more authentically reflect the quality of color restoration. It is formally defined as:
Furthermore, to specifically assess the accuracy of color restoration, we propose the Hue Alignment Error (\textbf{HAE}). This perceptually-driven metric calculates the saturation-weighted circular hue difference within the flare region, reflecting that the human eye is more sensitive to hue errors in vibrant colors.
\begin{equation}
\text{HAE} = \frac{\sum_{(\mathbf{x,y}) \in \mathbf{M}_{flare}} \Delta H(\mathbf{x,y}) \cdot \mathbf{S}_{GT}(\mathbf{x,y})}{\sum_{(\mathbf{x,y}) \in \mathbf{M}_{flare}} \mathbf{S}_{GT}(\mathbf{x,y}) + \epsilon},
\end{equation}
where $\Delta H$ is the circular hue difference. Together, PSNR-F/NF and HAE provide a comprehensive framework for evaluating this localized removal task.
%\textcolor{red}{The detailed methodology for generating the mask $\mathbf{M}_{flare}$ is provided in the appendix.}
% However, these global metrics cannot specifically quantify model performance on purple flare artifacts or fidelity in non-artifact regions. We thus propose a Hue Alignment Error (HAE) metric, more perceptually relevant than standard signal-based errors. First, a flare mask $\mathbf{M}_{flare}$ is generated from the input to isolate artifact regions. Within this mask, we compute the circular difference between the output hue $\mathbf{H}_{output}$ and ground truth $\mathbf{H}_{GT}$. To align with human perception, where hue errors are more visible in vibrant colors each pixel's hue difference is weighted by the ground-truth saturation $\mathbf{S}_{GT}$. The final HAE score is the average of these saturation-weighted hue errors in the flare region; a lower score indicates more accurate color restoration.
\noindent \textbf{Implementation Details. }
The model was implemented in PyTorch and trained on an NVIDIA RTX 4090 (32G) via a two-stage strategy: a pre-trained CAST module (4096-entry codebook, 128-dim embedding) was loaded and frozen, then the main network trained for 100 epochs with AdamW (batch size 8, initial lr $1 \times 10^{-4}$ decayed by cosine annealing). Inputs were resized to $256 \times 256$ with random horizontal flips and color jittering. Composite loss weights were set to 1.0, 0.1, 2.0, and 0.1 for $\lambda_{1}, \lambda_{p}, \lambda_{f}, \lambda_{q}$.
%We implemented our model in PyTorch and trained it on an NVIDIA RTX 4090 GPU. We used a two-stage training strategy, first loading a pre-trained CAST module (4096-entry codebook, 128-dim embedding) and freezing its parameters. The main network was then trained for 100 epochs using the AdamW optimizer with a batch size of 8 and an initial learning rate of $1 \times 10^{-4}$, which was decayed via a cosine annealing schedule. Input images were resized to $256 \times 256$ and augmented with random horizontal flips and color jittering. The weights for our composite loss terms ($\lambda_{1}, \lambda_{p}, \lambda_{f}, \lambda_{q}$) were set to 1.0, 0.1, 2.0, and 0.1, respectively.
\subsection{Comparison with State-of-the-Art Methods}
% \noindent \textbf{Baselines.}
% To comprehensively evaluate our method, we compare it against a diverse set of state-of-the-art (SOTA) baselines. These include Classical Methods to highlight the advantages of learning-based paradigms; modern LUT-based Methods that operate in RGB space, to demonstrate the superiority of our decoupled HSV strategy; and SOTA Scene-Specific Image Restoration Methods for related tasks such as low-light enhancement and exposure correction. This rigorous comparison against traditional, global, and other specialized enhancement techniques serves to validate the effectiveness and necessity of our targeted approach for purple flare removal.
\noindent \textbf{Quantitative results.}
In the Table. \ref{tab:sota_comparison}, comprehensive quantitative comparisons on the PFSD test set demonstrate that our method achieves an HAE score of 4.10, the lowest among all methods, largely confirming its state-of-the-art performance in preserving chromatic fidelity. While general restoration methods like HVI-CIDNet perform well on global metrics such as $\Delta E$, they struggle with targeted chromatic correction. CAST-LUT consistently outperforms all baselines across standard and artifact-specific metrics, validating its overall restoration quality and perceptual similarity to the ground truth, while its lightweight design ensures efficient runtime for real-time use on resource-constrained devices.
%As shown in Tab.~\ref{tab:sota_comparison}, we conduct a comprehensive quantitative comparison on our PFSD test set. The results demonstrate that our proposed CAST-LUT consistently outperforms all baselines across both standard and artifact-specific metrics. Notably, in our proposed metrics designed for this specific task, our method achieves a PSNR-F of 30.74, significantly surpassing the next best method, CBM3D (27.49). This indicates a superior capability in accurately restoring the flare-corrupted regions. Furthermore, our method obtains an HAE score of 4.10, which is the lowest among all methods by a large margin, confirming its state-of-the-art performance in preserving chromatic fidelity. While some general restoration methods like HVI-CIDNet perform well on global metrics such as $\Delta E$, they struggle with the targeted chromatic correction, as reflected by their poor HAE score (17.39). Our method also establishes the best results in all global quality metrics, including PSNR (34.96) and LPIPS (0.03), validating its overall restoration quality and perceptual similarity to the ground truth.
\noindent \textbf{Qualitative results.}
Fig.~\ref{fig:SOTA} shows the visual comparisons on two challenging scenes from our test set. The first example (top row, a cyclist near grass) presents a common failure case where methods might misidentify and desaturate the naturally green-colored grass. As seen in the magnified patches, methods like d) and l) incorrectly alter the color of the grass. In contrast, our method (m) precisely removes the purple flare from the high-contrast areas while perfectly preserving the color fidelity of the grass. The second example (bottom row, a person in a glider) shows a sky region severely corrupted by purple flare. While most competing methods either fail to completely remove the purple cast (e.g., g, h) or introduce unnatural color shifts (e.g., d, i), our method successfully restores the natural sky color and cloud details without any visible artifacts, demonstrating the effectiveness of our perception-correction paradigm.
\begin{table}[t]
\centering
\resizebox{\columnwidth}{!}{%
\begin{tabular}{@{}llcccc@{}}
\toprule
\textbf{ID} & \textbf{Model Configuration} & \textbf{PSNR $\uparrow$} & \textbf{PSNR-F $\uparrow$} & \textbf{PSNR-NF $\uparrow$} & \textbf{HAE $\downarrow$} \\
\midrule
\multicolumn{6}{c}{\textit{(1) Analysis of Core Correction Space \& Mechanism}} \\
\midrule
M1 & w/o HSV (uses RGB 1D-LUTs) & 28.04 & 24.15 & 29.81 & 8.81 \\
M2 & w/o Decoupled LUTs (uses 3D RGB-LUT) & 30.05 & 25.66 & 30.95 & 7.79 \\
\midrule
\multicolumn{6}{c}{\textit{(2) Analysis of Guidance Module}} \\
\midrule
M3 & w/o CAST (simple CNN encoder) & 31.54 & 29.01 & 29.42 & 6.5 \\
M4 & w/o VQ in CAST (continuous features) & 29.50 & 28.45 & 29.49 & 6.7 \\
\midrule
\multicolumn{6}{c}{\textit{(3) Analysis of Architecture}} \\
\midrule
M5 & w/o Residual Branch & 25.82 & 26.95 & 27.37 & 5.3 \\
\midrule
\textbf{Full} & \textbf{CAST-LUT (Ours)} & \textbf{34.96} & \textbf{30.74} & \textbf{34.35} & \textbf{4.1} \\
\bottomrule
\end{tabular}%
}
\caption{Ablation study of the CAST-LUT framework.}
\vspace{-4mm}
\label{tab:ablation}
\end{table}
\subsection{Ablation study}
To validate our design choices and quantify each key component’s contribution in CAST-LUT, we conducted comprehensive ablation experiments: starting with the full model, we systematically removed or replaced individual modules and analyzed performance impacts via our metrics. Results in Table~\ref{tab:ablation} confirm the efficacy of each proposed component.
%-----------------------------------------------------------
% \begin{figure}[h!]
% \centering
% \includegraphics[width=\columnwidth]{ablation_figure.png} % You'll need to create this figure
% \caption{Visual comparison for the ablation study. (a) Input with purple flare. (b) Our full model successfully removes the flare while preserving color. (c) The RGB-based variant (M1) fails to remove the purple hue effectively. (d) Without the fringing loss (M7), noticeable purple artifacts remain. (e) Without the residual branch (M6), textures in the non-flare regions appear slightly blurred.}
% \label{fig:ablation_visual}
% \end{figure}
\noindent \textbf{Effectiveness of the Decoupled HSV Space.}We validate our core mechanism by testing variants that operate in RGB space. As shown in Tab.~\ref{tab:ablation}, removing decoupled HSV correction and using RGB 1D-LUTs (M1) causes a catastrophic drop in performance, with PSNR-F plummeting from 30.74 to 24.15 and HAE worsening from 4.1 to 8.81. This highlights the severe limitations of color-coupled spaces. Similarly, using a standard 3D RGB-LUT (M2) is also significantly inferior, confirming the superiority of our decoupled 1D-LUT design for precise, targeted correction.
\begin{table}[b]
\centering
\setlength{\tabcolsep}{2pt}
\begin{tabular}{@{}lcccc@{}}
\toprule
\textbf{Variant} & $N_L=1$ & $N_L=8$ & $N_L=16$ (Ours) & $N_L=32$ \\
\midrule
\textbf{PSNR $\uparrow$} & 30.11 & 31.35 & \textbf{34.96} & 32.43 \\
\textbf{HAE $\downarrow$} & 5.1 & 4.4 & \textbf{4.1} & 5.8 \\
\bottomrule
\end{tabular}
\caption{Ablation on the number of fused LUTs ($N_L$). }
\label{tab:ablation_nl}
\end{table}
\noindent\textbf{Effectiveness of the CAST Guidance.}
%To demonstrate the importance of our semantic guidance, we replaced the CAST module with a simple CNN encoder (M3) and disabled its VQ step (M4). Both changes led to a notable performance decline. Specifically, removing CAST (M3) drops the PSNR-F to 29.01, while using continuous features without VQ (M4) drops it further to 28.45. This confirms that CAST's ability to generate discrete, semantic tokens provides more robust and effective guidance than simple, low-level features.
To show our semantic guidance's importance, we replaced CAST with a simple CNN encoder (M3) and disabled its VQ step (M4). M3 drops PSNR-F to 29.01, M4 further to 28.45. This confirms CAST's discrete semantic tokens offer more robust, effective guidance than simple low-level features.
Figure~\ref{fig:cast_viz} intuitively demonstrates the semantic vocabulary learned by CAST using two key examples, comparing the full model (use VQ Tokens) with a baseline model that directly uses continuous features for guidance (w/o VQ Tokens). We feature blue sky as it is a common background for flares, and its spectral proximity to purple severely tests the model's color stability. Concurrently, by visualizing a token for a purple object, we demonstrate CAST's ability to distinguish a legitimate object from a purple flare based on contextual features rather than color alone. This content-aware discrimination is precisely what enables our model to eliminate artifacts while preserving the color fidelity of all objects in the scene. %This is because it can associate purple flare with contextual features such as high intensity and soft edges. Such content-aware discriminative ability allows our model to precisely eliminate purple flare while fully preserving the color fidelity of any purple objects in the scene.
\noindent \textbf{Effectiveness of Architectural Choices and the number of fused LUTs ($N_L$).}
% \begin{table}[h!]
% \centering
% \caption{Ablation on the number of fused LUTs ($N_L$).
% \label{tab:ablation_nl}
% \begin{tabular}{@{}lccccc@{}}
% \toprule
% \textbf{Variant} & $N_L=1$ & $N_L=4$ & $N_L=8$ & $N_L=16$ (Ours) $N_L=32$ \\
% \midrule
% \textbf{PSNR $\uparrow$} & 32.11 & 32.35 & 32.41 & 32.43 & 32.43\\
% \textbf{HAE $\downarrow$} & 5.1 & 4.4 & 4.1 & 4.1 & 4.1 \\
% \bottomrule
% \end{tabular}}
% \end{table}
% The final experiments validate our key architectural and loss function choices. First, we analyze the impact of our multi-LUT fusion mechanism by ablating the number of fused LUTs, $N_L$. The quantitative results in Table \ref{tab:ablation_nl} and the qualitative comparison in Figure \ref{fig:lut} both confirm that performance peaks at our chosen configuration of $N_L=16$, which achieves the best PSNR of \textbf{34.96} while effectively suppressing the visual artifacts.
%
% In addition to the LUT fusion, other components are also critical. In M5, removing the residual branch severely degrades detail preservation in non-flare regions, causing PSNR-NF to drop from 34.35dB to 27.37dB.
Final experiments validate our key architectural and loss function choices. First, we analyze our multi-LUT fusion mechanism by ablating the fused LUT count $N_L$. Results in Table \ref{tab:ablation_nl} and Figure \ref{fig:lut} confirm performance peaks at $N_L=16$, achieving the best PSNR with effective artifact suppression.
Other components are also critical: removing the residual branch in M5 severely degrades non-flare region detail preservation.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{fig6.pdf}
\caption{Visual ablation for the number of fused LUTs. %($N_L$). Correction quality improves with $N_L$ from 1 to 8, peaks at 16, but further increases cause color shift.
}
\vspace{-3mm}
\label{fig:lut}
\end{figure}
\begin{figure}[b]
\centering
\includegraphics[width=\linewidth]{fig7.pdf}
\caption{Visual ablation experiment of key loss terms.}
\label{fig:loss}
\end{figure}
% \begin{figure}[h!]
% \centering
% \includegraphics[width=\columnwidth]{loss_mask_visualization.png} % 您需要创建这张图
% \caption{Visualization of our Purple Fringing Suppression Loss. (a) Input image with flare. (b) The generated penalty mask $\mathbf{M}_{penalty}$, where brighter areas indicate higher penalty weights, precisely targeting the flare region. (c) Our full model, guided by this loss, cleanly removes the artifact. (d) The result without this loss (variant M7) shows significant residual flare in the area highlighted by the mask.
% \label{fig:loss_mask_viz}
% \end{figure}
\noindent \textbf{Analysis of Key Loss Weights.}
As presented in Table \ref{tab:ablation_loss_weights} and Figure \ref{fig:loss}, our ablation study on the loss weights, $\lambda_f$ and $\lambda_p$, clearly demonstrates the necessity of both terms. Removing the flare suppression loss ($\mathcal{L}_f$) causes the HAE metric to worsen dramatically from 4.1 to 7.2, while removing the perceptual loss ($\mathcal{L}_p$) results in a significantly poorer LPIPS score of 0.061. Our final balanced configuration achieves the best overall performance by effectively navigating the trade-off between pixel-wise accuracy and perceptual quality.
%We conducted an ablation study to validate our chosen loss weights, with quantitative results summarized in Table \ref{tab:ablation_loss_weights} and visual comparisons shown in Figure \ref{fig:loss}. The necessity of the specialized flare loss is evident; removing it ($\lambda_{f}=0.0$) causes severe color errors, with HAE soaring to 7.2. The experiments also show that both insufficient ($\lambda_{f}=0.5$) and excessive ($\lambda_{f}=5.0$) weights are suboptimal for color correction. Similarly, the perceptual loss is crucial for visual quality, as its removal ($\lambda_{p}=0.0$) leads to the worst LPIPS score of 0.061. This analysis confirms that our final configuration ($\lambda_{f}=2.0, \lambda_{p}=0.1$) achieving the best results across all key metrics.
\begin{table}[t]
\centering
% Further reduce column spacing for a better fit
\setlength{\tabcolsep}{3.5pt}
% You have 6 columns including the ID
\begin{tabular}{@{}llccccc@{}}
\toprule
% The header is fine, no changes needed here
\textbf{ID} & \textbf{Variant} & $\lambda_{f}$ & $\lambda_{p}$ & \textbf{PSNR $\uparrow$} & \textbf{HAE $\downarrow$} & \textbf{LPIPS $\downarrow$} \\
\midrule
% Abbreviate the long text in the 'Variant' column
I & w/o $\mathcal{L}_{f}$ & 0.0 & 0.1 & 32.04 & 7.2 & 0.058 \\
II & Low $\lambda_{f}$ & 0.5 & 0.1 & 32.21 & 5.8 & 0.054 \\
III & High $\lambda_{f}$ & 5.0 & 0.1 & 32.32 & 5.9 & 0.052 \\
\midrule
IV & w/o $\mathcal{L}_{p}$ & 2.0 & 0.0 & 32.38 & 4.2 & 0.061 \\
V & High $\lambda_{p}$ & 2.0 & 0.5 & 32.15 & 5.6 & 0.049 \\
\midrule
% Use \multicolumn to span the first two columns for the "Ours" row
\multicolumn{2}{@{}l}{\textbf{Ours (Balanced)}} & \textbf{2.0} & \textbf{0.1} & \textbf{34.96} & \textbf{4.1} & \textbf{0.03} \\
\bottomrule
\end{tabular}
\caption{Ablation study on the weights of the Purple Flare Suppression Loss ($\lambda_{f}$) and the Perceptual Loss ($\lambda_{p}$). }
\label{tab:ablation_loss_weights}
\vspace{-3mm}
\end{table}
%Collectively, these experiments demonstrate that each component of our proposed CAST-LUT framework is well-justified and contributes meaningfully to its state-of-the-art performance.
\section{Disscuss}
To verify practical applicability, we deployed the CAST-LUT model on mobile devices, achieving real-time performance. Leveraging adaptive 1D HSV LUTs, our approach is far more efficient than methods relying on large 3D LUTs or complex CNNs, while preserving fine details in unaffected areas through pixel-wise correction. Specifically, tests on the iPhone 14 recorded an 82ms execution time for 4K processing, demonstrating efficient hardware-software compatibility. Fig.~\ref{fig:enter-label} shows the mobile application's interface and some failure and successful cases in real world. Supplementary material includes leading methods’ real-world results for broader comparison.
%To verify its practical applicability, we deployed our CAST-LUT model on mobile devices. It achieves real-time performance, processing HD images at 10 FPS on a standard mobile GPU. Our approach, which generates adaptive 1D HSV LUTs, is significantly more efficient than methods relying on large 3D LUTs or complex CNNs. The final pixel-wise correction ensures that fine details in unaffected areas are preserved. We conducted our software performance experiment on the iQOO Z9 Turbo+ smartphone. This device is powered by the MediaTek Dimensity 9300 flagship chipset, renowned for its powerful ``All Big Core" CPU architecture. During testing, we recorded an execution time of 82 milliseconds for our program while processing a task at 4K resolution. This excellent result demonstrates the hardware platform's capability to efficiently execute our software.
\begin{figure}[h]
\centering
\includegraphics[width=0.9\linewidth]{fig8.pdf}
\caption{Sample image purple flare removing application on mobile devices based on the proposed CAST-LUT and fail and succcessful examples in real world.}
\label{fig:enter-label}
\vspace{-3mm}
\end{figure}
\section{Conclusion}
We propose CAST-LUT, a purple flare removal framework operating in decoupled HSV space to address traditional methods’ poor generalization and RGB-to-HSV conversion noise. Its core is CAST, which encodes purple flare artifacts into stable high-level semantic tokens. This avoids direct conversion noise while guiding the generation of independent 1D-LUTs for precise color correction. Extensive experiments on our large-scale PFSD dataset, using metrics like PSNR-F/NF and HAE, confirm its superior artifact removal and detail preservation performance.
%We propose CAST-LUT, a purple flare removal framework operating in the decoupled HSV color space, addressing poor generalization of traditional methods and noise from RGB-to-HSV conversion. Its core contribution is the CAST, which encodes purple flare artifacts into stable high-level semantic tokens. This avoids noise induced by direct color space conversion while guiding the generation of independent 1D-LUTs for color correction. Extensive experiments on our large-scale dataset (PFSD) using metrics like PSNR-F/NF and HAE show CAST-LUT achieves superior artifact removal and detail preservation.
%We propose CAST-LUT, a framework for purple flare removal in the decoupled HSV color space, which addresses the issues of poor generalization in traditional methods and noise introduction during conversion from RGB to HSV space. Our core contribution is the introduction of a chroma-aware spectral tokenizer (CAST), which diagnoses purple flare artifacts into stable, high-level semantic representations, thereby avoiding noise introduction caused by direct color space conversion. These semantic tokens then guide the generation of independent 1D lookup tables (1D-LUTs) for color correction. Extensive experiments on our newly constructed large-scale dataset (PFSD) and evaluation metrics (PSNR-F/NF and HAE) demonstrate that CAST-LUT achieves the best performance in artifact removal and detail preservation.
\section{Acknowledgments}
This work was supported by the National Natural Science Foundation of China Project (No. 62172265) and Shandong Provincial Natural Science Foundation (ZR2025MS1025, ZR2025MS1036).
\bibliography{aaai2026}
\makeatletter
\@ifundefined{isChecklistMainFile}{
% We are compiling a standalone document
\newif\ifreproStandalone
\reproStandalonetrue
}{
% We are being \input into the main paper
\newif\ifreproStandalone
\reproStandalonefalse
}
\makeatother
\ifreproStandalone
\fi
\setlength{\leftmargini}{20pt}
\makeatletter\def\@listi{\leftmargin\leftmargini \topsep .5em \parsep .5em \itemsep .5em}
\def\@listii{\leftmargin\leftmarginii \labelwidth\leftmarginii \advance\labelwidth-\labelsep \topsep .4em \parsep .4em \itemsep .4em}
\def\@listiii{\leftmargin\leftmarginiii \labelwidth\leftmarginiii \advance\labelwidth-\labelsep \topsep .4em \parsep .4em \itemsep .4em}\makeatother
\setcounter{secnumdepth}{0}
\renewcommand\thesubsection{\arabic{subsection}}
\renewcommand\labelenumi{\thesubsection.\arabic{enumi}}
\newcounter{checksubsection}
\newcounter{checkitem}[checksubsection]
\newcommand{\checksubsection}[1]{%
\refstepcounter{checksubsection}%
\paragraph{\arabic{checksubsection}. #1}%
\setcounter{checkitem}{0}%
}
\newcommand{\checkitem}{%
\refstepcounter{checkitem}%
\item[\arabic{checksubsection}.\arabic{checkitem}.]%
}
\newcommand{\question}[2]{\normalcolor\checkitem #1 #2 \color{blue}}
\newcommand{\ifyespoints}[1]{\makebox[0pt][l]{\hspace{-15pt}\normalcolor #1}}
\clearpage
\setcounter{section}{0}
\section{Supplementary Material}
This supplementary material provides additional details to support our paper. Section A elaborates on the network architecture, including the specific implementations of the LUTGenerator, and WeightGenerator. Section B describes our synthetic dataset (PFSD), which covers the parameterized flare synthesis process and key hyperparameters. Section C presents further ablation analysis, offering additional studies on the impact of VQ codebook size and encoder/decoder depth on model performance and efficiency. Section D showcases extensive qualitative results, with visual comparisons against state-of-the-art methods on complex scenes, night scenes from the synthetic PFSD dataset, and various real-world images.
\section*{A. HSV-LUT Color Correction Module and Implementation}\label{sec:1}
\subsection*{A.1. LUTGenerator Architecture.}
The LUTGenerator is implemented as a Multi-Layer Perceptron (MLP) that maps the input feature vector $\mathbf{f}_{\text{token}}$ to a flat vector containing all necessary parameters for the 1D-LUTs. Its architecture is as follows:
\noindent \textbf{Layer 1.} A linear layer that maps the input dimension from hidden\_dim to hidden\_dim.
\noindent \textbf{Activation.} A GELU activation function (\texttt{nn.GELU}).
\noindent \textbf{Layer 2 (Output).} A final linear layer that maps from hidden\_dim to the total number of LUT parameters. The output dimension is calculated as:
\begin{equation}
\mathbf{D}_\text{out} = N_{L} \times \mathbf{C}_\text{HSV} \times \mathbf{S}_\text{LUT},
\end{equation}
where $N_L$ is the number of LUT sets, $\mathbf{C}_\text{HSV}=3$ for the H, S, and V channels,
and the size of each individual 1D-LUT is determined by $\mathbf{S}_\text{LUT}$ control points.
The resulting flat vector of dimension $D_{out}$ is then reshaped into a structured tensor $\mathbf{P} \in \mathbb{R}^{B \times N_L \times \mathbf{C}_\text{HSV} \times \mathbf{S}_\text{LUT}}$, where $B$ is the batch size.
\subsection*{A.2. WeightGenerator Architecture.}
Running in parallel to the LUTGenerator, the WeightGenerator is another MLP designed to predict the fusion weights for each of the $N_L$ LUT sets. Its architecture is as follows:
\noindent \textbf{Layer 1.} A linear layer that maps the input dimension from hidden\_dim to a smaller intermediate dimension hidden\_dim / 4. Given the input feature vector $\mathbf{f}_{\text{token}}$, this operation produces a pre-activation vector $\mathbf{h'}$:
\begin{equation}
\mathbf{h'} = \mathbf{f}_{\text{token}} W_1^T + b_1
\end{equation}
\noindent \textbf{Activation.} A GELU activation function (\texttt{nn.GELU}) is applied to the pre-activation vector $\mathbf{h'}$ to produce the activated intermediate representation $\mathbf{h}$:
\begin{equation}
\mathbf{h} = \text{GELU}(\mathbf{h'})
\end{equation}
\noindent \textbf{Layer 2 (Output).} A final linear layer maps the intermediate representation $\mathbf{h}$ to a vector of $N_L$ raw scores (logits), denoted as $\mathbf{z}$:
\begin{equation}
\mathbf{z} = \mathbf{h} W_2^T + b_2
\end{equation}
A Softmax function is subsequently applied to these logits to ensure the final weights $\mathbf{W}$ sum to one, forming a valid probability distribution:
\begin{equation}
\mathbf{W}_i = \text{Softmax}(\mathbf{z})_i = \frac{\exp(\mathbf{z}_i)}{\sum_{j=1}^{N_L} \exp(\mathbf{z}_j)}
\end{equation}
% \subsection*{A.3. Algorithm for 1D-LUT Application.}
% \label{sec:appendix_lut_application}
% This section details the mathematical formulation for applying a one-dimensional Look-Up Table (1D-LUT) to a single channel of an image via linear interpolation, as referenced in the main paper. %This operation is fundamental to our color correction module.
% Given a single input pixel value $\mathbf{p}_\text{in} \in [0, 1]$ from an image channel (e.g., $\mathbf{H}$, $\mathbf{S}$, or $\mathbf{V}$) and a corresponding 1D-LUT, denoted as a vector $\mathbf{P}$ of size $\mathbf{S}_\text{LUT}$, the output pixel value $\mathbf{p}_\text{out}$ is calculated through the following steps:
% \begin{enumerate}
% \item \textbf{Scale Input Value:} First, the input pixel value is scaled to the LUT's index range $[0, \mathbf{S}_\text{LUT}-1]$. This creates a floating-point index $\mathbf{v}_\text{float}$.
% \begin{equation}
% \mathbf{v}_\text{float} = \mathbf{p}_\text{in} \times (\mathbf{S}_\text{LUT} - 1).
% \end{equation}
% \item \textbf{Identify Bounding Indices:} We identify the two nearest integer indices in the LUT that bound the floating-point index.
% \begin{equation}
% \mathbf{x}_\text{0} = \lfloor \mathbf{v}_\text{float} \rfloor, \quad \mathbf{x}_\text{1} = \mathbf{x}_\text{0} + 1,
% \end{equation}
% To prevent out-of-bounds errors, $\mathbf{x}_\text{0}$ is clamped to a maximum of $\mathbf{S}_\text{LUT}-2$.
% \item \textbf{Look Up Bounding Values:} We retrieve the corresponding output values from the LUT at these two integer indices.
% \begin{equation}
% \mathbf{y}_\text{0} = \mathbf{P}[\mathbf{x}_\text{0}], \quad \mathbf{y}_\text{1} = \mathbf{P}[\mathbf{x}_\text{1}].
% \end{equation}
% \item \textbf{Calculate Interpolation Weight:} The weight for the linear interpolation is determined by the fractional part of $v_{float}$.
% \begin{equation}
% w = \mathbf{v}_\text{float} - \mathbf{x}_\text{0}.
% \end{equation}
% \item \textbf{Perform Linear Interpolation:} Finally, the output pixel value $p_{out}$ is calculated as the weighted average of the two bounding LUT values.
% \begin{equation}
% \mathbf{p}_\text{out} = (1 - w) \cdot \mathbf{y}_\text{0} + w \cdot \mathbf{y}_\text{1},
% \end{equation}
% \end{enumerate}
% This entire process is applied pixel-wise to the entire channel. %For the Hue channel, this algorithm is applied after the continuity of its LUT $\mathbf{P}$ has been enforced (by setting $\mathbf{P}[S_{LUT}-1] = \mathbf{P}[0]$), as described in the main text.
% Finally, a residual branch consisting of 3 convolutional layers extracts high-frequency detail features from the original input image. These features are fused with the LUT-corrected image from the main branch to ensure detail preservation in the final output. The key hyperparameters of the generator module are summarized in Table \ref{tab:hyperparams}.
% \begin{table}[h!]
% \centering
% \caption{Hyperparameters for the LUT and Weight Generation modules.}
% \label{tab:hyperparams}
% \begin{tabular}{lcc}
% \toprule
% \textbf{Hyperparameter} & \textbf{Symbol} & \textbf{Value} \\
% \midrule
% Hidden Dimension & hidden\_dim & 512 \\
% Number of LUT Sets & $N_L$ & 16 \\
% 1D-LUT Size & $\mathbf{S}_\text{LUT}$ & 256 \\
% \bottomrule
% \end{tabular}
% \end{table}
\section*{B.Purple Flare Synthesis Dataset (PFSD)}\label{sec:2}
%Our Purple Flare Synthesis Dataset (PFSD) is the first large-scale, paired dataset constructed for this task. The construction pipeline begins with selecting diverse, clean image frames from the high-resolution video dataset DAVIS to serve as our ground truth. To mimic the characteristic appearance of purple flare at high-luminance and object contour edges, we first use a Sobel operator to detect edges and combine this with a high-luminance threshold (pixel value > 220) to identify candidate regions for flare injection. We then apply a Gaussian blur to these regions to simulate the flare's diffuse effect and blend a predefined purple color into them using additive blending, thereby generating the flare-corrupted input images. Finally, the candidate regions identified in the second step are used directly as the ground-truth mask to support the calculation of our proposed PSNR-F/NF and HAE metrics.
Our Purple Flare Synthesis Dataset (PFSD) is the first large-scale, paired dataset constructed for this task. We first select diverse, clean image frames from the high-resolution video dataset DAVIS as our ground truth, denoted as \( \mathbf{I}_\text{GT} \). We then generate purple flare input images \( \mathbf{I}_\text{flare} \) using a physically motivated function, designed to mimic the characteristic appearance of purple flare in high-luminance regions and at object contour edges. This process is governed by a set of key hyperparameters, including the highlight percentile $\rho_h$, gradient threshold $\tau_g$, edge width $w_{edge}$, blend strength $\alpha_s$, and radial gamma $\gamma$.
The specific generation process is as follows:
\subsubsection*{Dynamic Highlight Detection}
To identify potential flare regions, we first calculate a dynamic highlight threshold, $\tau_h$, defined as the $\rho_h$-th percentile of the grayscale input image $\mathbf{I}_\text{gray}$. We then generate a binary highlight mask $\mathbf{M}_\text{bright}$ as follows:
\begin{equation}
\mathbf{M}_\text{bright} = (\mathbf{I}_\text{gray} > \tau_h).
\end{equation}
\begin{table*}[ht!]
\centering
\caption{Key parameters for the synthetic purple flare generation pipeline. Default values are those used to generate our dataset.}
\label{tab:flare_params}
\begin{tabular}{@{}llc@{}}
\toprule
\textbf{Parameter} & \textbf{Description} & \textbf{Value} \\
\midrule
\texttt{highlight\_pct} & Percentile for the dynamic highlight threshold. & 99.0 \\
\texttt{grad\_thresh} & Gradient magnitude threshold for the Sobel edge detector. & 25 \\
\texttt{edge\_width} & Width (in pixels) of the flare band. & 80 \\
\texttt{strength} & Global blending strength of the purple overlay. & 0.7 \\
\texttt{gamma} & Exponent for the radial mask to intensify the corner effect. & 2.2 \\
\bottomrule
\end{tabular}
\end{table*}
\subsubsection*{Edge Candidate Identification}
We use a Sobel operator to compute the gradient magnitude $G$ of the grayscale image. An edge mask $\mathbf{M}_\text{edge}$, is formed by thresholding the gradient magnitude with $\tau_g$:
\begin{equation}
G = \sqrt{(\text{Sobel}_x * \mathbf{I}_\text{gray})^2 + (\text{Sobel}_y * \mathbf{I}_\text{gray})^2},
\end{equation}
where $\quad \mathbf{M}_\text{edge} = (G > \tau_g)$.
\subsubsection*{Flare Mask Generation}
The initial region for the purple flare is identified as the intersection of highlight and edge regions, creating a candidate mask $\hat{\mathbf{M}}_\text{flare}$:
\begin{equation}
\hat{\mathbf{M}}_\text{flare} = \mathbf{M}_\text{bright} \cap \mathbf{M}_\text{edge}.
\end{equation}
\subsubsection*{Flare Simulation}
To simulate the width and diffusion properties of flares, we expand the candidate mask $\hat{\mathbf{M}}_\text{flare}$ by applying morphological dilation with a structural element $K_e$, whose size is determined by the hyperparameter $w_{edge}$.
\begin{equation}
\mathbf{M}_\text{dilated} = \hat{\mathbf{M}}_\text{flare} \oplus K_e,
\end{equation}
where $\oplus$ denotes morphological dilation.
$\mathbf{M}_\text{dilated}$ is convolved with a Gaussian kernel $G_\sigma$ to create soft edges, generating the final flare band mask.
\begin{equation}
\mathbf{M}_\text{flare} = \mathbf{M}_\text{dilated} * G_\sigma,
\end{equation}
where the standard deviation $\sigma$ is proportional to $w_{\text{edge}}$.
\subsubsection*{Spatially-Varying Alpha Mask}
To model the influence of lens geometry, where flares typically intensify toward the corners, we generate a radial attenuation mask \( \mathbf{R} \).
\begin{equation}
\mathbf{R}(x,y) = \left( \frac{\text{dist}\bigl( (x,y), \text{center} \bigr)}{\dist_{\text{max}}} \right)^\gamma,
\end{equation}
This mask $\mathbf{R}$ is combined with the normalized flare band $\mathbf{M}_\text{flare}$ and the blend strength $\alpha_s$ to create the final spatially-varying alpha mask $\alpha$:
\begin{equation}
\alpha = \frac{\mathbf{M}_\text{flare}}{\max(\mathbf{M}_\text{flare})} \cdot \mathbf{R} \cdot \alpha_s.
\end{equation}
\subsubsection*{Alpha Blending}
The final purple flare image \( \mathbf{I}_{\text{flare}} \) is generated by alpha blending the ground truth image \( \mathbf{I}_{\text{GT}} \) with a predefined purple color \( C_p \) using the generated alpha mask.
\begin{equation}
\mathbf{I}_\text{flare} = \mathbf{I}_\text{GT} \cdot (1 - \alpha) + C_p \cdot \alpha
\end{equation}
%Finally, the candidate regions identified in flare mask generation are used directly as the ground-truth mask to support the calculation of our proposed PSNR-F/NF and HAE metrics. The entire process is detailed in Algorithm~\cite{alg:synthesis}.
The key parameters controlling the flare's appearance are detailed in Table~\ref{tab:flare_params}. The entire synthesis process is detailed in Algorithm~\ref{alg:synthesis}. After generation, the dataset is divided into training, validation, and test sets. To prevent data leakage where frames from the same video sequence might appear in both training and evaluation splits, the division is performed at the scene level. The list of all scenes is randomly shuffled, and entire scenes are then assigned to the training, test, and validation sets, with proportions of 80\%, 10\%, and 10\%, respectively.
Finally, the candidate mask $\hat{\mathbf{M}}_\text{flare}$ is directly used as the ground-truth mask $\mathbf{M}_\text{GT}$ for metric calculation. We select this explicit mask instead of using the diffuse final flare band mask $\mathbf{M}_\text{flare}$ for visual blending. This is because $\hat{\mathbf{M}}_\text{flare}$ enables accurate measurement of the model's ability to restore core-damaged regions, avoiding penalties for failing to precisely reconstruct the feathered halo details of simulated flares. Let $\mathbf{I}_\text{out}$ be the model's output image; the PSNR calculations for the flare region (PSNR-f) and non-flare region (PSNR-nf) are as follows:
\begin{equation}
\text{PSNR-F} = 10 \log_{10} \left( \frac{\text{MAX}_I^2 \cdot \sum \mathbf{M}_\text{GT}}{\sum (\mathbf{I}_\text{out} - \mathbf{I}_\text{GT})^2 \odot \mathbf{M}_\text{GT}} \right),
\end{equation}
\begin{equation}
\text{PSNR-NF} = 10 \log_{10} \left( \frac{\text{MAX}_I^2 \cdot \sum (1-\mathbf{M}_\text{GT})}{\sum (\mathbf{I}_\text{out} - \mathbf{I}_\text{GT})^2 \odot (1-\mathbf{M}_\text{GT})} \right),
\end{equation}
where $\odot$ is element-wise multiplication.
To specifically evaluate the chromatic accuracy of the restoration, we designed the Hue Alignment Error (HAE), a metric more perceptually relevant than standard signal-based errors like PSNR. HAE is defined as the saturation-weighted average of the circular hue difference between the model's output $\mathbf{I}_\text{out}$ and the ground-truth $\mathbf{I}_\text{GT}$, calculated exclusively within the regions of the original input image $\mathbf{I}_\text{in}$ affected by purple flare. A lower HAE score signifies a more accurate color restoration.
\begin{algorithm}
\caption{Parametric Purple Flare Synthesis}
\label{alg:synthesis}
\begin{algorithmic}[l]
\Statex \textbf{Input:} Ground truth image $\mathbf{I}_\text{GT}$.
\Statex \textbf{Parameters:} Highlight percentile $\rho_h$, gradient threshold $\tau_g$, edge width $w_{edge}$, blend strength $\alpha_s$, radial gamma $\gamma$.
\Statex \textbf{Output:} Purple flare image $\mathbf{I}_\text{flare}$ and ground-truth mask $\mathbf{M}_\text{GT}$.
\State $\mathbf{I}_\text{gray} \leftarrow \text{Grayscale}(\mathbf{I}_\text{GT})$
\State $\tau_h \leftarrow \text{Percentile}(\mathbf{I}_\text{gray}, \rho_h)$
\State $\mathbf{M}_\text{bright} \leftarrow (\mathbf{I}_\text{gray} > \tau_h)$
\If{$\text{sum}(\mathbf{M}_\text{bright}) = 0$} \Return None, None \EndIf
\State $G \leftarrow \text{SobelMagnitude}(\mathbf{I}_\text{gray})$
\State $\mathbf{M}_\text{edge} \leftarrow (G > \tau_g)$
\State $\hat{\mathbf{M}}_\text{flare} \leftarrow \mathbf{M}_\text{bright} \cap \mathbf{M}_\text{edge}$
\If{$\text{sum}(\hat{\mathbf{M}}_\text{flare}) = 0$} \Return None, None \EndIf
\State $\mathbf{M}_\text{GT} \leftarrow \hat{\mathbf{M}}_\text{flare}$
\State $K_e \leftarrow \text{GetStructuringElement}(\text{shape=ELLIPSE, size}=w_{edge})$
\State $\mathbf{M}_\text{dilated} \leftarrow \text{Dilate}(\hat{\mathbf{M}}_\text{flare}, K_e)$
\State $\mathbf{M}_\text{flare} \leftarrow \text{GaussianBlur}(\mathbf{M}_\text{dilated}, \sigma=0.6 \cdot w_{edge})$
\State $R \leftarrow \text{RadialFalloffMask}(\text{shape of } \mathbf{I}_\text{GT}, \gamma)$
\State $\alpha \leftarrow \frac{\mathbf{M}_\text{flare}}{\max(\mathbf{M}_\text{flare})} \cdot \mathbf{R} \cdot \alpha_s$
\State Let $C_p$ be the target purple color (e.g., [255, 100, 255] in BGR)
\State $\mathbf{I}_\text{flare} \leftarrow \mathbf{I}_\text{GT} \cdot (1 - \alpha) + C_p \cdot \alpha$
\State \Return $\text{clip}(\mathbf{I}_\text{flare}, 0, 255)$, $\mathbf{M}_\text{GT}$
\end{algorithmic}
\end{algorithm}
A binary flare mask $\mathbf{M}_\text{flare}$ is generated from the input image to precisely identify the location of purple halos. This mask is used to locate pixels that satisfy two conditions: being on high-contrast edges detected by the Sobel filter, while exhibiting hues in the purple spectrum (e.g., 260°-340°) and significant saturation in the HSV color space. The specific calculation process is as follows: first, both the output image and the ground-truth image are converted to the HSV color space to separate hue, saturation, and brightness information. Then, we extract the hue channel $\mathbf{H}_\text{out}$ of the output image, as well as the hue $\mathbf{H}_\text{GT}$ and saturation $\mathbf{S}_\text{GT}$ channels of the ground-truth image. Within the region defined by the mask, the circular hue difference is calculated pixel by pixel.
\begin{equation}
\Delta H = \min(|\mathbf{H}_\text{out} - \mathbf{H}_\text{GT}|, 360 - |\mathbf{H}_\text{out} - \mathbf{H}_\text{GT}|),
\end{equation}
which correctly measures the shortest distance on the 360-degree hue circle. To align with human perception, where hue errors are more visible in vibrant colors, each $\Delta H$ value is then weighted by the saturation of the corresponding pixel in the ground-truth image, $\mathbf{S}_{GT}$. The final HAE score is the average of these saturation-weighted errors, defined as:
\begin{equation}
\text{HAE} = \frac{\sum_{(\mathbf{x,y}) \in \mathbf{M}_\text{flare}} \Delta \mathbf{H}(\mathbf{x,y}) \cdot \mathbf{S}_\text{GT}(\mathbf{x,y})}{\sum_{(\mathbf{x,y}) \in \mathbf{M}_\text{flare}} \mathbf{S}_\text{GT}(\mathbf{x,y}) + \epsilon},
\end{equation}
where $\epsilon$ is a small constant to prevent division by zero.
% The Hue Alignment Error (HAE) is a perceptually-driven metric that calculates the saturation-weighted circular hue difference specifically within the flare region, reflecting that the human eye is more sensitive to hue errors in vibrant colors. It is defined as:
% \begin{equation}
% \text{HAE} = \frac{\sum_{(\mathbf{x,y}) \in M_{GT}} \Delta H(\mathbf{x,y}) \cdot S_{GT}(\mathbf{x,y})}{\sum_{(\mathbf{x,y}) \in M_{GT}} S_{GT}(\mathbf{x,y}) + \epsilon},
% \end{equation}
% where $\Delta H$ is the circular hue difference, $\epsilon$ is a small constant to prevent division by zero..
\section*{C. Additional Ablation Analysis}\label{sec:3}
\subsection*{C.1. Impact of Codebook Size in the VQ Module}
The VQ layer is the core of the CAST module, and its codebook size directly affects the expressive power of the semantic tokens. In Table~\ref{tab:codebook_ablation_en} and Figure~\ref{tab:codebook_ablation_en}, we study the impact of different codebook sizes on model performance. The results show that a codebook that is too small (e.g., 1024) cannot learn sufficiently rich semantic patterns, leading to a performance drop. Conversely, an overly large codebook (e.g., 8192) increases model parameters and the risk of overfitting without bringing significant performance gains. A codebook size of 4096 achieves the best balance between performance and model complexity.
\begin{table}[h!]
\centering
\caption{Visualization of Ablation study on different codebook sizes.}
\label{tab:codebook_ablation_en}
\begin{tabular}{cccc}
\toprule
\textbf{Codebook Size} & \textbf{FLOPs (G) $\downarrow$} & \textbf{PSNR $\uparrow$} & \textbf{HAE $\downarrow$} \\
\midrule
1024 & 19.45 & 33.52 & 6.83 \\
2048 & 21.69 & 34.15 & 5.71 \\
\textbf{4096 (Ours)} & \textbf{23.32} & 34.96 & \textbf{4.10} \\
8192 & 26.05 & \textbf{35.03} & 4.15 \\
\bottomrule
\end{tabular}
\end{table}
\subsection*{C.2. Impact of Encoder/Decoder Depth}
The depth of the encoder and decoder in the CAST module determines the hierarchy of feature extraction. The results show in Table~\ref{tab:depth_ablation_en} and visualized in Figure~\ref{fig:depth_ablation_en}. The experiments prove that a network that is too shallow (2 layers) cannot extract robust high-level features, resulting in poor performance. While deepening the network to 6 layers brings slight performance improvements, it also significantly increases the computational cost. Therefore, a 4-layer depth is the optimal configuration we chose, striking a good balance between feature extraction capability and model efficiency.
\begin{figure}
\centering
\includegraphics[width=1\linewidth]{Afig8.pdf}
\caption{Ablation study on different codebook sizes.}
\label{fig:codebook_ablation_en}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=1\linewidth]{Afig9.pdf}
\caption{Visualization of the Ablation Study on Encoder/Decoder Depth.}
\label{fig:depth_ablation_en}
\end{figure}
\begin{table}[h!]
\centering
\caption{Ablation study on encoder/decoder depth.}
\label{tab:depth_ablation_en}
\begin{tabular}{ccc}
\toprule
\textbf{Depth (Conv Layers)} & \textbf{PSNR $\uparrow$} & \textbf{HAE $\downarrow$} \\
\midrule
2 & 32.89 & 5.31 \\
\textbf{4 (Ours)} & \textbf{34.96} & \textbf{4.10} \\
6 & 34.91 & 4.19 \\
\bottomrule
\end{tabular}
\end{table}
\section*{D. More Qualitative Results}\label{sec:4}
In this section, we present extensive qualitative results to intuitively demonstrate the robustness and superiority of our proposed method. The comparisons are divided into two categories: results from complex daylight scenes and challenging night scenes in the PFSD dataset, as well as results from real-world images used to test generalization ability.
\subsection*{D.1. Additional Qualitative Comparisons on the PFSD Dataset}
To further demonstrate the comprehensive performance of the proposed method, additional comparisons with state-of-the-art approaches were conducted across various scenarios in the PFSD test set. These scenarios range from daylight scenes with severe backlighting and complex textures (Figs. \ref{fig:1} and \ref{fig:2}) to challenging night scenes (Figs. \ref{fig:3}).
The results highlight the superiority of our method. It not only removes purple flares more effectively but also excels in preserving details and maintaining color fidelity in non-flare regions. In night scene scenarios, while other methods often leave residual artifacts or introduce unnatural color changes, the proposed method successfully corrects the images.
\subsection*{D.2. Qualitative Comparisons on Real-World Images}
To verify the practical applicability and generalization ability of the model, we tested it on real-world images not included in the PFSD dataset. As shown in Figs. \ref{fig:4}, \ref{fig:5}, and \ref{fig:6}, the comparisons demonstrate that the proposed model effectively generalizes to real-world artifacts different from synthetic data, successfully removing purple flares while preserving the authenticity of the original photos. However, we note that in some rare and extreme cases, such as when the flare’s spectrum significantly deviates from typical purple flares (atypical colors, see the second and third examples in Fig. \ref{fig:6}) or when the flare is particularly large (see the first example in Fig. \ref{fig:4}), our model may fail to achieve perfect removal.
\begin{figure*}
\centering
\includegraphics[width=1\linewidth]{Afig4.pdf}
\caption{Visual comparison of scenes with complex textures from the PFSD dataset.. While removing purple flares, our method accurately preserves the original textures and gloss. }
\label{fig:1}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=1\linewidth]{Afig5.pdf}
\caption{Visual comparison on backlit scenes from the PFSD dataset.. Our method excels at handling the severe purple flare at the boundary between the sky and trees, restoring a natural color transition.}
\label{fig:2}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=1\linewidth]{Afig6.pdf}
\caption{Visual comparison of all methods on a challenging night scene from the PFSD dataset. Our method effectively removes the purple flare around the lights while preserving details in the dark areas.}
\label{fig:3}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=1\linewidth]{Afig1.pdf}
\caption{Visual comparison of all methods on a real-world photograph with purple flare.}
\label{fig:4}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=1\linewidth]{Afig2.pdf}
\caption{Visual comparison of all methods on a real-world photograph with purple flare.}
\label{fig:5}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=1\linewidth]{Afig3.pdf}
\caption{Visual comparison of all methods on a real-world photograph with purple flare.}
\label{fig:6}
\end{figure*}
\end{document}