Patent Description:
Abnormal black levels in image sensors, such as complementary metal-oxide-semiconductor (CMOS) image sensors, may result in visible reddish tints in black regions of an image. Color mismatch in image sensors may be amplified by an image signal processor (ISP). For example digital gain or dynamic gain compression (DRC) performed by an ISP may amplify the color mismatch, resulting in such reddish tints. <CIT> describes a method of image processing. The method includes receiving at least part of an input image file. The at least part of the input image file includes input image data representing an image and reference tone mapping strength data representing a reference tone mapping strength parameter for deriving an input value representing an amount of spatially-variant tone mapping.

<CIT> describes a method for processing an image in which an estimated ambient light level of the captured image is determined and used to compute an optical-optical transfer function (OOTF) to correct the image to preserve an apparent contrast of the image under the estimated ambient light level in a viewing environment.

The claimed invention is defined by the appended claims. Further restricted embodiments are provided by the description and the drawings.

Aspects of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which like reference numerals refer to similar elements.

Aspects of the present disclosure may be used for detecting and correcting abnormal color tinted pixels in an image captured under low-light conditions. Abnormal color tinted pixels in an image may result from outputs from an image sensor indicating little to no light (which may be intended to be represented by a deep black). The color tinting may be amplified by a digital gain or a DRC performed by an ISP in processing the outputs from the image sensor. Such abnormal color tints may result in a black pixel of an image including a visible reddish tint. Conventional techniques for correcting such color tinted pixels may have a high false positive rate in detecting color tinted pixels, resulting in color degradation in one or more areas of an image not including color tinted pixels. Conventional techniques for correcting such color tinted pixels may additionally or alternatively have a high false negative rate in detecting color tinted pixels, resulting in a final image including pixels with uncorrected reddish tints. Conventional techniques typically process raw image data. Since using black level correction may not effectively suppress reddish tints in black pixels, and raw image data for red and green colors may be similar, a final image may include one or more black portions having alternating reddish and greenish tinted pixels.

Methods and apparatuses of the example implementations of the present disclosure may detect and correct pixels exhibiting such undesirable color tints of pixels of an image captured in low light environments. For example, an apparatus may detect one or more pixels that are converted from a grey pixel into a color tinted pixel at a stage in an image processing pipeline. When such pixels are detected, the color tint may be removed by replacing each of such pixels with a corresponding pixel from an earlier stage in the image processing pipeline. For example, color tinting may be caused by or amplified by one or more tone mapping operations in the image processing pipeline. Replacing a color tinted pixel with a corresponding grey pixel from an earlier stage may include replacing the tone mapped, color tinted pixel with a corresponding pixel from a stage in the image processing pipeline before the one or more tone mapping operations.

While conventional color tint correction techniques may operate on raw image data, some example implementations of the present disclosure may operate on image data in a YUV color space, where Y refers to the luminance, U to the blue projection chrominance, and V to the red projection chrominance. Other implementations may operate in other similar luma/chroma color spaces. Using such color spaces allows example implementations to focus color tint correction directly on the chrominance, without affecting the luminance of output pixels.

In the following description, numerous specific details are set forth, such as examples of specific components, circuits, and processes to provide a thorough understanding of the present disclosure. The term "coupled" as used herein means connected directly to or connected through one or more intervening components or circuits. Also, in the following description and for purposes of explanation, specific nomenclature is set forth to provide a thorough understanding of the present disclosure. However, it will be apparent to one skilled in the art that these specific details may not be required to practice the teachings disclosed herein. In other instances, well-known circuits and devices are shown in block diagram form to avoid obscuring teachings of the present disclosure. Some portions of the detailed descriptions which follow are presented in terms of procedures, logic blocks, processing, and other symbolic representations of operations on data bits within a computer memory. In the present disclosure, a procedure, logic block, process, or the like, is conceived to be a self-consistent sequence of steps or instructions leading to a desired result. The steps are those requiring physical manipulations of physical quantities. Usually, although not necessarily, these quantities take the form of electrical or magnetic signals capable of being stored, transferred, combined, compared, and otherwise manipulated in a computer system.

