Image extraction method, device and computer-readable storage medium
Through edge detection and color feature vector clustering methods, the image areas in the long web page map are screened, which solves the problem of insufficient utilization and flexible application of picture information in the prior art, and improves the accuracy of picture extraction.
Patent Information
- Application Number
- CN201910349682.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-04-28
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2039-04-28
AI Technical Summary
In the details of the item introduction on the web page, it is difficult for the prior art to effectively analyze, process and reuse multiple detailed pictures contained in the long pictures, resulting in insufficient utilization and flexible application of picture information.
The candidate image areas in the image are obtained through the edge detection algorithm, the color feature vectors of each candidate image area are determined, the color feature vectors are clustered, and the image areas are filtered out from the candidate image area according to the class cluster.
It improves the accuracy of image extraction, reduces the impact of interference, and enhances the utilization rate of information in the image and the flexible application of pictures.
Smart Images

Figure CN111783807B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to a picture extraction method, device and computer-readable storage medium. Background Art
[0002] In the detailed description of items on web pages, a long picture is often used, which includes multiple detail pictures and display pictures. Analyzing, processing and reusing the pictures included in the long picture can effectively improve the utilization rate of the information in the picture and improve the flexible application of the pictures. Summary of the invention
[0003] One purpose of the present disclosure is to improve the accuracy of image extraction.
[0004] According to one aspect of some embodiments of the present disclosure, a picture extraction method is proposed, comprising: obtaining candidate picture areas in an image through an edge detection algorithm, wherein the image includes one or more picture areas; determining color feature vectors of each candidate picture area; clustering the color feature vectors; and screening out picture areas from the candidate picture areas according to the clusters to which the color feature vectors of the candidate picture areas belong.
[0005] In some embodiments, selecting the picture region from the candidate picture regions includes: filtering the candidate picture regions according to the number of vectors in the cluster to which the color feature vector of the candidate picture region belongs, or the distance between the center of the cluster and a predetermined cluster center, to determine the picture region.
[0006] In some embodiments, determining the color feature vector of each candidate image region includes: determining the number of pixels belonging to each predetermined color range for each candidate image region; and determining the color feature vector according to the number and the order of the predetermined color ranges to which they belong in the predetermined feature vector.
[0007] In some embodiments, filtering out picture areas from candidate picture areas includes: obtaining the number of vectors in the cluster to which the color feature vector of the candidate picture area belongs; determining the cluster with the least number of vectors; excluding the candidate picture areas whose color feature vectors belong to the cluster with the least number of vectors, and determining the picture area.
[0008] In some embodiments, filtering out picture areas from candidate picture areas includes: determining the center of each cluster; obtaining the distance between the center of each cluster and a predetermined cluster center, wherein the predetermined cluster center is the cluster center of the color feature vector of the pre-stored picture area; determining the cluster farthest from the predetermined cluster center; excluding candidate picture areas whose color feature vectors belong to the cluster farthest from the predetermined cluster center, and determining the picture area.
[0009] In some embodiments, obtaining a candidate image area in an image through an edge detection algorithm includes: extracting edge lines through a Canny operator; extracting line segments in the edge lines that are greater than or equal to a predetermined length through a Hough transform; extracting horizontal and vertical line segments based on the slopes of the line segments, and obtaining a rectangular area cut out by the line segments; obtaining an area in the rectangular area that meets a predetermined size and a predetermined aspect ratio as a candidate image area.
[0010] In some embodiments, the parameters of the Canny operator for extracting edge lines include at least one of the following: an upper threshold interval of [195, 205], a lower threshold interval of [45, 55], or a filter size of 3, 5, or 7.
[0011] In some embodiments, the parameters of extracting line segments with slopes within a predetermined range in edge lines through Hough transform include at least one of the following: a distance accuracy of 1 pixel, an angle accuracy of π / 180 radians, or a threshold parameter of the accumulation plane of 100.
[0012] In some embodiments, obtaining a candidate image area in an image through an edge detection algorithm includes: obtaining derivative information of the image in the horizontal and vertical directions through a Sobel operator; obtaining the number of pixels in the same row and in the same column whose inverse information falls within a predetermined threshold range respectively; cutting the image along a first direction according to the number of pixels falling within the predetermined threshold range to obtain a cut image area, including: if the number of pixels falling within the predetermined threshold range is less than the predetermined number threshold, determining that the pixel in the second direction to which the current pixel belongs belongs to the same image as the previous pixel in the first direction; if the number of pixels falling within the predetermined threshold range is greater than the predetermined number threshold, determining that the pixel in the second direction to which the current pixel belongs belongs to a different image from the previous pixel in the first direction, wherein the first direction is either a horizontal direction or a vertical direction on the image plane, and the second direction is perpendicular to the first direction on the image plane; cutting the cut image area along the second direction according to the number of pixels falling within the predetermined threshold range to obtain a second cut image area; obtaining an area in the second cut image area that meets a predetermined aspect ratio as a candidate image area.
[0013] In some embodiments, the predetermined threshold range is [5, 255].
[0014] In some embodiments, the image extraction method further includes: converting the color image into a grayscale image; and obtaining a candidate image region in the image by an edge detection algorithm to extract the candidate image region from the grayscale image.
[0015] In some embodiments, the image extraction method further includes: generating a scrolling display image based on the screened image area.
[0016] Through this method, after obtaining the candidate image area based on edge detection, the clustering algorithm and the color of the image can be used to screen out the required image area from the candidate image area, thereby reducing the interference effect and improving the accuracy of image extraction.
[0017] According to an aspect of some other embodiments of the present disclosure, a picture extraction device is proposed, including: a picture candidate unit, configured to obtain candidate picture areas in an image through an edge detection algorithm, wherein the image includes one or more picture areas; a feature vector determination unit, configured to determine the color feature vectors of each candidate picture area; a clustering unit, configured to cluster the color feature vectors; and a screening unit, configured to screen out picture areas from the candidate picture areas according to the clusters to which the color feature vectors of the candidate picture areas belong.
[0018] In some embodiments, the image extraction device further includes: an image conversion unit configured to convert a color image into a grayscale image; and a picture candidate unit configured to extract a candidate picture area from the grayscale image.
[0019] In some embodiments, the image extraction device further includes: an image application unit configured to generate a scrolling display image based on the screened image area.
[0020] According to one aspect of some further embodiments of the present disclosure, a picture extraction device is proposed, comprising: a memory; and a processor coupled to the memory, wherein the processor is configured to execute any one of the above picture extraction methods based on instructions stored in the memory.
[0021] Such an image extraction device can obtain candidate image areas based on edge detection, and then use a clustering algorithm and the color of the image to filter out the required image areas from the candidate image areas, thereby reducing interference effects and improving the accuracy of image extraction.
[0022] According to one aspect of some further embodiments of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored, and when the instructions are executed by a processor, the steps of any one of the above-mentioned image extraction methods are implemented.
[0023] By executing instructions on such a computer-readable storage medium, after obtaining candidate image areas based on edge detection, the required image areas can be screened out from the candidate image areas using a clustering algorithm and the color of the image, thereby reducing interference effects and improving the accuracy of image extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure. In the drawings:
[0025] Figure 1 The following is a flowchart of some embodiments of the image extraction method disclosed in the present invention.
[0026] Figure 2 Flowcharts of other embodiments of the image extraction method disclosed herein.
[0027] Figure 3 The present invention is a flowchart of some embodiments of obtaining candidate image regions in the image extraction method of the present invention.
[0028] Figure 4 Flowcharts of other embodiments of obtaining candidate image regions in the image extraction method disclosed herein.
[0029] Figure 5 Flowcharts of some further embodiments of the image extraction method disclosed herein.
[0030] Figures 6A to 6E Schematic diagrams of some embodiments of the image extraction method disclosed in the present invention.
[0031] Figure 7 Schematic diagrams of some embodiments of the image extraction device disclosed in the present invention.
[0032] Figure 8 Schematic diagrams of other embodiments of the image extraction device disclosed in the present invention.
[0033] Fig. 9 Schematic diagrams of some further embodiments of the image extraction device disclosed herein. DETAILED DESCRIPTION
[0034] The technical solution of the present disclosure is further described in detail below through the accompanying drawings and embodiments.
[0035] The flowcharts of some embodiments of the picture extraction method disclosed in the present invention are as follows: Figure 1 shown.
[0036] In step 101, a candidate image region in an image is obtained by an edge detection algorithm, and the image includes one or more image regions. In some embodiments, edge lines in an image may be determined by an edge detection algorithm, and a rectangular region may be extracted as a candidate image region. In some embodiments, the candidate image region may be extracted by using a Canny operator in combination with a Hough transform; in other embodiments, the candidate image region may be extracted by using a Sobel operator.
[0037] In step 102, the color feature vector of each candidate image region is determined. In some embodiments, the color range, such as the [0, 255] values of red, green, and blue, can be divided into multiple ranges, each range corresponds to a dimension in the color feature vector, and the color statistics of each dimension are performed on each candidate image region to determine the color feature vector of each candidate image region.
[0038] In step 103, the color feature vectors are clustered. In some embodiments, the color feature vectors may be clustered using a K-means algorithm.
[0039] In step 104, the picture region is selected from the candidate picture regions according to the cluster to which the color feature vector of the candidate picture region belongs. In some embodiments, the candidate picture regions corresponding to one or some clusters can be deleted as needed, and the remaining color feature regions are used as picture regions.
[0040] Since long images containing multiple images often include text and model information, this method can be used to obtain candidate image areas based on edge detection, and then use clustering algorithms and image colors to filter out required image areas from the candidate image areas, thereby reducing interference effects and improving the accuracy of image extraction.
[0041] Flow charts of other embodiments of the picture extraction method disclosed in the present invention are as follows: Figure 2 shown.
[0042] In step 201, a candidate image region in an image is obtained by using an edge detection algorithm.
[0043] In step 202, for each candidate image region, the number of pixels belonging to each predetermined color range is determined.
[0044] In step 203, a color feature vector is obtained according to the order of the quantity and the belonging predetermined color ranges in the predetermined feature vector.
[0045] In some embodiments, the color distribution in the image can be reflected by a color histogram, and the color frequency is counted for each channel bucket. For example, the number of buckets for each channel is set to 16. For an image with three RGB channels, the color histogram feature of an image is a 16*3, or 48-dimensional color feature vector.
[0046] In step 204, the color feature vectors are clustered and candidate image regions are screened based on the clusters obtained by clustering.
[0047] In some embodiments, different cluster screening strategies can be selected according to needs. For example, when the image has a relatively uniform and even background color, or the background color is similar to the color of the image area to be acquired, the method such as steps 211 to 213 can be used to determine the clusters to be deleted.
[0048] In step 211, the number of vectors in the cluster to which the color feature vector of the candidate image region belongs is obtained.
[0049] In step 212, the cluster with the least number of vectors is determined.
[0050] In step 213, the candidate picture regions whose color feature vectors belong to the cluster with the least number of vectors are excluded to determine the picture region.
[0051] In most cases, the number of pictures in an image is greater than the number of text areas and size tables, and the colors of pictures are often rich, while the colors of text and size tables are often relatively simple. Therefore, the distance between the color feature vectors of pictures and other parts is large. By deleting clusters with a small number of samples after clustering, the candidate picture areas to which text and size tables belong can be deleted, thereby obtaining the picture area.
[0052] In other embodiments, in order to avoid erroneous deletion due to the lack of text or size chart area in the image, or too many text or size chart areas, the operations in steps 221 to 224 may be performed.
[0053] In step 221, the center of each cluster is determined by a clustering algorithm.
[0054] In step 222, the distance between the center of each cluster and the predetermined cluster center is obtained, and the predetermined cluster center is the cluster center of the color feature vector of the pre-stored image area. In some embodiments, a large amount of image data can be used for clustering, and after the cluster of non-information page images is obtained, the value of the cluster center is saved and will not change during subsequent use.
[0055] In step 223, the cluster farthest from the predetermined cluster center is determined.
[0056] In step 224, the candidate picture regions whose color feature vectors belong to the cluster farthest from the predetermined cluster center are excluded to determine the picture region.
[0057] This method can avoid erroneous deletion due to the absence of text or size chart areas in the image or the large number of text or size chart areas, thereby improving the successful extraction rate of the image area.
[0058] The flowchart of some embodiments of obtaining candidate image regions in the image extraction method of the present disclosure is as follows: Figure 3 shown.
[0059] In step 301, edge lines are extracted by using the Canny operator. In some embodiments, the Canny operator can be used to binarize the image and outline all edges in the image. In some embodiments, the implementation of OpenCV (open source computer vision library) can be used to set upper and lower thresholds and filter sizes respectively.
[0060] For each pixel, if the value is less than the lower threshold, the pixel is considered not to be an edge; if the value is greater than the upper threshold, it is an edge; when the value is between the upper and lower thresholds, if the pixel connected to the current pixel is an edge, the current pixel is also considered to be an edge, otherwise the current pixel is not an edge. The two thresholds together constitute the sensitivity of edge detection. The lower the upper threshold, the easier it is to determine that a pixel is an edge, and the higher the lower threshold, the easier it is to determine that a pixel is not an edge. The filter size determines how many pixels are involved in the calculation when calculating the Canny value of each pixel. In some embodiments, the upper and lower thresholds can be set to 200 and 50 respectively, and the filter size can be 3. In some embodiments, the interval of the upper threshold can be set to [195,205], the interval of the lower threshold can be set to [45,55], or the filter size can be set to 3, 5, or 7.
[0061] In step 302, line segments greater than or equal to a predetermined length in the edge line are extracted by Hough transform. In some embodiments, Hough transform can detect all straight lines, and can be implemented by using HoughLinesP (statistical Hough transform) of OpenCV. In some embodiments, the parameters of Hough transform can be adjusted by setting one or more of distance accuracy rho, angle accuracy theta, and threshold parameter threshold of the accumulation plane, such as setting rho=1, theta=π / 180, and threshold=100.
[0062] In step 303, horizontal (slope is 0) and vertical (slope is 90 degrees) line segments are extracted according to the slope of the line segment, and all horizontal and vertical lines are combined to cut out a large number of small rectangles to obtain the rectangular area cut out by the line segment. In some embodiments, the over-segmented line segments can be deleted to reduce the amount of data for calculation.
[0063] In step 304, an area in the rectangular area that meets a predetermined size and a predetermined aspect ratio is obtained as a candidate image area. In some embodiments, a predetermined size interval and a predetermined aspect ratio interval can be set to eliminate images that are too large or too small, and images whose aspect ratios are not within the predetermined aspect ratio interval, to form a candidate image area.
[0064] Through this method, the Canny operator can be used in conjunction with the Hough transform workflow with appropriate parameters to extract candidate image regions from the image. While improving efficiency, it is also possible to delete regions that obviously do not conform to the image characteristics by judging the slope, size, and proportion, thereby improving the accuracy of extraction and reducing the amount of computation in the subsequent calculation process.
[0065] Flowcharts of other embodiments of obtaining candidate image regions in the image extraction method disclosed in the present invention are as follows: Figure 4 shown.
[0066] In step 401, the derivative information of the image in the horizontal and vertical directions is obtained by using the Sobel operator. In some embodiments, two different Sobel operators can be used for calculation, one for calculating the derivative in the X direction and one for calculating the derivative in the Y direction. Specifically, in the Sobel implementation using OpenCV, one operator has dx=0, dy=1, and the other operator has dx=1, dy=0.
[0067] In step 402, the number of pixels in the same row and the same column whose reciprocal information falls within a predetermined threshold range is obtained respectively. In some embodiments, taking the Y direction (vertical direction) as an example, a threshold range is set, and the number of pixels in a row (horizontal X direction) falling within the threshold range is counted. In some embodiments, the threshold of OpenCV can be used for binarization first, and then directly accumulated to obtain two one-dimensional arrays.
[0068] In step 403, the image is cut along the first direction according to the number of pixels falling within the predetermined threshold range, and a cut image area is obtained. The first direction is any one of the horizontal direction or the vertical direction on the image plane, and the second direction is perpendicular to the first direction on the image plane. The cutting strategy may include: if the number of pixels falling within the predetermined threshold range is less than the predetermined number threshold, it is determined that the pixel in the second direction to which the current pixel belongs belongs to the same image as the previous pixel in the first direction; if the number of pixels falling within the predetermined threshold range is greater than the predetermined number threshold, it is determined that the pixel in the second direction to which the current pixel belongs belongs to different images from the previous pixel in the first direction.
[0069] In step 404, the first cut image area is cut along the second direction according to the number of pixels falling within the predetermined threshold range to obtain a second cut image area. The logic of the cutting is the same as the logic of the first cutting in step 403.
[0070] In step 405, an area in the secondary cut image area that meets a predetermined aspect ratio range is obtained as a candidate image area.
[0071] This method can make full use of the mathematical principle of the Sobel operator to detect the continuity of the image in both the horizontal and vertical directions, thereby determining the image boundary. This method requires less manual parameter configuration and is conducive to improving the automation of candidate image extraction.
[0072] Flowcharts of some other embodiments of the picture extraction method disclosed in the present invention are as follows: Figure 5 shown.
[0073] In step 501, the color image is converted into a grayscale image, such as Fig. 6A as shown in .
[0074] In step 502, a candidate image region in the image is obtained by edge detection algorithm. The extraction of the candidate image region can be performed as follows: Figure 3 or the algorithm used in 4. In some embodiments, Fig. 6A The image in can be cut into Figures 6B to 6E Candidate image regions in . Fig. 6A It can be seen that there is a part of the incomplete picture at the bottom of the image. This area will be discarded due to the abnormal aspect ratio and will not be used as a candidate image area.
[0075] In step 503, the color feature vector of each candidate image region is obtained.
[0076] In step 504, the color feature vectors are clustered.
[0077] In step 505, according to the cluster to which the color feature vector of the candidate image region belongs, the image region is screened out from the candidate image region, such as deleting Figure 6C The size chart area is obtained by 6B, 6D, and 6E areas.
[0078] In the related image cropping methods, microscopic features are often extracted first, and then a large number of rules are used to generate and filter possible boundary lines after combining the features. Many manual rules need to be written, and the performance and generalization capabilities are insufficient. The method in the embodiment of the present disclosure can improve the accuracy of image area determination, reduce the number of parameters configured manually, and improve generalization capabilities.
[0079] In some embodiments, step 506 may be further included, where the filtered image area is used to perform a specific application, such as analyzing image details. In some embodiments, in order to reduce the number of page scrolling operations by the user, a scrolling display image may be generated based on the filtered image area, thereby eliminating the need to occupy a large page and being able to display images to the user by scrolling in the same page area, thereby improving the degree of automation of page display and reducing the amount of page area occupied.
[0080] Through this method, the color image can be converted into a grayscale image first and then the candidate image region can be extracted, thereby improving the calculation accuracy of the Sobel operator and the Canny operator, and improving the accuracy of the candidate image region recognition and extraction.
[0081] Schematic diagrams of some embodiments of the picture extraction device disclosed in the present invention are as follows Figure 7 shown.
[0082] The picture candidate unit 701 can obtain a candidate picture region in an image by using an edge detection algorithm, and the image includes one or more picture regions. In some embodiments, the edge line in the image can be determined by an edge detection algorithm, and a rectangular region can be extracted as a candidate picture region. In some embodiments, the picture candidate unit 701 can use the following method: Figure 3 or Figure 4 The method in the illustrated embodiment extracts candidate picture regions.
[0083] The feature vector determination unit 702 can determine the color feature vector of each candidate image region. In some embodiments, the number of pixels belonging to each predetermined color range can be determined for each candidate image region; and the color feature vector is obtained according to the number and the order of the predetermined color ranges in the predetermined feature vector.
[0084] The clustering unit 703 can cluster the color feature vectors. In some embodiments, the color feature vectors can be clustered by a K-means algorithm.
[0085] The screening unit 704 can screen out the picture area from the candidate picture area according to the cluster to which the color feature vector of the candidate picture area belongs. In some embodiments, the candidate picture area corresponding to one or some clusters can be deleted as needed, and the remaining color feature area is used as the picture area.
[0086] After obtaining candidate image regions based on edge detection, such a device can use a clustering algorithm and the color of the image to filter out the required image regions from the candidate image regions, thereby reducing interference effects and improving the accuracy of image extraction.
[0087] In some embodiments, Figure 7 As shown, the image extraction device may further include an image conversion unit 705, which can convert a color image into a grayscale image, thereby improving the calculation accuracy of the Sobel operator and the Canny operator, and improving the accuracy of identifying and extracting the candidate image region.
[0088] In some embodiments, Figure 7As shown, the image extraction device may also include an image application unit 706, which can apply the filtered image area to perform specific applications, such as analyzing image details. In some embodiments, in order to reduce the user's operation of sliding pages, a scrolling display image can be generated based on the filtered image area, so that there is no need to occupy a large page, and the image can be displayed to the user by scrolling in the same page area, thereby improving the automation of page display and reducing the occupation of the page area.
[0089] The structural diagram of an embodiment of the picture extraction device disclosed in the present invention is as follows Figure 8 As shown. The image extraction device includes a memory 801 and a processor 802. Wherein: the memory 801 can be a disk, a flash memory or any other non-volatile storage medium. The memory is used to store the instructions in the corresponding embodiment of the image extraction method above. The processor 802 is coupled to the memory 801 and can be implemented as one or more integrated circuits, such as a microprocessor or a microcontroller. The processor 802 is used to execute the instructions stored in the memory, which can reduce the influence of interference and improve the accuracy of image extraction.
[0090] In one embodiment, it is also possible to Fig. 9 As shown, the image extraction device 900 includes a memory 901 and a processor 902. The processor 902 is coupled to the memory 901 via a BUS bus 903. The image extraction device 900 can also be connected to an external storage device 905 via a storage interface 904 to call external data, and can also be connected to a network or another computer system (not shown) via a network interface 906. No further detailed description will be given here.
[0091] In this embodiment, by storing data instructions in a memory and then processing the instructions through a processor, interference effects can be reduced and the accuracy of image extraction can be improved.
[0092] In another embodiment, a computer-readable storage medium stores computer program instructions thereon, which, when executed by a processor, implement the steps of the method in the corresponding embodiment of the image extraction method. Those skilled in the art should understand that the embodiments of the present disclosure may be provided as methods, devices, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable non-transitory storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0093] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram and the combination of processes and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0094] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0095] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0096] So far, the present disclosure has been described in detail. In order to avoid obscuring the concept of the present disclosure, some details known in the art are not described. Based on the above description, those skilled in the art can fully understand how to implement the technical solution disclosed here.
[0097] The method and apparatus of the present disclosure may be implemented in many ways. For example, the method and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.
[0098] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present disclosure rather than to limit it. Although the present disclosure has been described in detail with reference to the preferred embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present disclosure can still be modified or some technical features can be replaced by equivalents without departing from the spirit of the technical solution of the present disclosure, which should be included in the scope of the technical solution for protection of the present disclosure.
Claims
1. A method for extracting an image, comprising: Acquire a candidate picture region in an image by using an edge detection algorithm, wherein the image includes one or more picture regions; Determining the color feature vector of each candidate image region includes: determining, for each candidate image region, the number of pixels belonging to each predetermined color range; determining the color feature vector according to the number and the order of the predetermined color ranges in the predetermined feature vector, wherein each color range corresponds to a dimension in the color feature vector; Clustering the color feature vectors; According to the cluster to which the color feature vector of the candidate picture area belongs, a picture area is screened out from the candidate picture area, including: obtaining the number of vectors in the cluster to which the color feature vector of the candidate picture area belongs; determining the cluster with the least number of vectors; excluding the candidate picture area whose color feature vector belongs to the cluster with the least number of vectors, and determining the picture area.
2. The method according to claim 1, wherein: The step of selecting a picture region from the candidate picture regions further comprises: The candidate image regions are filtered according to the distance between the center of the cluster and a predetermined cluster center to determine the image region.
3. The method according to claim 1 or 2, wherein: The step of selecting a picture region from the candidate picture regions further comprises: Determine the center of each cluster; Obtaining the distance between the center of each of the clusters and a predetermined cluster center, wherein the predetermined cluster center is the cluster center of the color feature vector of the pre-stored image region; Determine the cluster farthest from the predetermined cluster center; The candidate picture region whose color feature vector belongs to the cluster farthest from the predetermined cluster center is excluded to determine the picture region.
4. The method according to claim 1, wherein: The step of obtaining a candidate image region in an image by using an edge detection algorithm comprises: Extract edge lines through Canny operator; Extracting line segments whose slopes are within a predetermined range from the edge line by Hough transform; Extracting horizontal and vertical line segments according to the slopes of the line segments, and obtaining rectangular areas cut out by the line segments; An area in the rectangular area that meets a predetermined size and a predetermined aspect ratio is obtained as the candidate image area.
5. The method according to claim 4, comprising at least one of the following: The parameters of the Canny operator for extracting edge lines include at least one of the following: an upper threshold interval of [195, 205], a lower threshold interval of [45, 55], or a filter size of 3, 5 or 7; or, The parameters for extracting line segments of the edge line having a length greater than or equal to a predetermined length through Hough transform include at least one of the following: a distance accuracy of 1 pixel, an angle accuracy of π / 180 radians, or a threshold parameter of an accumulation plane of 100.
6. The method according to claim 1, wherein: The step of obtaining a candidate image region in an image by using an edge detection algorithm comprises: Obtaining derivative information of the image in horizontal and vertical directions through a Sobel operator; Respectively obtaining the number of pixels in the same row and the same column whose derivative information falls within a predetermined threshold range; The image is cut along a first direction according to the number of pixels falling within a predetermined threshold range, and a cut image area is obtained, including: if the number of pixels falling within the predetermined threshold range is less than the predetermined number threshold, it is determined that the pixel in the second direction to which the current pixel belongs and the previous pixel in the first direction belong to the same image; if the number of pixels falling within the predetermined threshold range is greater than the predetermined number threshold, it is determined that the pixel in the second direction to which the current pixel belongs and the previous pixel in the first direction belong to different images, wherein the first direction is any one of a horizontal direction or a vertical direction on the image plane, and the second direction is perpendicular to the first direction on the image plane; Cut the first cut image area along the second direction according to the number of pixels falling within a predetermined threshold range to obtain a second cut image area; An area in the second-cut image area that satisfies a predetermined aspect ratio is obtained as the candidate image area.
7. The method according to claim 6, wherein: The predetermined threshold range is [5, 255].
8. The method according to any one of claims 1, 4 to 7, further comprising: Convert color images to grayscale images; The acquiring the candidate picture region in the image by using the edge detection algorithm is to extract the candidate picture region from the grayscale image.
9. The method according to claim 1, further comprising: Generate scrolling display images based on the filtered image area.
10. A picture extraction device, comprising: A picture candidate unit is configured to obtain a candidate picture region in an image by an edge detection algorithm, wherein the image includes one or more picture regions; The feature vector determination unit is configured to determine the color feature vector of each of the candidate image regions, including: determining the number of pixels belonging to each predetermined color range for each of the candidate image regions; determining the color feature vector according to the number and the order of the predetermined color ranges in the predetermined feature vector, wherein each color range corresponds to a dimension in the color feature vector; A clustering unit configured to cluster the color feature vectors; The screening unit is configured to screen out picture areas from the candidate picture areas according to the cluster to which the color feature vector of the candidate picture area belongs, including: obtaining the number of vectors in the cluster to which the color feature vector of the candidate picture area belongs; determining the cluster with the least number of vectors; excluding the candidate picture area whose color feature vector belongs to the cluster with the least number of vectors, and determining the picture area.
11. The apparatus according to claim 10, further comprising: An image conversion unit configured to convert a color image into a grayscale image; The picture candidate unit is configured to extract the candidate picture area from the grayscale image.
12. The apparatus according to claim 10, further comprising: The picture application unit is configured to generate a scrolling display image based on the screened picture area.
13. A picture extraction device, comprising: Memory; as well as A processor coupled to the memory, the processor being configured to execute the method according to any one of claims 1 to 9 based on instructions stored in the memory.
14. A computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 9.