Systems and methods for shadow detection in images

The method addresses the issue of shadow detection in image editing by segmenting and clustering cells based on illumination values, enabling seamless object manipulation and removal in image editing software.

WO2026025466A9PCT designated stage Publication Date: 2026-03-05HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/109356
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2024-08-02
Publication Date
2026-03-05

AI Technical Summary

Technical Problem

Current image editing software struggles to effectively remove shadows of selected objects, often leaving noticeable artefacts in the image when the object is altered or removed.

Method used

A method for modifying an object mask to include its shadow by segmenting the image into cells, identifying seed cells adjacent to the bottommost cells, clustering these cells into darker and lighter clusters based on illumination values, and recursively growing the shadow region until convergence or a maximum size is reached.

Benefits of technology

Effectively detects and incorporates the shadow into the object mask, ensuring seamless removal or manipulation of the object without leaving noticeable defects in the image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024109356_05032026_PF_FP_ABST
    Figure CN2024109356_05032026_PF_FP_ABST
Patent Text Reader

Abstract

Devices and methods for modifying an object mask to include a shadow of the object. An image is segmented into cells, each cell having an estimated illumination value. The bottommost cells of an identified object are determined and the surrounding non-object cells that are adjacent to the bottommost cells are identified as seed cells. The seed cells undergo binary clustering based on their illumination values. The darker cluster of seed cells are identified as shadow cells. Cells adjacent to the shadow cells are recursively evaluated based on their illumination values to determined if they are further shadow cells. The shadow region growing continues until it converges or until it exceeds a maximum size. If it converges, then the resulting shadow cells are added to an object mask to generate an object mask that includes the object's shadow.
Need to check novelty before this filing date? Find Prior Art

Description

SYSTEMS AND METHODS FOR SHADOW DETECTION IN IMAGESFIELD

[0001] The present application relates to image or video editing or analysis and, in particular, to one or more techniques for detecting a shadow of an object in an image.BACKGROUND

[0002] Computer-aided photo editing is widely available and used on all types of computing devices. The proliferation of camera-equipped mobile devices and tablets in particular has resulted in billions of digital photos or videos which, coupled with image-intensive social media platforms, has created demand for robust and user-friendly image editing software.

[0003] One of the features often employed in image editing is object selection, e.g. segmentation. In the past, this required advanced skills and great care to manually identify the boundary of an object in the image. In most image editing software, object selection is now partly or fully automated. Artificial intelligence (AI) has enabled algorithms and software offerings that are able to identify and select an object, often based on a semantic (e.g. text) instruction. These solutions can then manipulate or edit the image based on the selected object. For example, the software may enable selection of a specified object and removal of that object from the image, with the software “filling in” the space previously occupied by the object using an automated image generation technique to generate pixels values in that area.

[0004] Despite these advances, current software struggles to deal with the shadow of an object. When a selected object is removed, the shadow or some portion of the shadow is often left in the image, resulting in an obvious, and sometimes jarring, artefact marring the image.

[0005] BRIEF SUMMARY

[0006] In accordance with one aspect, the present application describes a method of modifying a mask for an object in an image to include its shadow. The method may include obtaining the mask defining a location of the object within the image; segmenting the image into cells, each cell having an illumination value, the cells within the mask being object cells and the cells outside the mask being outer cells; identifying a subset of the outer cells as seed cells based on them being adjacent to one or more bottommost cells of the object cells, wherein the one or more bottommost cells are located closer to a bottom edge of the image than other object cells; clustering the seed cells based on their respective illumination values into a darker cluster and a lighter cluster; designating the seed cells in the darker cluster as shadow cells; and revising the mask of the object to include the shadow cells.

[0007] In some implementations, the method may further include recursively growing a shadow region starting from the shadow cells by determining whether adjacent cells to the shadow cells are to be added to the shadow cells based on their respective illumination values. The recursively growing may include identifying candidate cells from the outer cells adjacent the shadow cells; categorizing each of the candidate cells, based on their respective illumination values, into the darker cluster or the lighter cluster; designating the candidate cells in the darker cluster as further shadow cells; and repeating the identifying, the categorizing, and the designating until no further shadow cells are found.

[0008] In some cases, revising includes revising the mask of the object to include the further shadow cells.

[0009] In some implementations, the recursively growing ma include determining that a size of the shadow region is lower than a maximum size. The maximum size may be a predetermined percentage of the size of the object in the image.

[0010] In some implementations, segmenting includes applying a segmentation algorithm to the image. The segmentation algorithm may include one of an over-segmentation algorithm, a superpixel segmentation algorithm, a watershed algorithm, or a simple linear iterative clustering (SLIC) algorithm.

[0011] In some implementations, the method further includes applying panoptic segmentation to the image, wherein identifying seed cells from the outer cells further includes removing cells labeled with a predetermined semantic label from the seed cells. In some cases, the predetermined semantic label may include “sky” , “tree” , or “human” .

[0012] In some implementations, identifying the seed cells includes identifying the one or more bottommost cells based on identifying a number of the object cells located closest to the bottom edge of the image, and wherein the number is based on a predetermined percentage of the number of object cells.

[0013] In some implementations, clustering includes applying a clustering algorithm to the seed cells based on their respective illumination values, determining that the clustering is sufficiently selective, and obtaining a classification criteria for membership in the darker cluster. In some cases, the classification criteria include a threshold illumination value below which seeds cells are classified as shadow cells.

[0014] In another aspect, the present application describes an electronic device including a process and memory coupled to the processor. The memory may store computer-executable instructions for modifying a mask for an object in an image to include its shadow, wherein the instructions, when executed by the processor, are to configure the processor to obtain a mask defining a location of the object within the image; segment the image into cells, each cell having an illumination value, the cells within the mask being object cells and the cells outside the mask being outer cells; identify a subset of the outer cells as seed cells, the seed cells being adjacent to one or more bottommost cells of the object cells, wherein the one or more bottommost cells are located closer to a bottom edge of the image than other object cells; cluster the seed cells based on their respective illumination values into a darker cluster and a lighter cluster; designate the seed cells in the darker cluster as shadow cells; and revise the mask of the object to include the shadow cells.