Unless specifically stated otherwise as apparent from the following discussions, it is appreciated that throughout the present application, discussions utilizing the terms such as "accessing," "receiving," "sending," "using," "selecting," "determining," "normalizing," "multiplying," "averaging," "monitoring," "comparing," "applying," "updating," "measuring," "deriving," "settling" or the like, refer to the actions and processes of a computer system, or similar electronic computing device, that manipulates and transforms data represented as physical (electronic) quantities within the computer system's registers and memories into other data similarly represented as physical quantities within the computer system's memories or registers or other such information storage, transmission or display devices.

In the figures, a single block may be described as performing a function or functions; however, in actual practice, the function or functions performed by that block may be performed in a single component or across multiple components, and/or may be performed using hardware, using software, or using a combination of hardware and software. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps are described below generally in terms of their functionality. Also, the example devices may include components other than those shown, including well-known components such as a processor, memory, and the like.

Aspects of the present disclosure are applicable to any suitable electronic device (such as a security system with one or more cameras, smartphones, tablets, laptop computers, digital video and/or still cameras, web cameras, and so on) configured to or capable of capturing images or video. While described below with respect to a device having or coupled to one camera, aspects of the present disclosure are applicable to devices having any number of cameras and are therefore not limited to devices having one camera. Aspects of the present disclosure are applicable for cameras configured to capture still images as well as capture video and may be implemented in devices having or coupled to cameras of different capabilities.

The term "device" is not limited to one or a specific number of physical objects (such as one smartphone, one camera controller, one processing system and so on). As used herein, a device may be any electronic device with one or more parts that may implement at least some portions of this disclosure. While the below description and examples use the term "device" to describe various aspects of this disclosure, the term "device" is not limited to a specific configuration, type, or number of objects.

<FIG> is a block diagram of an example device <NUM> configured to perform color correction, according to some implementations of the present disclosure. The example device <NUM> may include or be coupled to a camera <NUM>, a processor <NUM>, a memory <NUM> storing instructions <NUM>, and a controller <NUM>. In some implementations, the device <NUM> may include (or be coupled to) a display <NUM>, and a number of input/output (I/O) components <NUM>. The device <NUM> may also include a power supply <NUM>, which may be coupled to or integrated into the device <NUM>. The device <NUM> may include additional features or components not shown. For example, a wireless interface, which may include a number of transceivers and a baseband processor, may be included for a wireless communication device. In another example, the device <NUM> may include or be coupled to additional cameras other than the camera <NUM>.

The camera <NUM> may be any suitable camera capable of capturing still images (such as individual captured image frames) and/or capturing video (such as a succession of captured image frames). The camera <NUM> may include a single image sensor or be a dual camera module or any other suitable module with one or more image sensors, such as one or more CMOS image sensors.

The memory <NUM> may be a non-transient or non-transitory computer readable medium storing computer-executable instructions <NUM> to perform all or a portion of one or more operations described in this disclosure. The processor <NUM> may be one or more suitable processors capable of executing scripts or instructions of one or more software programs (such as instructions <NUM>) stored within the memory <NUM>. In some aspects, the processor <NUM> may be one or more general purpose processors that execute instructions <NUM> to cause the device <NUM> to perform any number of functions or operations. In additional or alternative aspects, the processor <NUM> may include integrated circuits or other hardware to perform functions or operations without the use of software.

While shown to be coupled to each other via the processor <NUM> in the example of <FIG>, the processor <NUM>, the memory <NUM>, the controller <NUM>, the optional display <NUM>, and the optional I/O components <NUM> may be coupled to one another in various arrangements. For example, the processor <NUM>, the memory <NUM>, the controller <NUM>, the optional display <NUM>, and/or the optional I/O components <NUM> may be coupled to each other via one or more local buses (not shown for simplicity).

The display <NUM> may be any suitable display or screen allowing for user interaction and/or to present items (such as captured images, video, or a preview image) for viewing by a user. In some aspects, the display <NUM> may be a touch-sensitive display. The I/O components <NUM> may be or include any suitable mechanism, interface, or device to receive input (such as commands) from the user and to provide output to the user. For example, the I/O components <NUM> may include (but are not limited to) a graphical user interface, keyboard, mouse, microphone, and speakers, and so on. The display <NUM> and/or the I/O components <NUM> may provide a preview image to a user and/or receive a user input for adjusting one or more settings of the camera <NUM>.

