Interactively adjusting light source brightness in digital images with non-destructive synthetic lens blur
Methods, systems, and non-transitory computer readable storage media are disclosed for generating a lens blur effect in a digital image with interactive light source adjustment. The disclosed system determines a gradient mask by detecting edges of a luminance map comprising luminance values of pixels in a digital image. The disclosed system determines a highlight mask by thresholding the luminance map to determine a subset of pixels with luminance values meeting a threshold luminance. The disclosed system also generates a gradient-highlight mask including pixel values from a combination of the gradient mask and the highlight mask. The disclosed system further generates a highlight guide image comprising indications of one or more light sources in the digital image based on the gradient-highlight mask and the highlight mask.
1 . A computer-implemented method comprising:
determining, by at least one processor, a gradient mask by applying a gradient filter to a luminance map comprising luminance values of pixels in a digital image to detect edges indicating boundaries in the luminance map;
determining, by the at least one processor, a highlight mask by thresholding the luminance map to determine a subset of pixels with luminance values meeting a threshold luminance;
generating, by the at least one processor, a gradient-highlight mask by selecting pixel values that are included in the gradient mask and the highlight mask; and
generating, by the at least one processor, a highlight guide image comprising indications of one or more light sources in the digital image based on the gradient-highlight mask and the highlight mask.
2 . The computer-implemented method of claim 1 , further comprising generating the luminance map for the digital image by downsampling the digital image and determining the luminance values of the pixels.
3 . The computer-implemented method of claim 1 , wherein determining the gradient mask comprises:
generating gradients from the luminance map by applying a Laplacian filter to the luminance map; and
determining the gradient mask by selecting a subset of the gradients that meet a threshold gradient value.
4 . The computer-implemented method of claim 1 , wherein determining the highlight mask further comprises applying a tone curve filter to the subset of pixels with luminance values above the threshold luminance.
5 . The computer-implemented method of claim 1 , wherein generating the gradient-highlight mask comprises multiplying the gradient mask and the highlight mask to create the gradient-highlight mask.
6 . The computer-implemented method of claim 1 , wherein generating the highlight guide image comprises:
generating an inverse of the gradient-highlight mask; and
generating the highlight guide image by combining the gradient-highlight mask, the inverse of the gradient-highlight mask, and the highlight mask.
7 . The computer-implemented method of claim 6 , wherein generating the highlight guide image comprises combining the gradient-highlight mask, the inverse of the gradient-highlight mask, and the highlight mask via a weighted sum of the gradient-highlight mask, the inverse of the gradient-highlight mask, and the highlight mask.
8 . The computer-implemented method of claim 1 , further comprising:
determining, in response to a request to apply a lens blur effect to the digital image, a luminance boost value for a pixel of the one or more light sources based on a highlight value of the pixel in the highlight guide image and a luminance value of the pixel in the digital image; and
rendering the digital image to include the lens blur effect according to the luminance boost value of the pixel.
9 . The computer-implemented method of claim 8 , wherein determining the luminance boost value for the pixel comprises determining the luminance boost value further based on a local blur radius associated with the lens blur effect.
10 . A system comprising:
a memory component; and
one or more processing devices coupled to the memory component, the one or more processing devices to perform operations comprising:
generating, in response to a request to apply a lens blur effect to a digital image, a highlight guide image comprising visual indications of one or more light sources in the digital image based on a gradient-highlight mask and a highlight mask, the gradient-highlight mask comprising pixel values included in a gradient mask and the highlight mask;
determining a luminance boost value for a pixel corresponding to the one or more light sources based on a luminance value of the pixel in the digital image, a highlight value of the pixel in the highlight guide image, and a blur value; and
rendering the digital image to include the lens blur effect by generating a modified luminance value of the pixel according to the luminance boost value.
11 . The system of claim 10 , wherein generating the highlight guide image comprises generating the highlight guide image utilizing a machine-learning model comprising parameters learned on highlight guide images and corresponding digital images from a digital image repository.
12 . The system of claim 10 , wherein generating the highlight guide image comprises:
determining the gradient mask indicating edges in a luminance map of the digital image;
determining the highlight mask comprising a subset of pixels with luminance values above a threshold luminance;
generating the gradient-highlight mask by selecting pixel values that are included in the gradient mask and the highlight mask; and
generating the highlight guide image based on the gradient-highlight mask and the highlight mask.
13 . The system of claim 10 , wherein the operations further comprise:
generating a mapping between the highlight guide image and the digital image; and
generating the highlight guide image as a separate file associated with the digital image according to the mapping.
14 . The system of claim 13 , wherein the operations further comprise:
opening the digital image within a digital image application; and
accessing, in response to opening the digital image, the highlight guide image mapped to the digital image in connection with editing the digital image in the digital image application.
15 . The system of claim 13 , wherein the operations further comprise:
generating an additional version of the digital image by modifying a resolution of the digital image; and
rendering the additional version of the digital image including an additional lens blur effect according to the highlight guide image associated with the digital image.
16 . The system of claim 10 , wherein determining the luminance boost value comprises:
determining a boost amount in response to an input via a boost setting within a graphical user interface displaying the digital image;
selecting highlight values from the highlight guide image by modifying a luminance threshold based on the boost amount, the highlight values comprising a highlight value of the pixel; and
determining a scaling amount for the highlight value of the pixel based on the boost amount.
17 . A non-transitory computer readable medium storing executable instructions which, when executed by a processing device, cause the processing device to perform operations comprising:
generating a gradient-highlight mask by:
determining a gradient mask by detecting edges indicating boundaries in a luminance map of a digital image by applying a gradient filter to the luminance map;
determining a highlight mask by determining a subset of pixels of the digital image with luminance values above a luminance threshold; and
selecting pixel values that are included in the gradient mask and the highlight mask;
generating a highlight guide image comprising indications of one or more light sources in the digital image by combining the gradient-highlight mask, an inverse of the gradient-highlight mask, and the edges of the luminance map; and
rendering the digital image to include a lens blur effect by utilizing the highlight guide image to modify luminance values of one or more pixels of the digital image.
18 . The non-transitory computer readable medium of claim 17 , wherein detecting the edges indicating boundaries in the luminance map of the digital image comprises:
applying a gradient detection filter to the luminance map; and
selecting a subset of gradients that meet a threshold gradient value.
19 . The non-transitory computer readable medium of claim 17 , wherein rendering the digital image comprises:
determining luminance boost values for the one or more pixels of the digital image based on a boost amount in response to an input via a boost setting in a request to apply the lens blur effect to the digital image; and
modifying the luminance values of the one or more pixels of the digital image according to the luminance boost values.
20 . The non-transitory computer readable medium of claim 17 , wherein rendering the digital image comprises:
generating the highlight guide image as metadata of the digital image; and
rendering a plurality of versions of the digital image with a plurality of different lens blur effects by accessing the highlight guide image for each of the plurality of different lens blur effects.