[0015] In some implementations, the instructions, when executed, are to further cause the processor to recursively grow a shadow region starting from the shadow cells by determining whether adjacent cells to the shadow cells are to be added to the shadow cells based on their respective illumination values. In some cases, the processor is to recursively grow the shadow region by identifying candidate cells from the outer cells adjacent the shadow cells; categorizing each of the candidate cells, based on their respective illumination values, into the darker cluster or the lighter cluster; designating the candidate cells in the darker cluster as further shadow cells; repeating the identifying, the categorizing, and the designating until no further shadow cells are found; and revising the mask of the object to include the further shadow cells.

[0016] In some implementations, the instructions, when executed are to cause the processor to recursively grow the shadow region by determining that a size of the shadow region is lower than a maximum size.

[0017] In some implementations, the instructions, when executed by the processor, are to further configure the processor to apply panoptic segmentation to the image, wherein identifying seed cells from the outer cells further comprises removing cells labeled with a predetermined semantic label from the seed cells.

[0018] In some implementations, the instructions, when executed by the processor, are to configure the processor to identify the seed cells by identifying the one or more bottommost cells based on identifying a number of the object cells located closest to the bottom edge of the image, and wherein the number is based on a predetermined percentage of the number of object cells.

[0019] In yet another aspect, the present application describes a non-transitory computer-readable medium containing instructions for modifying a mask for an object in an image to include its shadow. The instructions, when executed by a processor, are to cause the processor to obtain a mask defining a location of the object within the image; segment the image into cells, each cell having an illumination value, the cells within the mask being object cells and the cells outside the mask being outer cells; identify a subset of the outer cells as seed cells, the seed cells being adjacent to one or more bottommost cells of the object cells, wherein the one or more bottommost cells are located closer to a bottom edge of the image than other object cells; cluster the seed cells based on their respective illumination values into a darker cluster and a lighter cluster; designate the seed cells in the darker cluster as shadow cells; and revise the mask of the object to include the shadow cells.

[0020] In yet a further aspect, the present application describes a computer-readable medium storing computer-executable instructions that, when executed by one or more processors, are to cause the one or more processors to carry out any one of the methods described.

[0021] In another aspect, the present application describes a computer program comprising instructions which, when executed by a computing device, are to cause the computing device to carry out any one of methods described herein.

[0022] In a further aspect, the present application describes a computing device having means to perform any one of the methods described herein.

[0023] In yet a further aspect, the present application describes a computing device having at least one processor and a memory coupled to the at least one processor, wherein the memory stores instructions that, when executed by the at least one processor, are to cause the apparatus to perform any one of the communication methods described herein.

[0024] Other aspects and features of the present application will be understood by those of ordinary skill in the art from a review of the following description of examples in conjunction with the accompanying figures.BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Reference will now be made, by way of example, to the accompanying drawings in which:

[0026] FIG. 1 illustrates an example image editing pipeline that includes shadow detection;

[0027] FIG. 2 shows a simplified example image that includes an object and its shadow;

[0028] FIG. 3 shows the example image segmented into cells;

[0029] FIG. 4 shows a close-up view of the bottom portion of the object and its shadow;

[0030] FIG. 5 shows, in flowchart form, one example method of modifying an object mask to include the object’s shadow;

[0031] FIG. 6 shows a high-level diagram of an example computing device; and

[0032] FIG. 7 shows a simplified example of software components within the computing device.

[0033] Like reference numerals are used in the drawings to denote like elements and features.DETAILED DESCRIPTION

[0034] In the present disclosure, the terms “a” , “an” and “one” are defined to mean “at least one” , that is, these terms do not exclude a plural number of items, unless stated otherwise.

[0035] In the present disclosure, terms such as “substantially” , “generally” and “about” , which modify a value, condition or characteristic of a feature of an embodiment, should be understood to mean that the value, condition or characteristic is defined within tolerances that are acceptable for the proper operation of this embodiment for its intended application.

[0036] In the present disclosure, unless stated otherwise, the terms “connected” and “coupled” , and derivatives and variants thereof, refer herein to any structural or functional connection or coupling, either direct or indirect, between two or more elements. For example, the connection or coupling between the elements can be acoustical, mechanical, optical, electrical, thermal, logical, or any combinations thereof.

[0037] In the present disclosure, expressions such as “match” , “matching” and “matched” , including variants and derivatives thereof, are intended to refer herein to a condition in which two or more elements are either the same or within some predetermined tolerance of each other. That is, these terms are meant to encompass not only “exactly” or “identically” matching the two elements but also “substantially” , “approximately” or “subjectively” matching the two or more elements, as well as providing a higher or best match among a plurality of matching possibilities.

[0038] In the present disclosure, the expression “based on” is intended to mean “based at least partly on” , that is, this expression can mean “based solely on” or “based partially on” , and so should not be interpreted in a limited manner. More  particularly, the expression “based on” could also be understood as meaning “depending on” , “representative of” , “indicative of”, “associated with” or similar expressions.

[0039] In the present disclosure, the terms "system" and "network" may be used interchangeably in embodiments of this application. "At least one" means one or more, and "a plurality of" means two or more. The term "and / or" describes an association relationship of associated objects and indicates that three relationships may exist. For example, A and / or B may indicate the following three cases: Only A exists, both A and B exist, and only B exists, where A and B may be singular or plural. The character " / " usually indicates an "or" relationship between associated objects. "At least one of the following items (pieces) " or a similar expression thereof indicates any combination of these items, including a single item (piece) or any combination of a plurality of items (pieces) . For example, "at least one of A, B, or C" includes A, B, C, A and B, A and C, B and C, or A, B, and C, and "at least one of A, B, and C" may also be understood as including A, B, C, A and B, A and C, B and C, or A, B, and C. In addition, unless otherwise specified, ordinal numbers such as "first" and "second" in embodiments of this application are used to distinguish between a plurality of objects, and are not used to limit a sequence, a time sequence, priorities, or importance of the plurality of objects.