The controller <NUM> may include one or more controllers. The one or more controllers may be configured to control the camera <NUM>. The controller <NUM> may include an image signal processor (ISP) <NUM>, which may be one or more image signal processors to process captured image frames or video provided by the camera <NUM>. In some aspects, the controller <NUM> or the ISP <NUM> may execute instructions from a memory (such as instructions <NUM> from the memory <NUM> or instructions stored in a separate memory coupled to the ISP <NUM>). In other aspects, the controller <NUM> or the ISP <NUM> may include specific hardware. The controller <NUM> or the ISP <NUM> may alternatively or additionally include a combination of specific hardware and the ability to execute software instructions. For example, the ISP <NUM> may include or otherwise be configured to implement one or more stages of an image processing pipeline.

<FIG> shows an example processing flow <NUM> for detecting and correcting incorrectly color tinted pixels in a captured image, according to some implementations of the present disclosure. In some aspects, the processing flow <NUM> may be included in an image processing pipeline implemented or controlled by the device <NUM> shown in <FIG>. While the processing flow <NUM> may be described as being performed by the device <NUM>, the processing flow <NUM> may also be performed by any other suitable image capture device.

With respect to <FIG>, raw image data may be an input to the processing flow <NUM>. Such raw image data may, for example, be received from one or more image sensors included in or coupled to the device <NUM>, or from an analog front end of the device <NUM>. At raw image processing stage <NUM>, the device <NUM> may perform one or more operations on the raw image data (such as one or more operations for black level correction, lens shading correction (LSC), auto focus, auto exposure, auto white balance, and so on). After processing the image data at the raw image processing stage <NUM>, the device <NUM> may process the image data at the color correction matrix (CCM) stage <NUM>. The processed raw image data may be converted into a red green blue (RGB) color space before proceeding to CCM stage <NUM>. Alternatively, the device <NUM> may convert the data into the RGB color space at CCM stage <NUM>. At CCM stage <NUM>, the device <NUM> may perform one or more operations on the image data in the RGB color space (such as one or more operations for color correction in the RGB color space). In some examples, the device <NUM> may transform the RGB pixel values of the image data into a defined and known color space, represented by the color correction matrix. After the device <NUM> processes the image data at CCM stage <NUM>, the device <NUM> processes the image data at denoising stage <NUM>, performing one or more denoising operations on the image data. In some implementations, the denoising stage <NUM> may process the image data in a YUV color space, for example, the device <NUM> may convert the image data from the RGB color space into the YUV color space either before denoising stage <NUM> or at denoising stage <NUM>. The output image data from the denoising stage <NUM> may be referred to as reference image data. For example, output YUV image data, representing the image data in the YUV color space, may include reference Y data representing the luminance of the image data and reference U data and reference V data representing the chrominance of the image data.

After the denoising stage <NUM>, the processing flow <NUM> splits into multiple paths (such as an upper flow <NUM> and a lower flow <NUM> depicted in <FIG>). Discussing the upper flow <NUM> first, the device <NUM> processes the image data at local tone mapping (LTM) stage <NUM>. At LTM stage <NUM>, the device <NUM> may perform one or more tone mapping operations on the image data. In some aspects, the LTM stage <NUM> may operate on the image data in an RGB color space. Thus, prior to or as a part of the LTM stage <NUM>, the device <NUM> may convert the image data into the RGB color space. Tone mapping may adjust the brightness of different regions of the image data or combine different exposures in order to increase a local contrast between disparate regions of a scene. Local tone mapping may adjust the brightness of a given pixel based on local, as in nearby, features of the image, as opposed to global or spatially uniform tone mapping. After LTM stage <NUM>, the device <NUM> may process the image data at gamma compression stage <NUM>. At gamma compression stage <NUM>, the device <NUM> may perform one or more operations to increase the exposure of underexposed parts of the image data, while decreasing the exposure of overexposed parts of the image data. In some aspects, the device <NUM> may apply a gamma function. For example, the device <NUM> may apply a gamma filter, such as <MAT>, where <NUM> < γ < <NUM> and A > <NUM>. In applying the gamma function, the device <NUM> maps the input luminance Yin in a domain of <MAT> to the output luminance (Yout) in a range of [<NUM>,<NUM>]. In the example gamma filter, γ may be adjusted to regulate the contrast of the image, with lower values corresponding to lower contrast and increased exposure for underexposed portions of the image. A may be set to less than <NUM> to ensure that the exposure of one or more portions of the image is decreased enough to keep them from being overexposed.

