Interactive image recoloring
Disclosed are systems, methods, and computer-readable storage media to perform an interactive image recolorization process. The method includes receiving user input including a stroke drawn on an image presented on a client device. The stroke comprises a user-specified color. The method further includes determining a region of interest in the image. The method further includes recolorizing the region of interest on the image based on the user-specified color and causing presentation of a result of the recolorization on the client device.
1 . A method comprising:
on a computing device, causing presentation of a user interface comprising an image;
detecting an input as a stroke drawn on the image;
determining a region of interest in the image based on the stroke;
performing a method to recolorize the region of interest by:
performing a comparison of luminance values of neighboring pixels; and
determining a recolorization color based on the comparison; and
filling the region of interest with the recolorization color to produce a recolorized image.
2 . The method of claim 1 , wherein the user interface further comprises multiple selectable colors and the method further comprises detecting a selected color from the multiple selectable colors.
3 . The method of claim 1 , further comprising causing presentation of the recolorized image on the computing device.
4 . The method of claim 1 , comprising expanding the stroke to generate a mask.
5 . The method of claim 4 , comprising refining the mask to determine a precise boundary of the region of interest.
6 . The method of claim 5 , wherein refining of the mask comprises:
computing a convex hull of the mask;
dilating the convex hull by a predetermined amount to generate an enlarged convex hull mask; and
segmenting the image based on the enlarged convex hull mask.
7 . The method of claim 5 , wherein refining of the mask further comprises simulating one or more additional strokes on the image.
8 . The method of claim 7 , wherein simulating of the one or more additional strokes on the image comprises:
performing bilateral filtering on the image to remove high-frequency edges;
performing edge detection on the image to generate an edge map; and
dilating the edge map such that edges of the edge map are thickened.
9 . The method of claim 1 , further comprising generating a mask by performing operations comprising:
identifying one or more contour points on the stroke; and
applying a flood fill algorithm to the image using the one or more contour points as seeds, resulting in the mask.
10 . The method of claim 2 , comprising generating a mask by performing operations comprising:
identifying one or more contour points on the stroke;
identifying contour pixels, each pixel of the contour pixels having a color within a threshold color difference to a neighboring pixel; and
replacing the color of connected pixels with the selected color resulting in the mask.
11 . A system comprising:
one or more processors; and
a non-transitory computer readable storage medium comprising instructions that when executed by the one or more processors cause the one or more processors to perform operations comprising:
on a computing device, causing presentation of a user interface comprising an image;
detecting an input as a stroke drawn on the image;
determining a region of interest in the image based on the stroke;
performing a method to recolorize the region of interest by:
performing a comparison of luminance values of neighboring pixels; and
determining a recolorization color based on the comparison; and
filling the region of interest with the recolorization color to produce a recolorized image.
12 . The system of claim 11 , wherein the user interface further comprises multiple selectable colors and the method further comprises detecting a selected color from the multiple selectable colors.
13 . The system of claim 11 , further comprising causing presentation of the recolorized image on the computing device.
14 . The system of claim 11 , comprising expanding the stroke to generate a mask.
15 . The system of claim 14 , wherein the operations caused by instructions executed by the one or more processors further include:
refining the mask to determine a precise boundary of the region of interest.
16 . The system of claim 15 , wherein refining of the mask comprises:
computing a convex hull of the mask;
dilating the convex hull by a predetermined amount to generate an enlarged convex hull mask; and
segmenting the image based on the enlarged convex hull mask.
17 . The system of claim 15 , wherein refining of the mask further comprises simulating one or more additional strokes on the image.
18 . The system of claim 17 , wherein simulating of the one or more additional strokes on the image comprises:
performing bilateral filtering on the image to remove high-frequency edges;
performing edge detection on the image to generate an edge map; and
dilating the edge map such that edges of the edge map are thickened.
19 . The system of claim 11 , wherein the operations further include generating a mask by performing operations comprising:
identifying one or more contour points on the stroke; and
applying a flood fill algorithm to the image using the one or more contour points as seeds resulting in the mask.
20 . A machine-readable non-transitory storage medium having instruction data executable by a machine to cause the machine to perform operations comprising:
on a computing device, causing presentation of a user interface comprising an image;
detecting an input as a stroke drawn on the image;
determining a region of interest in the image based on the stroke;
performing a method to recolorize the region of interest by:
performing a comparison of luminance values of neighboring pixels; and
determining a recolorization color based on the comparison; and
filling the region of interest with the recolorization color to produce a recolorized image.