[0040] In the present application, the phrase “at least one of…or…” is intended to cover any one or more of the listed elements, including any one of the listed elements alone, any sub-combination, or all of the elements, without necessarily excluding any additional elements, and without necessarily requiring all of the elements. The term “and / or” is intended to indicate that either of the two elements may be included or both of the elements may be included.

[0041] A person skilled in the art will understand that embodiments of this application may be provided as a method, an apparatus (or system) , a computer-readable storage medium, or a computer program product. Therefore, this application may use a form of a hardware-only embodiment, a software-only embodiment, or an embodiment with a combination of software and hardware. Moreover, this application may use a form of a computer program product that is implemented on one or more computer-usable storage media (including but not limited to a disk memory, an optical memory, and the like) that include computer-usable program code.

[0042] This application is described with reference to the flowcharts and / or block diagrams of the method, the device (system) , and the computer program product according to this application. It should be understood that computer program instructions may be used to implement each process and / or each block in the flowcharts and / or the block diagrams and a combination of a process and / or a block in the flowcharts and / or the block diagrams. The computer program instructions may be provided for a general-purpose computer, a dedicated computer, an embedded processor, or a processor of another programmable data processing device to generate a machine, so that the instructions executed by the computer or the processor of the another programmable data processing device generate an apparatus for implementing a specific function in one or more procedures in the flowcharts and / or in one or more blocks in the block diagrams.

[0043] The computer program instructions may alternatively be stored in a computer-readable memory that can indicate a computer or another programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate an artifact that includes an instruction apparatus. The instruction apparatus implements a specific function in one or more procedures in the flowcharts and / or in one or more blocks in the block diagrams.

[0044] The computer program instructions may alternatively be loaded onto a computer or another programmable data processing device, so that a series of operations and steps are performed on the computer or the another programmable device, so that computer-implemented processing is generated. Therefore, the instructions executed on the computer or the another programmable device provide steps for implementing a specific function in one or more procedures in the flowcharts and / or in one or more blocks in the block diagrams.

[0045] It will be understood that a person skilled in the art may make various modifications and variations to this application without departing from the scope of this application. This application is intended to cover these modifications and variations of this application provided that they fall within the scope of protection defined by the following claims and their equivalent technologies.

[0046] Throughout the present disclosure, a processor, a processor system, an application processor, a baseband processor, a processor circuit, or a processor core may be collectively referred to as a processor. A processor may include one or more of a central processing unit (CPU) , a digital signal processor (DSP) , a microprocessor unit (MPU) , a microcontroller unit, (MCU) , a graphics processing unit (GPU) , a field programmable gate array (FPGA) , an artificial intelligence (AI) processor, or a neural network processing unit (NPU) , or a combination of at least two of these integrated circuit forms.

[0047] Throughout the present disclosure, a memory may include one or more of the following storage media: a RAM, a static random access memory (SRAM) , a dynamic random access memory (DRAM) , a phase-change memory (PCM) , a resistive random access memory (ReRAM) , a magnetoresistive random access memory (MRAM) , a ferroelectric random access memory (FRAM) , a cache, a register, a read-only memory (ROM) , a flash memory, an erasable programmable read-only memory (EPROM) , a hard disk, and / or the like. In an example, the computer program instructions used to execute embodiments contained herein may be stored in a non-volatile memory. When a terminal runs, part or all of corresponding computer program instructions may be loaded into a memory that has a higher transmission speed with a corresponding processor, for example, the instructions may be loaded into at least a part of a memory such that the processor executes the computer program instructions to perform the steps in of embodiments described herein.

[0048] References herein to an “image” may be understood as applying to a single static image or to a series of images that make up an animation or a video, i.e. frames.

[0049] Modern image editing software enables selection of a particular object. Object selection can be automated to some degree and may employ various techniques or algorithms to identify and select the object. In some cases, these algorithms may employe artificial intelligence or may utilize models trained using machine learning to identify particular types or classes of objects. The output of an object selection or object segmentation application or algorithm may be a mask. A mask is a data structure that defines the boundaries of the object in the image. In some cases, the mask may be an equivalently-sized image (or matrix of values) having binary values instead of luminance / chrominance values or RGB values, wherein the binary values indicate whether the pixel is part of the object or not part of the object.

[0050] As noted above, current software struggles to deal with a shadow of an object. When a selected object is altered, moved, or removed, the shadow or some portion of the shadow is often left in the image, resulting in noticeably unrealistic defect.

[0051] The present application describes, in one aspect, methods and devices for detecting and selecting shadows of a selected object in an image. In some cases, the methods may include receiving a mask defining the boundaries of a selected object and partitioning the image into cells. There are a number of possible techniques for partitioning an image into cells, e.g. over-segmentation or superpixel segmentation, by way of examples. In general, the cells may be formed based on the pixels within the cell being relatively similar in colour and / or luminance. That is the partitioning may be based on grouping like pixels together in a region in the same cell, such that cell boundaries map to changes in luminance and / or colour. The cells may be formed based on them having a minimum and maximum size in some cases. The cells may be non-uniform in size and shape in some cases. Each cell can be assigned an illumination value, which reflects some combination of the features of the pixels in the cell, such as an average or median luminance value for example.

[0052] The method may then identify the cells within a mask determined by an objection selection module. In particular, the method identifies the cells within the mask that are closest to the bottom of the mask, e.g. closest to the bottom edge of the image, as the bottommost cells. The method the identifies cells outside the mask that are adjacent to (e.g. share a boundary  with) at least one of the bottommost cells. This results in selecting all the cells that surround the bottom end of the selected object in the image. These are then designated as “seed cells” .

