1. An electronic device comprising: a display device; at least one processor; and a storage device storing a plurality of instructions, which when executed by the at least one processor, cause the at least one processor to: display an image on the display device when the electronic device is locked; obtain a pattern according to touch signals on the displayed image based on an image-recognition algorithm, wherein the pattern is obtained by: determining touch areas according to the touch signals on the displayed image; extracting an image feature corresponding to each of the touch areas; and obtaining the pattern by sequentially connecting each image feature according to a touch sequence; and unlock the electronic device when a similarity degree between the obtained pattern and a predetermined pattern is greater than or equal to a predetermined value.