After the gamma compression stage <NUM>, the device <NUM> may process the image data at sharpness stage <NUM>, which may perform one or more sharpness enhancing operations on the image data, for example an edge enhancement operation, a deblurring filtering operation, or similar. In some aspects, the device <NUM> may process the image data in the YUV color space at sharpness stage <NUM>. Accordingly, either before or as a part of sharpness stage <NUM>, the device <NUM> may convert the image data into the YUV color space. The output image data of the sharpness stage <NUM> may be referred to as current image data. For example, output YUV image data, representing the image data in the YUV color space, may include current Y data representing the luminance of the image data and a current U data and current V data representing the chrominance of the image data. The current Y data may be provided to the combiner <NUM>. The current U data and current V data may be provided to the color correction stage <NUM>.

At the color correction stage <NUM>, the device <NUM> may selectively output either the reference U data and reference V data or the current U data and current V data for each pixel of the image data. As mentioned above, for images captured in low-light or dark environments, some grey pixels may be turned into color tinted pixels during image processing, which may result in a reddish tint appearing in black areas of an image. This may often result from tone mapping operations. As discussed in more detail below, the color correction stage <NUM> may detect when a captured image appears to be captured in a sufficiently dark environment. For such images, the device <NUM> may detect when a grey pixel is turned into a color tinted pixel (such as by comparing a reference U and V data and corresponding current U and V data). For such pixels, the device <NUM> may replace the current U and V data with the corresponding reference U and V data. In this manner, the image processing steps resulting in the abnormal color tint may be undone. The color correction stage <NUM> may output corrected U data and corrected V data to the combiner <NUM>. The combiner <NUM> combines the current luminance data with the corrected U data and corrected V data to generate respective Y, U, and V data for the output image data. The output image data thus reflect the current luminance (Y) data and the corrected chrominance (U and V) data.

<FIG> shows an illustrative flowchart showing an example operation <NUM> for processing image data in a color correction stage, according to some implementations of the present disclosure. In some aspects, the operation <NUM> may be performed by a device <NUM> at the color correction stage <NUM> of <FIG>. Reference U and V data from the denoising stage <NUM> and current U and V data from the sharpness stage <NUM> may be used to generate corrected U and V data for an image. As discussed above, the reference U and V data may correspond to the image data before tone mapping has been performed. The current U and V data may correspond to the image data after tone mapping has been performed.

The abnormal color tint typically occurs in images captured in a dark environment. Accordingly, the device <NUM> makes a threshold determination <NUM> whether the image data meets a threshold darkness level. An example threshold darkness level may include an auto exposure correction gain threshold. For example, the device <NUM> may determine whether a total auto exposure correction gain for a captured image exceeds the auto exposure correction gain threshold. As discussed above, such auto exposure correction may occur as a part of raw image processing stage <NUM>. Another example threshold darkness level may include a camera flash enablement threshold. For example, the device <NUM> may determine whether or not the environment was sufficiently dark for a camera flash to be enabled. Another example threshold darkness level may a light sensor threshold. For example, the device <NUM> may determine whether a light sensor included in or coupled to the device <NUM> senses less than a threshold amount of light. If the threshold darkness level is not met, then the operation <NUM> may output the current U data and the current V data as the corrected U data and the corrected V data, and the process may end.

If the threshold darkness level is met, then the image is a candidate image for replacing one or more pixels' current U and V data with reference U and V data. The operation <NUM> may proceed to chrominance replacement step <NUM>, where the device <NUM> may perform a series of determinations for each pixel of the current and reference U and V data. For each pixel, the device <NUM> may determine in block <NUM> whether the pixel is grey in the reference U and V data. In some aspects, this determination may include determining that an absolute difference between the reference U data and the midpoint in the range of possible values of U (the "midpoint U value") is less than a reference threshold and an absolute difference between the reference V data and a midpoint in the range of possible values of V (the "midpoint V value") is also less than the reference threshold. Thus, a pixel is determined to be grey when its U and V values are sufficiently close to the midpoint U value and the midpoint V value, respectively. A pixel is therefore grey when (|IREF U - MID U| < REF_TH) and (REF V - MID V| < REF_TH), where REF U is the reference U data and REF V is the reference V data, MID U is the midpoint U value and MID V is the midpoint V value. For example, if the possible range of U and V values is between <NUM> and <NUM>, then the midpoint U and V values are each <NUM>. Determining whether the pixel is grey may include determining whether or not both (|REF U - <NUM>| < REF_TH) and (|REF V - <NUM>| < REF_TH). In some implementations, the reference threshold may be a single-digit reference threshold, for U and V having ranges between <NUM> and <NUM>. In one example, the reference threshold may be <NUM>. In some implementations, determining that a pixel in the reference data is grey may also include determining that an absolute difference between the reference U data and reference V data is less than the reference threshold, that is, determining that |REF U - REF V| < REF_TH. If each of these absolute differences is less than the reference threshold, then the pixel is considered grey. If the pixel is not considered grey in the reference U and V data, then the current U and current V data are maintained in the corrected U and V data for that pixel. If the pixel is grey in the reference U and V data, then the device <NUM> may determine, in block <NUM>, whether the pixel is color tinted in the current U and V data.