[0053] Having identified the seed cells, the method then analyzes the illumination values of the seed cells. If a shadow is present, then the illumination values should fall into two clusters: those cells that are part of the shadow with low illumination values and those cells that are not in shadow and have higher illumination values. In some cases, that clustering into two sets may be the basis for defining a threshold between “shadow” and “not shadow” in terms of an illumination value threshold. Those seed cells that fall into the cluster of low illumination values are designated as “shadow cells” , meaning they are likely part of the shadow of the object.

[0054] The method then “grows” the shadow by looking at cells adjacent to the current shadow cells and assessing whether those cells have illumination values that are sufficiently close to the shadow cluster to be classed as a further shadow cell. The growing of the region continues until no adjacent cells to the current shadow cells are classified as further shadow cells, or until the region grows beyond a maximum size that indicates the shadow is too unlikely to be a legitimate shadow.

[0055] Once the shadow growing ceases, the mask that defines the object location in the image may then be modified to include the shadow cells identified.

[0056] Reference will now be made to FIG. 1, which shows, in block diagram form, an example image editing pipeline 100. The image editing pipeline 100 may be implemented in software, by way of one or more applications for example. In this example, the pipeline 100 may be implemented within an image editing application embodied by computer-executable instructions stored in memory on a computing device having a processor that, when executing the computer-executable instructions, carries out the operations coded in the instructions.

[0057] The image editing pipeline 100 in this example includes applying an object selection module 104 to an input image 102 to determine a mask 106. As noted above, the object selection module 104 may employ any of a number of possible techniques to identify and select objects within an image. The object selection module 104 may receive user input in terms of selection of one or more points or pixels in the image, or terms of sematic input such as a text description of the object. Any one of a number of possible object selection techniques may be used. The resultant mask 106 defines the location of the objection in the image. The mask 106 may specify the location of the pixels that are included in the selected object. The mask 106 may include a matrix of binary values mapped to pixel locations, where the binary values indicate whether the corresponding pixel is or is not part of the selected object. Other data structures may be used in other implementations.

[0058] The mask 106 and the image 102 may then be input to a shadow detection module 108. As described above, the shadow detection module 108 performs the operations of segmenting the image into cells or superpixels, identifying bottommost cells of the object, clustering seed cells around the bottommost cells as shadow or non-shadow, and then growing the shadow until a finalized shadow is determined. It then modifies the mask 106 so as to include the shadow as part of the identified object, resulting in a modified mask.

[0059] The pipeline 100 may include an editing module 110 which may permit a user to apply manipulations to the image 102 based, at least in part, on the modified mask. For example, the editing module 110 may enable movement of the object and its shadow within the image, removal of the object and its shadow from the image, resizing of the object and its shadow, or other such manipulations. It outputs an edited image 112. In some cases, the pipeline may include a recursion feedback path 114.

[0060] The shadow detection process will now be described with reference to an example. FIG. 2 shows an example of an image 200.

[0061] The image 200 is made of pixels, each pixel having pixel data defining its illumination intensity (e.g. a luminance (or luma) value) . The pixel data may include colour data (e.g. chrominance (or chroma) values) in some cases. The pixel data may be in any suitable image format or representation, e.g. RGB values, YUV values, etc.

[0062] An object selection operation results in selection of an object 202 in the image 200. The object 202 in this example, is the cactus shown. The object selection may be automated, e.g. based on a semantic input, or semi-automated, e.g. based on user input of a selection point or bounding box that serves as the basis for carrying out object detection within the image. Irrespective of the mechanisms, the object selection operation results in identification of the object 202 and the defining of a mask corresponding to the objection 202. The mask is a data structure defining the location of the object 202 within the image.

[0063] It will be noted that the image 200 further includes a shadow 204 associated with the object 202.

[0064] A shadow detection process may be used to identify the shadow 204 within the image and to then modify the mask to add pixels corresponding to the shadow 204 so that the mask includes both the object 202 and its shadow 204. The process may be implemented in software executed by a computing device. The computing device may be the same computing device used for object detection and / or image editing.

[0065] Referring now to FIG. 3, it will be noted that the image 200 may be segmented or partitioned into cells 302 by the computing device. In some cases, the cells 302 may be referred to as superpixels. The segmentation may be based on growing small cells having substantially similar pixel data, e.g. similar RGB or luma and chroma values within some threshold range. The cell sizes may be restricted to a maximum size. The maximum size may be maximum count of pixels in some cases. The maximum size may be a maximum distance from a central pixel in some cases. The maximum size may be a maximum dimension, such as a diameter, radius, x-or y-distance between edges of the cell, or other such measures of size.

[0066] In some cases, the image 200 may be partitioned into cells using an over-segmentation algorithm, a superpixel segmentation algorithm, or other such algorithm, such as the simple linear iterative clustering (SLIC) algorithm described by Achanta, R., et al., “SLIC Superpixels Compared to State-of-the-art Superpixel Methods” , IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 34, no. 11, p. 2274-2282, May 2012. The cells may be denoted by a cell set S= {si} . In some implementations, the computing device may construct a graph G=<S, V> whose vertices are the cells in cell set S, and whose edges are formed by the adjacency matrix V of the cells.

[0067] The computing device may determine an illumination value bi for each cell si. The illumination value for a cell may be an average or median of one or more elements of the pixel data in the cell, in some cases. For example, the illumination value may be an average or median luma value for the pixels in the cell. Other illumination estimation methods may be used in determining the illumination value of each cell, such as homomorphic filtering, bright channel prior, or other such methods. In some cases, the illumination value may be a vector that includes values from two or more different illumination estimation mechanisms.

[0068] The present technique may be most applicable to natural scenes in which natural lighting creates shadows. It will be appreciated that in this example, the image 200 is presumed to be oriented correctly so as to show ground proximate the bottom edge of the image 200. Moreover, the light source is presumed to be elevated such that it casts shadows, if any, downwards onto the ground surface. Note that the term “ground” does not necessarily imply outdoor natural surface, but may include flooring, tables, or other such surfaces on which an object may be situated and onto which shadows may be cast. It will further be appreciated that in some cases, shadows may be cast onto both floors and walls.

[0069] Reference will now be made to FIG. 4 which shows a close-up portion 400 of the image 200 (FIG. 2) and, in particular, the cells near the bottom of the object. As noted above, the object identification process resulted in determination of a mask identifying the location of the object in the image. The computing device may determine, using the mask, which cells are object cells 402, and thus which cells are outer cells 404. The outer cells 404 include all cells that are outside of the mask, i.e. non-object cells.

[0070] The computing device may identify one or more “bottommost” cells from among the object cells 402. The bottommost cells may include one or more cells closets to the bottom edge of the image. In some cases, this may include determining a coordinate position of each cell and identifying the object cell having a position with the y-coordinate closest to the bottom edge. The position may be centroid position in some cases. The position may be a lowest y-coordinate of any pixel  within the cell in some cases. In some implementations, the device may select a single bottommost cell. In some cases, the device may select one or more bottommost cells. The one or more bottommost cells may be selected on the basis that they are within a particular range of the bottommost cell closest to the bottom edge of the image in some cases. For example, all object cells within a certain distance of the bottommost cell of the object may be included within the one or more bottommost cells. In some cases, the device may have a preconfigured proportion of the cells within the mask that are to be identified as bottommost cells. For example, the device may be configured to ensure that at least a fixed percentage of the object cells are included as bottommost cells.

[0071] In the simplified example shown in FIG. 4, cell 402a may be identified the bottommost cell as it is the object cell closest to the bottom edge of the image. In some cases, adjacent cell 402b may be included within the “bottommost cells” identified on the basis that it is within a threshold distance of the position of the cell 402a. In some other implementations, only the cell 402a may be identified as the one or more bottommost cells.

[0072] The computing device then identifies the outer cells 404 that are adjacent to the one or more bottommost cells as “seed” cells. In the example in which only cell 402a is included as the bottommost cell, the seed cells identified as at least partly adjacent to cell 402a include cells 404a, 404b, 404c, 404d, and 404f. Cells may be identified as at least partly adjacent if they share at least one border pixel in some cases.

[0073] Once the computing device has identified the seed cells, which in this example include cells 404a, 404b, 404c, 404d, and 404f, it then clusters their illumination values bi. It will be recalled that the illumination value of each cell may, in general, represent a measure of the brightness or luminosity of the pixels within that cell. Some measures of illumination value may be more complex in accounting for colour, reflectance, or other such features. In some cases, the illumination value may be a vector. The computing device compares the illumination values of the seed cells and determines whether they fall into two binary clusters. In the case where there is a clear shadow and the seed cells do not contain vastly different surfaces, the illumination values should cluster into two distributions: a cluster of higher illumination values and a cluster of lower illumination values. The cluster of cells with lower illumination values may be identified as “shadow cells” . Any one of a number of clustering algorithms may be used, such as, for example, a binary Gaussian mixture model (2-GMM) .

[0074] In this simplified example, seed cells 404a, 404b, 404c, and 404d may be expected to have illumination values within the higher illumination cluster, whereas seed cell 404f may be expected to have an illumination value within the lower cluster (which in this simplistic case contains a single illumination value) . Accordingly, only seed cell 404f is identified as a shadow cell.

[0075] In some cases, the clustering of illumination values may not result in clear distribution of shadow / not-shadow cells. That is, the distribution of values may not produce two clear clusters of lower illumination and high illumination. In such a case, the shadow detection process may end without identifying a shadow. A measure of confidence or selectivity may be evaluated to determine whether the clustering was successful or not.

[0076] Based on the clustering, a threshold may be identified for membership as a shadow cell. That is, the clustered distribution may enable selection of a threshold illumination value. A candidate cell that has an illumination value below the threshold illumination value may be identified as a further shadow cell. In some cases, the distribution may be used to identify a range of illumination values for classification of candidate cells as shadow cells, such that there is both an upper and lower bound. Some clustering algorithms will output a classification criteria, i.e. a threshold value, or vector of values, for classification of future elements into either the first or second cluster.

[0077] Using the threshold illumination value or classification criteria, the computing device may then grow the shadow region starting from the one or more seed cells identified as shadow cells. Outer cells that are adjacent to the one or more shadow cells are evaluated, in turn, to determine whether their respective illumination values indicate that they are to be classified as shadow cells or not. That is, their illumination values are compared to the threshold illumination value or range or the classification criteria. If their illumination value lower than the threshold illumination value (or within the range) , then the outer cell under evaluation is classified as a shadow cell and added to the shadow region. The computing device continues  evaluating the outer cells adjacent to the shadow region until no further adjacent cells are classified as shadow cells, i.e. until convergence. In some cases, the computing device may terminate the shadow region growing if it determines that the shadow region growing has failed due to growth of the shadow beyond a reasonable maximum size. The maximum size may be set as a percentage of the size of the object in some implementations.

[0078] If the shadow growing region converges, then the device outputs the union of the mask and the shadow as an updated mask for use in image editing operations.

[0079] Reference is now made to FIG. 5, which shows, in flowchart form, one example method 500 of detecting a shadow of an object in an image. The method 500 may be implemented in software executed by one or more processing units of a computing device. In some cases, the software may be embodied within an image editing application that includes manual or automated or semiautomated object selection within images. The method 500 may be applied to an input image.