Note that in some implementations the reference threshold may vary based at least in part on the automatic exposure control (AEC) gain and/or the dynamic range compression (DRC) gain. For example, for larger AEC gains or DRC gains, a higher reference threshold may be used as compared to when the AEC gain or DRC gain is lower. The AEC gain and DRC gain may depend on the characteristics of the image sensor used by the device <NUM>. Consequently, the reference threshold may vary under the same lighting conditions for different image sensors under the same lighting conditions.

At block <NUM>, determining whether or not the pixel is color tinted in the current U data and current V data may include determining that each of the current U data and current V data has at least a minimum difference and no more than a maximum difference from the midpoint U value and midpoint V value, respectively, that is, determining that an absolute difference between the current U data and the midpoint U value, and an absolute difference between the current V data and the midpoint V value are each between a current minimum value and less than a current maximum value. Thus, a pixel in the current U data and current V data may be determined to be color tinted when |CUR U - MID U| ∈ [CURMIN, CURMAX] and |CUR V - MID V| ∈ [CURMIN, CURMAX], where CUR U and CUR V are the current U data and current V data, respectively, CURMIN is the current minimum value, and CURMAX is the current maximum value. The current minimum value may be greater than or equal to the reference threshold. In some implementations, the current minimum value may be the same as the reference threshold, and may be, for example, <NUM> when the U and V data range between <NUM> and <NUM>. In some implementations the current maximum value may be selected to be a multiple of the current minimum value, such as three times the current minimum value. In one example, the current maximum value may be <NUM> when the U and V data range between <NUM> and <NUM>. If the pixel is not determined to be color tinted in the current U data and current V data, then the current U data and current V data may be maintained in the corrected U data and corrected V data. If the pixel is determined to be color tinted, then the corrected U data and corrected V data for the pixel may include the reference U data and reference V data, rather than the current U data and current V data. Processing each pixel in the current and reference U and V data using chrominance replacement step <NUM> thus generates the corrected U data and corrected V data for images meeting the threshold darkness level.

The operation <NUM> may thus generate the corrected U data and corrected V data, which may, for example, be output to the combiner <NUM> for incorporation as the U data and V data in the output of the processing flow <NUM>.

Note that while operation <NUM> describes generating the corrected U data and corrected V data on a per pixel basis, in some other implementations the corrected U data and corrected V data may be determined on a per-window or per-region basis. For example, the image corresponding to the reference and current U and V data may be divided into a plurality of windows or regions, and for each window or region, the corrected U and V data may include either the reference U and V data or the current U and V data. In some implementations, a representative value may be selected for each of the reference U and V data and the current U and V data. Such a representative value may be a predetermined pixel of the region or window, such as a center pixel, or an upper-leftmost pixel, or the like, or may be an average value, such as a mean or median value, of pixels in the window or region. In some examples, the chrominance replacement step <NUM> of <FIG> may be performed on the representative value to determine whether the corrected U and V data for the window or region should include the values of the reference U and V data or the current U and V data.

Further, note that while the operation <NUM> describes replacing abnormally color-tinted pixels in the current U data and current V data with the corresponding pixels of the reference U data and reference V data, in some other implementations abnormally color-tinted pixels in the current U data and current V data may be replaced by U and V data for a predetermined grey pixel value. For example, at block <NUM>, in response to determining that the pixel is color-tinted in the current U data and current V data, the chrominance replacement step <NUM> may replace the current U data and the current V data with the U and V data for the predetermined grey pixel value. In some aspects, such a predetermined grey pixel value may have U and V data corresponding to the midpoint U value and the midpoint V value.