[0080] In operation 502, a mask is determined for an object in the image. As noted above, the mask may be determined by an object selection module within the image editing application in some cases. Any one of a number of object selection algorithms may be used. The object selection may be partly manual, such as through user input of a selected location on the image or bounding box or “lasso” to define the area containing the object-of-interest. In some cases, the selection may be at least partly automated and tuned to recognize categories of objects, such as humans, animals, vehicles, etc. The object selection may be based on input of a semantic object identifier, such as a text instruction like “select people” . In some cases, the object selection module may identify a plurality of objects in the image, which may be indicated by visually displaying a coloured outline around the identified objects in the displayed image for instance, and the user may have the option of inputting a selection of one of the identified objects. Irrespective of the mechanism, a mask is produced that defines the location of the identified object within the image. In some implementations, the mask may be a binary mask, e.g. a matrix of binary values indicating for each pixel location in the image whether that pixel is or is not part of the object.

[0081] In operation 504, the computing device segments the image into cells. The segmentation into cells may include use of an algorithm for segmenting image data into cells based on common pixel characteristics. Examples include an over-segmentation algorithm, a superpixel segmentation algorithm, the SLIC algorithm, a watershed algorithm, or other such algorithms. The cells may be of different sizes and shapes and in some cases may be restricted to be no more than a maximum size.

[0082] The segmentation may produce a cell set S= {si} . In some implementations, the computing device may construct a graph G=<S, V> whose vertices are the cells in cell set S, and whose edges are formed by the adjacency matrix V of the cells.

[0083] In operation 504, the computing device also determines an illumination value bi for each cell si. In some cases, illumination estimation methods may be used in determining the illumination value of each cell, such as homomorphic filtering, bright channel prior, or another such illumination estimation algorithm. In some cases, the illumination value may be a vector that includes values from two or more different illumination estimation mechanisms.

[0084] The cells resulting from the segmentation include a set of cells within the identified object covered by the mask M. Those cells that correspond to, or cover, the mask M may be termed object cells SM.

[0085] As mentioned above, the present process operates from an assumption that the light source casting a shadow originates from somewhere above the top of the image, such that the shadow is cast onto a surface on which the object is situated. In many natural scenes, such as outdoor photography, this assumption typically holds. There may be some edge cases in which the method 500 cannot be successfully applied, such as where lighting originates from below an object that casts shadows against walls or ceiling or other surfaces. Likewise, there may be image that are not oriented upright such that the assumption is undermined. However, in most cases the assumption will be valid. In cases in which the assumption is invalid, the method 500 may not detect a shadow.

[0086] In operation 506, the computing device may identify the bottommost object cells SS. The focus on the bottommost object cells is based on the above-noted assumption regarding the light direction and surfaces, and the consequent assumption that the shadow will be connected to the bottommost portion of the object.

[0087] The bottommost object cells SS may be the one or more object cells positioned closest to the bottom edge of the image. In some cases, the bottommost object cells SS may be selected as a particular subset (e.g. a percentage) of the object cells that are closest to the bottom edge of the image. The position of the cells may be determined based on the lowest positional y-value of any pixel within the cell in some examples. The position of the cells may be determined based on the positional x-y values of a centroid of the cell in some examples. For the purposes of this example, the computing device may have a preset percentage ps of object cells that are to be included within the set of bottommost cells such that bottommost cells SS=ps%of cells in SM closest to the bottom edge of the image.

[0088] The computing device further identifies the non-object cells adjacent to the bottommost cells as “seed” cells S↓. In some implementations, the device may use the graph G=<S, V> to identify those cells that are adjacent to the bottommost cells SS and are not member of the set of object cells SM. This may be expressed as S↓=neighbour (SS) \SM. The set of seed cells S↓ is the initial set of candidate cells that may or may not be part of the object’s shadow.

[0089] Having identified the set of seed cells S↓, the device then performs binary clustering of the seed cells based on their illumination values in operation 508. If a shadow is present, then the clustering should result in two clusters of illumination values: a set of darker cells and a set of lighter cells, where the darker cells are presumed result from a shadow being cast on the surface. Clustering may be carried out using any suitable clustering algorithm, such as fitting a binary Gaussian mixture model, for example. If the clustering operation does not result in two sufficiently distinct clusters, then the method 500 may fail and no shadow is identified. In some cases, the clustering may result in three or more clusters, which may be indicative of a surface having a sufficiently complex pattern or reflectiveness that a shadow cannot be determined with sufficient accuracy and the method 500 may terminate without identifying a shadow.

[0090] Assuming that the clustering is effective, then the device may determined from the clustering a classification criteria f that may be used to identify membership in the darker cluster. In some cases, this may be a threshold illumination value below which a cell is classified as being in the darker cluster, i.e. as being a shadow cell. As indicated by operation 510, those seed cells S↓ that meet the classification criteria f, i.e. those that were determined to be part of the darker cluster in the clustering operation, are designated as shadow cells, f (S↓) .

[0091] The device then engages in region growing for the shadow. In operation 512, the device identifies an outer cell that is adjacent to one or more of the shadow cells and determines whether that outer cell’s illumination value meets the classification criteria f. The device may use the graph G to identify adjacent cells to the shadow cells. If the cell’s illumination value meets the classification criteria f, e.g. if it is below the threshold value set by the classification criteria f, then the cell is added to the set of shadow cells S*. If not, then it is not added to the set of shadow cells S*. The device then determines whether there are further outer cells adjacent to any of the current set of shadow cells S*, as indicated by operation 516. If all of the adjacent cells have been evaluated and they are not classified as shadow cells, then the method 500 has converged on a shadow and the set of shadow cells S* is then added to the mask M and the modified mask S*∪M is output in operation 518. The recursive growth may be implemented by depth first search (DFS) on the graph G in some examples. The method 500 may use DFS or any other suitable region growing method.

[0092] As the device recursively grows the shadow through evaluating adjacent cells, it may determine in operation 520 whether the set of shadow cells violates a validity criteria. In some cases, the validity criteria may be a size criteria. The size criteria may be a cell count, a pixel count, a x-and / or y-dimension maximum, an area calculation or some other measure of size. The size criteria may be set as a percentage of the object size in some cases. For example, a shadow that is more than twice as large as the object may be the maximum set. This may be expressed as valid shadow is given by: area S*≤area α(M) , where α is the percentage, such as 150%, 200%, etc.

[0093] In one other example implementation, the method 500 may be modified to include a panoptic segmentation result as a factor in shadow region growth. There are certain textures or features on which it may be difficult to identify shadows, and on which the shadows may be less noticeable as an artefact when the object casting the shadow is removed from an image. In those cases, it may be advantageous to have the method 500 exclude such features from the shadow region growing operation.

[0094] In some cases, the device may perform panoptic segmentation on the image. The output of the panoptic segmentation operation may be identification of a plurality of features or objects in the image together with their classification or labelling. Particular categories or labels of objects may be pre-identified as “excluded” objects. For example, “sky” , “trees” , “bushes” , “human” , “animal” , etc., may be preidentified as items that should not be included within a shadow region.

[0095] In this situation, the panoptic segmentation operation may result in a cell set SE of excluded cells that correspond to the identified objects that have labels / classes that are excluded. That is, the computing device may map the cells to the segmented objects with excluded classes / labels to identify the set of excluded cells. During the shadow region growing operation, the excluded cells of the cell set SE may be excluded as candidate shadow cells, just as the object cells SM are excluded as candidate shadow cells.

[0096] Reference will now be made to FIG. 6, which shows a high-level diagram of an example computing device 600. The example computing device 600 includes a variety of modules. For example, the example computing device 600 may include a processor 610, a memory 620, an I / O module 640, and a communications module 650. As illustrated, the foregoing example modules of the example computing device 600 are in communication over a bus 660.

[0097] The processor 610 is a hardware processor. The processor 610 may, for example, be one or more ARM, Intel x86, PowerPC processors, or the like.

[0098] The memory 620 allows data to be stored and retrieved. The memory 620 may include, for example, random access memory, read-only memory, and persistent storage. Persistent storage may be, for example, flash memory, a solid-state drive or the like. Read-only memory and persistent storage are a computer-readable medium. A computer-readable medium may be organized using a file system such as may be administered by an operating system governing overall operation of the example computing device 600.

[0099] The I / O module 1240 allows the example computing device 600 to receive input signals and to transmit output signal. Input signals may, for example, correspond to input received from a user. Some output signals may, for example, allow provision of output to a user. The I / O module 640 may serve to interconnect the example computing device 600 with one or more input devices. Input devices may, for example, include one or more of a touchscreen input, keyboard, trackball or the like. The I / O module 640 may serve to interconnect the example computing device 600 with one or more output devices. Output devices may include, for example, one or more display screens such as, for example, a liquid crystal display (LCD) , a touchscreen display. Additionally, or alternatively, output devices may include devices other than screens such as, for example, a speaker, indicator lamps (such as, for example, light-emitting diodes (LEDs) ) , and printers.

[0100] The communications module 650 allows the example computing device 600 to communicate with other electronic devices and / or various communications networks. For example, the communications module 650 may allow the example computing device 600 to send or receive communications signals. As an example, the communication module 650 may include a network connection, data port, or the like. Communications signals may be sent or received according to one or more protocols or according to one or more standards. For example, the communications module 650 may allow the example computing device 600 to communicate via a cellular data network, such as for example, according to one or more standards such as, for example, Global System for Mobile Communications (GSM) , Code Division Multiple Access (CDMA) , Evolution Data Optimized (EVDO) , Long-term Evolution (LTE) , 5G, 6G, or the like. Additionally, or alternatively, the communications  module 650 may allow the example computing device 600 to communicate using near-field communication (NFC) , via Wi-Fi (TM) , via the Ethernet family of network protocols, using Bluetooth (TM) or via some combination of one or more networks or protocols. In some embodiments, all or a portion of the communications module 650 may be integrated into a component of the example computing device 600. In some examples, the communications module may be integrated into a communications chipset.

[0101] Software instructions are executed by the processor 610 from a computer-readable medium. For example, software may be loaded into random-access memory from persistent storage within memory 620. Additionally, or alternatively, instructions may be executed by the processor 610 directly from read-only memory of the memory 620.

[0102] FIG. 7 depicts a simplified organization of software components stored in memory 620 of the example computing device 600. As illustrated, these software components include, at least, application software 710 and an operating system 700.

[0103] The application software 710 adapts the example computing device 600, in combination with the operating system 700, to operate as a device performing a particular function. While a single application software 710 is illustrated in FIG. 7, in operation, the memory 620 may include more than one application software and different application software may perform different operations.

[0104] The operating system 700 is software. The operating system 700 allows the application software 710 to access the processor 610, the memory 620, the I / O module 640, and the communications module 650. The operating system 700 may, for example, be iOSTM, AndroidTM, LinuxTM, Microsoft WindowsTM, or the like.

[0105] The application software 710 and / or operating system 700 may, when executed, cause the processor 710 to carry out operations to implement at least some portion of one or more of the methods described herein.

[0106] The various embodiments presented above are merely examples and are in no way meant to limit the scope of this application. Variations of the innovations described herein will be apparent to persons of ordinary skill in the art, such variations being within the intended scope of the present application. In particular, features from one or more of the above-described example embodiments may be selected to create alternative example embodiments including a sub-combination of features which may not be explicitly described above. In addition, features from one or more of the above-described example embodiments may be selected and combined to create alternative example embodiments including a combination of features which may not be explicitly described above. Features suitable for such combinations and sub-combinations would be readily apparent to persons skilled in the art upon review of the present application as a whole. The subject matter described herein and in the recited claims intends to cover and embrace all suitable changes in technology.

Claims