<FIG> is an illustrative flow chart depicting an example operation <NUM> for color correction in an image processing pipeline, according to some implementations of the present disclosure. The operation <NUM> may be performed by any suitable device including or coupled to an image processing pipeline. In some implementations, the operation <NUM> may be performed by device <NUM> shown in <FIG>. At block <NUM>, the device <NUM> receives first image data corresponding to reference luminance data and reference chrominance data for each of a plurality of pixels. At block <NUM>, the device <NUM> determines that the first image data corresponds to a raw image captured in a dark environment. For example, this determination may be based at least in part on an automatic exposure control (AEC) gain associated with the raw image being greater than a threshold AEC gain. At block <NUM>, the device <NUM> generates second image data by performing one or more tone mapping operations on the first image data, where the second image data corresponds to current luminance data and current chrominance data for each of the plurality of pixels. At block <NUM>, the device <NUM> generates output image data for each pixel of the plurality of pixels. For each pixel of the plurality of pixels, generating the output data may include generating the output data to include an output luminance value of a corresponding pixel of the current luminance data (408A), and to include chrominance values of the corresponding pixel from a selected one of the reference chrominance data and the current chrominance data, where the selection is based at least in part on the reference chrominance data and the current chrominance data (408B). In some aspects, the reference chrominance data may be selected when the corresponding pixel of the first image data is determined to be grey and the corresponding pixel of the second image data is determined to be color tinted. In some aspects, the current chrominance data is selected when the corresponding pixel of the first image data is not determined to be grey or the corresponding pixel of the second image data is not determined to be color tinted.

The techniques described herein may be implemented in hardware, software, firmware, or any combination thereof, unless specifically described as being implemented in a specific manner. Any features described as modules or components may also be implemented together in an integrated logic device or separately as discrete but interoperable logic devices. If implemented in software, the techniques may be realized at least in part by a non-transitory processor-readable storage medium (such as the memory <NUM> in the example device <NUM> of <FIG>) comprising instructions <NUM> that, when executed by the processor <NUM> (or the controller <NUM> or the ISP <NUM>), cause the device <NUM> to perform one or more of the methods described above. The non-transitory processor-readable storage medium may form part of a computer program product, which may include packaging materials.

The non-transitory processor-readable storage medium may comprise random access memory (RAM) such as synchronous dynamic random access memory (SDRAM), read only memory (ROM), non-volatile random access memory (NVRAM), electrically erasable programmable read-only memory (EEPROM), FLASH memory, other known storage media, and the like. The techniques additionally, or alternatively, may be realized at least in part by a processor-readable communication medium that carries or communicates code in the form of instructions or data structures and that can be accessed, read, and/or executed by a computer or other processor.

The various illustrative logical blocks, modules, circuits, and instructions described in connection with the embodiments disclosed herein may be executed by one or more processors, such as the processor <NUM> or the ISP <NUM> in the example device <NUM> of <FIG>. Such processor(s) may include but are not limited to one or more digital signal processors (DSPs), general purpose microprocessors, application specific integrated circuits (ASICs), application specific instruction set processors (ASIPs), field programmable gate arrays (FPGAs), or other equivalent integrated or discrete logic circuitry. The term "processor," as used herein may refer to any of the foregoing structures or any other structure suitable for implementation of the techniques described herein. In addition, in some aspects, the functionality described herein may be provided within dedicated software modules or hardware modules configured as described herein. A general purpose processor may be a microprocessor and/or any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.

Claim 1:
A method (<NUM>) for color correction in an image processing pipeline, comprising:
receiving (<NUM>) first image data corresponding to reference luminance data and reference chrominance data for each of a plurality of pixels;
determining (<NUM>) that the first image data corresponds to a raw image captured in a dark environment;
generating (<NUM>) second image data by performing one or more tone mapping operations on the first image data, the second image data corresponding to current luminance data and current chrominance data for each of the plurality of pixels; and
generating (<NUM>) output image data to include, for each pixel of the plurality of pixels:
an output luminance value of a corresponding pixel of the current luminance data; and
chrominance values of the corresponding pixel from a selected one of the reference chrominance data and the current chrominance data, the selection based at least in part on the reference chrominance data and the current chrominance data, wherein, for each pixel of the plurality of pixels, the output image data includes the reference chrominance data instead of the current chrominance data when the corresponding pixel of the first image data is detected as grey and the corresponding pixel of the second image data is detected as color tinted.