1.A method of modifying a mask for an object in an image to include its shadow, the method comprising:obtaining the mask defining a location of the object within the image;segmenting the image into cells, each cell having an illumination value, the cells within the mask being object cells and the cells outside the mask being outer cells;identifying a subset of the outer cells as seed cells based on them being adjacent to one or more bottommost cells of the object cells, wherein the one or more bottommost cells are located closer to a bottom edge of the image than other object cells;clustering the seed cells based on their respective illumination values into a darker cluster and a lighter cluster;designating the seed cells in the darker cluster as shadow cells; andrevising the mask of the object to include the shadow cells.2.The method of claim 1, further comprising recursively growing a shadow region starting from the shadow cells by determining whether adjacent cells to the shadow cells are to be added to the shadow cells based on their respective illumination values.3.The method of claim 2, wherein the recursively growing includes:identifying candidate cells from the outer cells adjacent the shadow cells;categorizing each of the candidate cells, based on their respective illumination values, into the darker cluster or the lighter cluster;designating the candidate cells in the darker cluster as further shadow cells; andrepeating the identifying, the categorizing, and the designating until no further shadow cells are found.4.The method of claim 3, wherein revising includes revising the mask of the object to include the further shadow cells.5.The method of claim 2, wherein the recursively growing includes determining that a size of the shadow region is lower than a maximum size.6.The method of claim 5, wherein the maximum size is a predetermined percentage of the size of the object in the image.7.The method of claim 1, wherein segmenting includes applying a segmentation algorithm to the image.8.The method of claim 7, wherein the segmentation algorithm includes one of an over-segmentation algorithm, a superpixel segmentation algorithm, a watershed algorithm, or a simple linear iterative clustering (SLIC) algorithm.9.The method of claim 1, wherein segmenting includes determining the illumination value of each cell using an illumination estimation algorithm.10.The method of claim 1, further comprising applying panoptic segmentation to the image, wherein identifying seed cells from the outer cells further comprises removing cells labeled with a predetermined semantic label from the seed cells.11.The method of claim 10, wherein the predetermined semantic label comprises “sky” , “tree” , or “human” .12.The method of claim 1, wherein identifying the seed cells includes identifying the one or more bottommost cells based on identifying a number of the object cells located closest to the bottom edge of the image, and wherein the number is based on a predetermined percentage of the number of object cells.13.The method of claim 1, wherein clustering includes applying a clustering algorithm to the seed cells based on their respective illumination values, determining that the clustering is sufficiently selective, and obtaining a classification criteria for membership in the darker cluster.14.The method of claim 13, wherein the classification criteria include a threshold illumination value below which seeds cells are classified as shadow cells.15.An electronic device, comprising:a processor; anda memory coupled to the processor, the memory storing computer-executable instructions for modifying a mask for an object in an image to include its shadow, wherein the instructions, when executed by the processor, are to configure the processor to:obtain a mask defining a location of the object within the image;segment the image into cells, each cell having an illumination value, the cells within the mask being object cells and the cells outside the mask being outer cells;identify a subset of the outer cells as seed cells, the seed cells being adjacent to one or more bottommost cells of the object cells, wherein the one or more bottommost cells are located closer to a bottom edge of the image than other object cells;cluster the seed cells based on their respective illumination values into a darker cluster and a lighter cluster;designate the seed cells in the darker cluster as shadow cells; andrevise the mask of the object to include the shadow cells.16.The electronic device of claim 15, wherein the instructions, when executed, are to further cause the processor to recursively grow a shadow region starting from the shadow cells by determining whether adjacent cells to the shadow cells are to be added to the shadow cells based on their respective illumination values.17.The electronic device of claim 16, wherein instructions, when executed are to cause the processor to recursively grow the shadow region by:identifying candidate cells from the outer cells adjacent the shadow cells;categorizing each of the candidate cells, based on their respective illumination values, into the darker cluster or the lighter cluster;designating the candidate cells in the darker cluster as further shadow cells;repeating the identifying, the categorizing, and the designating until no further shadow cells are found; andrevising the mask of the object to include the further shadow cells.18.The electronic device of claim 16, wherein instructions, when executed are to cause the processor to recursively grow the shadow region by determining that a size of the shadow region is lower than a maximum size.19.The electronic device of claim 15, wherein the instructions, when executed by the processor, are to further configure the processor to:apply panoptic segmentation to the image, wherein identifying seed cells from the outer cells further comprises removing cells labeled with a predetermined semantic label from the seed cells.20.The electronic device of claim 15, wherein the instructions, when executed by the processor, are to configure the processor to identify the seed cells by identifying the one or more bottommost cells based on identifying a number of  the object cells located closest to the bottom edge of the image, and wherein the number is based on a predetermined percentage of the number of object cells.21.A computer-readable medium containing instructions for modifying a mask for an object in an image to include its shadow, wherein the instructions, when executed by a processor, are to cause the processor to:obtain a mask defining a location of the object within the image;segment the image into cells, each cell having an illumination value, the cells within the mask being object cells and the cells outside the mask being outer cells;identify a subset of the outer cells as seed cells, the seed cells being adjacent to one or more bottommost cells of the object cells, wherein the one or more bottommost cells are located closer to a bottom edge of the image than other object cells;cluster the seed cells based on their respective illumination values into a darker cluster and a lighter cluster;designate the seed cells in the darker cluster as shadow cells; andrevise the mask of the object to include the shadow cells.22.A computer-readable medium storing computer-executable instructions that, when executed by one or more processors, are to cause the one or more processors to carry out the method of any one of claims 1 to 14.23.A computer program comprising instructions which, when executed by a computing device, are to cause the computing device to carry out the method of any one of claims 1 to 14.24.A computing device comprising means to perform the method of any one of claims 1 to 14.25.A computing device comprising at least one processor and a memory coupled to the at least one processor, wherein the memory stores instructions that, when executed by the at least one processor, are to cause the at least one processor to perform the method of any one of claims 1 to 14.