CN110298858B - Image clipping method and device - Google Patents

Image clipping method and device Download PDF

Info

Publication number
CN110298858B
CN110298858B CN201910585564.9A CN201910585564A CN110298858B CN 110298858 B CN110298858 B CN 110298858B CN 201910585564 A CN201910585564 A CN 201910585564A CN 110298858 B CN110298858 B CN 110298858B
Authority
CN
China
Prior art keywords
image
edge
pixel
difference
pixel unit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910585564.9A
Other languages
Chinese (zh)
Other versions
CN110298858A (en
Inventor
邵瑞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN201910585564.9A priority Critical patent/CN110298858B/en
Publication of CN110298858A publication Critical patent/CN110298858A/en
Application granted granted Critical
Publication of CN110298858B publication Critical patent/CN110298858B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20112Image segmentation details
    • G06T2207/20132Image cropping

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

The embodiment of the invention provides an image clipping method and device, and relates to the technical field of computer image processing, wherein the method comprises the following steps: performing edge extraction on an image to be processed, calculating to obtain a difference image representing the difference value of pixel points of the edge image, performing edge extraction on the difference image again to obtain a second edge image, calculating the distribution characteristics of the edge pixel points in each pixel unit of the second edge image, determining a fuzzy area in the image to be processed according to the distribution characteristics, and cutting and removing the determined fuzzy area. When the embodiment of the invention is applied to cutting and removing the blurred region in the image, the contrast degree of the blurred region and the non-blurred region in the image is increased through continuous image calculation and transformation, and then the blurred regions at two sides of the image in the vertical direction or the horizontal direction are found out and cut and removed. By using the scheme provided by the embodiment of the invention to cut the image, the accuracy of cutting and removing the image fuzzy area can be improved.

Description

Image clipping method and device
Technical Field
The invention relates to the technical field of computer image processing, in particular to an image clipping method and device.
Background
When an image is displayed, sometimes the size of the image itself is smaller than the size of the display area, and in this case, a blur area is usually added around the image according to the pixel values of the pixels around the image, so that the size of the image is consistent with the size of the display area. Due to the similar pixel values of the blurred region, when the image is analyzed, the blurred region does not bring useful information basically, and even generates redundant information, in which case the blurred region needs to be cut and removed.
In the prior art, in order to remove the added blurred region from the image, edge detection is usually performed on the image after the blurred region is added by using an edge detection algorithm, and then the blurred region in the image is determined according to an edge detection result, and the detected blurred region is cut and removed.
The inventor finds that the prior art at least has the following problems in the process of implementing the invention:
due to the influence of factors such as the detection accuracy of the edge detection algorithm in the prior art, it is difficult to accurately identify the boundary between the blurred region and the non-blurred region according to the edge detection result, so that when the blurred region is removed, all the blurred region may not be removed, and the non-blurred region may be erroneously determined as the blurred region and removed.
Therefore, the accuracy rate is low when the fuzzy area in the image is cut and removed by applying the prior art.
Disclosure of Invention
The embodiment of the invention aims to provide an image cropping method and an image cropping device, so as to improve the accuracy of cropping and removing an image fuzzy area. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides an image cropping method, where the method includes:
performing edge extraction on an image to be processed to obtain a first edge image;
obtaining a difference image formed by difference values corresponding to each pixel point in the first edge image, wherein the difference value corresponding to each pixel point represents: the difference of the pixel value between the pixel point and the pixel point within a preset range of the pixel point is as follows: a range along the direction of the pixel unit;
performing edge extraction on the difference image to obtain a second edge image;
obtaining the distribution characteristics of edge pixel points in each pixel unit in the second edge image;
determining a fuzzy region including a to-be-cut edge in the to-be-processed image according to the obtained distribution characteristics, and cutting off the fuzzy region, wherein the to-be-cut edge is as follows: and the image to be processed is arranged on the image side in the direction of the pixel unit.
In an embodiment of the present invention, the obtaining a difference image formed by difference values corresponding to each pixel point in the first edge image includes:
calculating a difference value corresponding to each pixel point in the first edge image along the direction of the pixel unit to obtain a first difference image;
calculating a difference value corresponding to each pixel point in the first difference image along the direction of the pixel unit to obtain a second difference image;
taking the second difference image as a new first difference image, and returning to the step of calculating the difference value corresponding to each pixel point in the first difference image along the direction of the pixel unit until the calculation times of the difference value reach preset times;
and taking the finally obtained second difference image as a difference image formed by the difference value corresponding to each pixel point in the first edge image.
In an embodiment of the present invention, the determining, according to the obtained distribution feature, a blurred region including a to-be-clipped edge in the to-be-processed image includes:
calculating a variation value between distribution characteristics corresponding to every two adjacent pixel units in the second edge image;
and determining a fuzzy area including the edge to be cut in the image to be processed according to the calculated change value.
In an embodiment of the present invention, the determining, according to the calculated change value, a blurred region including a to-be-clipped edge in the to-be-processed image includes:
determining a first pixel unit pair with a variation value between first distribution characteristics larger than a preset threshold value and a second pixel unit pair with a variation value between last distribution characteristics larger than the preset threshold value in the second edge image along a direction vertical to the direction of the pixel units;
determining a region between a first pixel unit and a first edge to be cut in the image to be processed as a fuzzy region, and determining a region between a second pixel unit and a second edge to be cut in the image to be processed as a fuzzy region, wherein the first pixel unit is as follows: the first pixel unit is corresponding to one pixel unit in the pixel units in the image to be processed, and the first edge to be cut is: along the first pixel unit perpendicular with the direction in which pixel unit is located, the second pixel unit is: the second pixel unit is for one pixel unit in the corresponding pixel units in the image to be processed, and the second edge to be cut is: and the last pixel unit along the direction vertical to the direction of the pixel unit.
In one embodiment of the present invention, the pixel unit includes: rows and/or columns of pixels.
In a second aspect, an embodiment of the present invention provides an image cropping device, where the device includes:
the first edge image obtaining module is used for carrying out edge extraction on the image to be processed to obtain a first edge image;
a difference image obtaining module, configured to obtain a difference image formed by a difference value corresponding to each pixel point in the first edge image, where the difference value corresponding to each pixel point represents: the difference of the pixel value between the pixel point and the pixel point within a preset range of the pixel point is as follows: a range along the direction of the pixel unit;
the second edge image obtaining module is used for carrying out edge extraction on the difference image to obtain a second edge image;
a distribution feature obtaining module, configured to obtain a distribution feature of edge pixel points in each pixel unit in the second edge image;
a fuzzy region clipping module, configured to determine, according to the obtained distribution characteristics, a fuzzy region in the image to be processed, where the fuzzy region includes a to-be-clipped edge, and clip and remove the fuzzy region, where the to-be-clipped edge is: and the image to be processed is arranged on the image side in the direction of the pixel unit.
In an embodiment of the present invention, the difference image obtaining module includes:
the first difference image obtaining unit is used for calculating a difference value corresponding to each pixel point in the first edge image along the direction of the pixel unit to obtain a first difference image;
a second difference image obtaining unit, configured to calculate a difference value corresponding to each pixel point in the first difference image along a direction in which the pixel unit is located, so as to obtain a second difference image;
a new difference image determining unit, configured to determine the second difference image as a new first difference image, and trigger the second difference image obtaining unit until the number of times of calculating the difference value reaches a preset number of times;
and the difference image determining unit is used for determining the finally obtained second difference image as a difference image formed by the difference value corresponding to each pixel point in the first edge image.
In an embodiment of the present invention, the fuzzy region clipping module includes:
the change value calculating unit is used for calculating the change value between the distribution characteristics corresponding to every two adjacent pixel units in the second edge image;
the fuzzy region determining unit is used for determining a fuzzy region comprising the edge to be cut in the image to be processed according to the change value obtained by calculation;
and the fuzzy region clipping unit is used for clipping and removing the fuzzy region.
In an embodiment of the present invention, the blurred region determining unit is specifically configured to determine, along a direction perpendicular to a direction in which the pixel units are located, a first pixel unit pair in which a variation value between first distribution features in the second edge image is greater than a preset threshold, and a second pixel unit pair in which a variation value between last distribution features in the second edge image is greater than the preset threshold;
determining a region between a first pixel unit and a first edge to be cut in the image to be processed as a fuzzy region, and determining a region between a second pixel unit and a second edge to be cut in the image to be processed as a fuzzy region, wherein the first pixel unit is as follows: the first pixel unit is corresponding to one pixel unit in the pixel units in the image to be processed, and the first edge to be cut is: along the first pixel unit perpendicular with the direction in which pixel unit is located, the second pixel unit is: the second pixel unit is for one pixel unit in the corresponding pixel units in the image to be processed, and the second edge to be cut is: and the last pixel unit along the direction vertical to the direction of the pixel unit.
In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor and the communication interface complete communication between the memory and the processor through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of the first aspect when executing a program stored in the memory.
In a fourth aspect, embodiments of the present invention also provide a computer program product comprising instructions, which when run on a computer, cause the computer to perform the method steps of any of the first aspects described above.
As can be seen from the above, when the scheme provided by the embodiment of the present invention is applied to image clipping, edge extraction is performed on an image to be processed, a difference image representing a difference value of pixel points of the edge image is obtained through calculation, the edge extraction is performed on the difference image again to obtain a second edge image, distribution characteristics of edge pixel points in each pixel unit of the second edge image are calculated, a blurred region in the image to be processed is determined according to the distribution characteristics, and the determined blurred region is clipped and removed. Compared with the prior art, the scheme provided by the embodiment of the invention carries out two times of edge extraction and difference calculation on the image to be processed, enhances the pixel change difference degree of a fuzzy area and a non-fuzzy area in the image to be processed, then obtains the distribution characteristics of edge pixel points in each pixel unit of the calculated image, and determines the fuzzy area in the image by utilizing the distribution characteristics so as to carry out cutting removal. Therefore, by applying the embodiment of the invention, the accuracy of cutting and removing the image fuzzy area can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flow chart of an image cropping method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an image to be processed according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an edge extraction image according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a difference image according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a distribution characteristic of a pixel point according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a processed image according to an embodiment of the present invention;
FIG. 7 is a schematic structural diagram of an image cropping device according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention provides an image cropping method and an image cropping device, which are respectively described in detail below.
First, an execution body of the image cropping scheme provided by the embodiment of the present invention is explained.
The execution subject may be a software client, for example, video processing software, image processing software, or the like.
In addition, the execution main body may also be an electronic device running the client, for example, a desktop computer, a notebook computer, a tablet computer, a smart phone, and the like.
The following describes an image cropping method provided by an embodiment of the present invention with reference to a specific embodiment.
Referring to fig. 1, fig. 1 is a schematic flow chart of an image cropping method according to an embodiment of the present invention, where the method includes the following steps 101-105.
Step 101, performing edge extraction on an image to be processed to obtain a first edge image.
The image to be processed can be a gray scale image or a color image.
When the image to be processed is a color image, the image to be processed may be converted into a gray-scale image, and then the converted gray-scale image may be subjected to edge extraction to obtain a first edge image.
Specifically, when the edge extraction is performed, a preset edge detection operator may be used to perform the edge extraction on the image.
For example, the edge detection operator may be Sobel (Sobel) operator, Roberts (Roberts) operator, Log (laplacian gaussian) operator, and the like, which is not limited in the present invention.
As shown in fig. 2, the gray scale image represents an image to be processed, and an edge detection operator Canny (Canny) operator is used to perform edge extraction on the gray scale image, so as to obtain a first edge image, as shown in fig. 3.
When the Canny operator is used for processing the image to be processed, the non-maximum signal in the image can be suppressed, so that the non-fuzzy area with severe color change in the image to be processed is improved, and the fuzzy area with small color change in the image to be processed is restrained.
Step 102, obtaining a difference image formed by difference values corresponding to each pixel point in the first edge image.
Wherein, the difference value corresponding to each pixel point represents: the difference of the pixel value between the pixel point and the pixel point within a preset range of the pixel point is as follows: along the extent of the direction in which the pixel cell is located.
The pixel units may be pixel rows or pixel columns.
When the pixel unit is a pixel row, the direction of the pixel unit is a horizontal direction, and the preset range is a range along the horizontal direction. In this case, the pixel point within the preset range where one pixel point is located may be a preset number of pixel points horizontally left of the pixel point and/or a preset number of pixel points horizontally right of the pixel point.
When the pixel units are pixel columns, the direction of the pixel units is a vertical direction, and the preset range is a range along the vertical direction. In this case, the pixel point within the preset range where one pixel point is located may be a preset number of vertically upward pixel points of the pixel point and/or a preset number of vertically downward pixel points of the pixel point.
The difference value corresponding to one pixel point can be obtained by calculating the average difference, variance, range, and the like of the pixel values of the pixel point and the pixel point in the preset range.
The difference value corresponding to each pixel point is the difference value between each pixel point and other pixel points in the preset range. For example, the difference value corresponding to each pixel point can be obtained by calculating an average value of the gradient values between each pixel point and other pixel points in the preset range.
In one embodiment of the present invention, the above-described difference image may be obtained by the following steps A-D.
Step A: and calculating a difference value corresponding to each pixel point in the first edge image along the direction of the pixel unit to obtain a first difference image.
Specifically, each pixel point in the first edge image has a difference value, so that each pixel point in the first difference image and each pixel point in the first edge image correspond to each other one to one. The pixel value of each pixel point in the first difference image is the difference value of the corresponding pixel point of the pixel point in the first edge image.
And B: and calculating a difference value corresponding to each pixel point in the first difference image along the direction of the pixel unit to obtain a second difference image.
Since each pixel point in the first difference image has a difference value, it can be considered that each pixel point in the second difference image corresponds to each pixel point in the first difference image one to one. The pixel value of each pixel point in the second difference image is the difference value of the pixel point corresponding to the pixel point in the first difference image.
And C: and D, taking the second difference image as a new first difference image, and returning to the step B until the calculation times of the difference value reach preset times.
Wherein, the preset times can be 3 times, 6 times, 7 times and the like. The specific times are determined according to the application scene, the image type and the accuracy rate of cutting and removing a large number of image fuzzy areas. Specifically, the application scene includes picture software, video software, picture web pages, video web pages and the like, and the image types can be divided according to image sizes, pixel sizes, people, landscapes, real objects and the like.
Step D: and taking the finally obtained second difference image as a difference image formed by the difference value corresponding to each pixel point in the first edge image.
For example, a Sobel edge detection operator may be used to calculate a difference value corresponding to each pixel point in the first edge image along the pixel column direction, and the difference image is obtained through 7 times of calculation. Firstly, calculating a difference value corresponding to each pixel point in a first edge image by using a Sobel edge detection operator along the direction of a pixel column to obtain a first difference image; then calculating a difference value corresponding to each pixel point in the first difference image along the direction of the pixel row to obtain a second difference image; taking the second difference image as a new first difference image, and returning to the step of calculating the difference value corresponding to each pixel point in the first difference image along the direction of the pixel row to obtain the second difference image until the calculation times of the difference value reach 7 times; and taking the second difference image obtained after 7 times of calculation as a difference image formed by the difference value corresponding to each pixel point in the first edge image.
And 103, performing edge extraction on the difference image to obtain a second edge image.
Similarly, the edge extraction may be implemented by using an edge detection operator such as a Sobel operator, a Roberts operator, and a Log operator, which is not limited in the present invention.
For example, as shown in fig. 4, the difference image is subjected to edge extraction by using a Laplacian edge detector to obtain a second edge image.
Step 104, obtaining the distribution characteristics of the edge pixel points in each pixel unit in the second edge image.
Specifically, the distribution characteristics may be a variance, a standard deviation, an average difference, and the like between pixel values of edge pixel points in each pixel unit in the second edge image; the pixel unit direction is consistent with the pixel unit direction in step 102.
For example, the variance of the edge pixel points in each pixel column in the second edge image is calculated along the vertical direction as the distribution characteristic. Calculating the variance of the pixel values of each row of pixel units in the second edge image from left to right, and forming an array A (n) i by a series of variance values0,i1,i2,……in]Wherein i0Representing the distribution characteristic of the edge pixel points of the first pixel column to the left of the second edge image, i1Distribution characteristic … … i representing edge pixel point of second pixel column on left side of second edge imagenAnd the distribution characteristics of the edge pixel points of the (n + 1) th pixel column at the left side of the second edge image are shown. The array can represent the distribution characteristics of the edge pixel points in each pixel column from left to right in the second edge image.
And 105, determining a fuzzy area including the edge to be cut in the image to be processed according to the obtained distribution characteristics, and cutting off the fuzzy area.
Wherein, the edge to be cut is as follows: and the image to be processed is arranged at the image edge of the direction of the pixel unit. Under the condition that the pixel units are pixel columns, the sides to be cut are the sides where two pixel columns at the left end and the right end of the image to be processed are located; and under the condition that the pixel units are pixel lines, the edge to be cut is the edge where two pixel lines at the upper end and the lower end of the image to be processed are located.
In an embodiment of the present invention, the step 105 may include the following first and second steps:
and firstly, calculating a variation value between the distribution characteristics corresponding to every two adjacent pixel units in the second edge image.
Specifically, the variation value between the distribution characteristics corresponding to every two adjacent pixel units in the second edge image may be represented by a difference value of the distribution characteristics corresponding to the two adjacent pixel units, or may be represented by a quotient obtained by dividing the distribution characteristics corresponding to the two adjacent pixel units, which is not limited in the present invention.
For example, the first-order difference of the above-mentioned array a (n) is used to represent the variation value between the distribution characteristics corresponding to each two adjacent pixel units in the second edge image. The first difference of the above array is calculated using the following formula:
B[in]=A[in+1]-A[in]
thereby obtaining a new array B (n-1) [ A1-A0,A2-A1,……An-An-1]。
The array B (n-a) is a variation value between distribution characteristics corresponding to each two adjacent pixel units in the second edge image.
And secondly, determining a fuzzy area including the edge to be cut in the image to be processed according to the calculated change value.
In an embodiment of the present invention, along a direction perpendicular to a direction in which the pixel units are located, a first pixel unit pair in which a variation value between first distribution features in the second edge image is greater than a preset threshold and a second pixel unit pair in which a variation value between last distribution features in the second edge image is greater than the preset threshold are determined.
Specifically, in order to more clearly show the pixel point distribution difference between adjacent pixel units, the array B is sorted. Specifically, as shown in fig. 5, a threshold value a is set, the elements greater than a in the array B are set to 100, the elements less than a are set to 0, and the values of the elements in the sorted array B only include 0 or 100. The value of the threshold value a can be 10, 30, 80, etc., and the specific value is determined according to the application scene, the image type, the accuracy rate of the cropping removal of a large amount of image fuzzy areas, etc.
Under the condition that the pixel units are pixel columns, the first pixel unit pair and the second pixel unit pair represent pixel unit pairs with large pixel difference change at the left side and the right side of the image to be processed; when the pixel units are pixel rows, the first pixel unit pair and the second pixel unit pair represent pixel unit pairs with large pixel difference change on the upper side and the lower side of the image to be processed. Therefore, the first pixel unit pair and the second pixel unit pair can be considered as the boundary of the blurred region and the non-blurred region of the image to be processed.
Therefore, the area between the first pixel unit and the first edge to be cut in the image to be processed is determined as a blurred area, and the area between the second pixel unit and the second edge to be cut in the image to be processed is determined as a blurred area.
Wherein, the first pixel unit is: the first pixel unit is corresponding to one pixel unit in the pixel units in the image to be processed, and the first edge to be cropped is: along the first pixel unit perpendicular with the direction that above-mentioned pixel unit belongs to, above-mentioned second pixel unit is: the second pixel unit is corresponding to one pixel unit in the pixel units in the image to be processed, and the second edge to be cut is: and the last pixel unit along the direction vertical to the direction of the pixel unit.
The first pixel unit may be any one of a first pixel unit pair, and similarly, the second pixel unit may be any one of a second pixel unit pair.
When the pixel unit is a pixel column, the first edge to be cut is the leftmost pixel column of the image to be processed, and the second edge to be cut is the rightmost pixel column; when the pixel units are pixel lines, the first edge to be cropped is the uppermost pixel line of the image to be processed, and the second edge to be cropped is the lowermost pixel line.
For example, a first pixel unit pair corresponding to the first non-0 element from the left end of the array B and a second pixel unit pair corresponding to the first non-0 element from the right end of the array B are found. The pixel cell on the left side of the first pixel cell pair is considered as a first pixel cell, and the pixel cell on the right side of the second pixel cell pair is considered as a second pixel cell. Then, the area between the first pixel unit and the first edge to be cut on the leftmost side and the area between the second pixel unit and the second edge to be cut on the rightmost side of the image to be processed are determined as fuzzy areas.
In an implementation manner of the present invention, the blurred region of the image to be processed may also be determined directly according to the distribution characteristics corresponding to every two adjacent pixel units in the second edge image. Specifically, in a direction perpendicular to the direction of the pixel units, the first pixel units with distribution characteristic values larger than the preset characteristic value are searched from two ends to the middle respectively and serve as the boundary of the blurred region and the non-blurred region of the image to be processed, and therefore the part outside the boundary is determined to be the blurred region.
For example, in the case that the pixel units are in the vertical direction, a first pixel unit with a first distribution characteristic value larger than a preset characteristic value is searched from the left end of the image to be processed to the right, then a second pixel unit with a first distribution characteristic value larger than a preset characteristic value is searched from the right end of the image to be processed to the left, the two searched pixel units are used as the boundary of the blurred region and the non-blurred region of the image to be processed, and the region on the left side of the first pixel unit and the region on the right side of the second pixel unit are determined as the blurred region.
As shown in fig. 6, the determined blurred region is cut out to obtain a processed image.
Therefore, by applying the image clipping method provided by the embodiment of the invention, the edge of the image to be processed is extracted, the difference image representing the difference value of the pixel points of the edge image is obtained through calculation, the edge of the difference image is extracted again to obtain the second edge image, the distribution characteristics of the edge pixel points in each pixel unit of the second edge image are calculated, the fuzzy area in the image to be processed is determined according to the distribution characteristics, and the determined fuzzy area is clipped and removed. Compared with the prior art, the method and the device have the advantages that the pixel change difference degree of the blurred region and the non-blurred region in the image to be processed is enhanced through multiple times of transformation and calculation of the image to be processed, then the distribution characteristics of the edge pixel points in each pixel unit of the calculated image are obtained, the distribution characteristics are compared with the preset threshold value, and the blurred region in the image is determined and then cut and removed. Therefore, by applying the embodiment of the invention, the accuracy of cutting and removing the image fuzzy area can be improved.
Corresponding to the image clipping method, the embodiment of the invention also provides an image clipping device.
Fig. 7 is a schematic structural diagram of a graph cropping device according to an embodiment of the present invention, where the device includes:
a first edge image obtaining module 701, configured to perform edge extraction on an image to be processed to obtain a first edge image;
a difference image obtaining module 702, configured to obtain a difference image formed by difference values corresponding to each pixel point in the first edge image, where the difference value corresponding to each pixel point represents: the difference of the pixel value between the pixel point and the pixel point within a preset range of the pixel point is as follows: a range along the direction of the pixel unit;
a second edge image obtaining module 703, configured to perform edge extraction on the difference image to obtain a second edge image;
a distribution feature obtaining module 704, configured to obtain a distribution feature of edge pixel points in each pixel unit in the second edge image;
a fuzzy region clipping module 705, configured to determine, according to the obtained distribution feature, a fuzzy region in the to-be-processed image, where the to-be-clipped region includes a to-be-clipped edge, and clip the fuzzy region to remove the fuzzy region, where the to-be-clipped edge is: and the image to be processed is arranged at the image edge of the direction of the pixel unit.
In an embodiment of the present invention, the difference image obtaining module 702 includes:
the first difference image obtaining unit is specifically used for calculating a difference value corresponding to each pixel point in the first edge image along the direction of the pixel unit to obtain a first difference image;
the second difference image obtaining unit is specifically used for calculating a difference value corresponding to each pixel point in the first difference image along the direction of the pixel unit to obtain a second difference image;
a new difference image determining unit, configured to determine the second difference image as a new first difference image, and return to the second difference image obtaining unit until the number of calculations of the difference value reaches a preset number;
and the difference image determining unit is specifically configured to determine the finally obtained second difference image as a difference image formed by difference values corresponding to each pixel point in the first edge image.
In an implementation manner of the present invention, the fuzzy region clipping module 705 includes:
a change value calculation unit, configured to calculate a change value between distribution features corresponding to every two adjacent pixel units in the second edge image;
the fuzzy region determining unit is used for determining a fuzzy region comprising the edge to be cut in the image to be processed according to the change value obtained by calculation;
and the fuzzy region clipping unit is used for clipping and removing the fuzzy region.
In an implementation manner of the present invention, the blur area determining unit is specifically configured to determine, along a direction perpendicular to a direction in which the pixel units are located, a first pixel unit pair in which a variation value between first distribution features in the second edge image is greater than a preset threshold, and a second pixel unit pair in which a variation value between last distribution features in the second edge image is greater than the preset threshold;
determining a region between a first pixel unit and a first edge to be cut in the image to be processed as a fuzzy region, and determining a region between a second pixel unit and a second edge to be cut in the image to be processed as a fuzzy region, wherein the first pixel unit is as follows: the first pixel unit is corresponding to one pixel unit in the pixel units in the image to be processed, and the first edge to be cropped is: along the first pixel unit perpendicular with the direction that above-mentioned pixel unit belongs to, above-mentioned second pixel unit is: the second pixel unit is corresponding to one pixel unit in the pixel units in the image to be processed, and the second edge to be cut is: and the last pixel unit along the direction vertical to the direction of the pixel unit.
Therefore, with the image clipping device provided by the embodiment of the present invention, the edge of the image to be processed is extracted, the difference image representing the difference value of the pixel point of the edge image is obtained through calculation, the edge of the difference image is extracted again to obtain the second edge image, the distribution characteristics of the edge pixel point in each pixel unit of the second edge image are calculated, the blur area in the image to be processed is determined according to the distribution characteristics, and the determined blur area is clipped and removed. Compared with the prior art, the method and the device have the advantages that the pixel change difference degree of the blurred region and the non-blurred region in the image to be processed is enhanced through multiple times of transformation and calculation of the image to be processed, then the distribution characteristics of the edge pixel points in each pixel unit of the calculated image are obtained, the distribution characteristics are compared with the preset threshold value, and the blurred region in the image is determined and then cut and removed. Therefore, by applying the embodiment of the invention, the accuracy of cutting and removing the image fuzzy area can be improved.
An embodiment of the present invention further provides an electronic device, as shown in fig. 8, which includes a processor 801, a communication interface 802, a memory 803, and a communication bus 804, where the processor 801, the communication interface 802, and the memory 803 complete mutual communication through the communication bus 804,
a memory 803 for storing a computer program;
the processor 801 is configured to implement the image cropping method according to the embodiment of the present invention when executing the program stored in the memory 803.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any of the image cropping methods described above.
In yet another embodiment, a computer program product containing instructions is provided, which when run on a computer, causes the computer to perform any of the image cropping methods of the above embodiments.
It can be seen that, when the electronic device provided by the above embodiment is used for image cropping, executing the computer program stored in the computer-readable storage medium provided by the above embodiment to perform image cropping, and when the computer program product provided by the above embodiment is run on a computer to perform image cropping, an edge of an image to be processed is extracted, a difference image representing a difference value of pixel points of the edge image is obtained through recalculation, the difference image is edge-extracted again to obtain a second edge image, a distribution feature of edge pixel points in each pixel unit of the second edge image is calculated, a blurred region in the image to be processed is determined according to the distribution feature, and the determined blurred region is cropped and removed.
The electronic device, the readable storage medium and the computer program product provided by the embodiment of the invention can quickly and accurately realize the image cropping method provided by the embodiment of the invention. Compared with the prior art, the method and the device have the advantages that the pixel change difference degree of the blurred region and the non-blurred region in the image to be processed is enhanced through multiple times of transformation and calculation of the image to be processed, then the distribution characteristics of the edge pixel points in each pixel unit of the calculated image are obtained, the distribution characteristics are compared with the preset threshold value, and the blurred region in the image is determined and then cut and removed. Therefore, by applying the embodiment of the invention, the accuracy of cutting and removing the image fuzzy area can be improved.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, apparatus embodiments, electronic device embodiments, computer-readable storage medium embodiments, and computer program product embodiments are described with relative simplicity as they are substantially similar to method embodiments, where relevant only as described in portions of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. An image cropping method, characterized in that it comprises:
performing edge extraction on an image to be processed to obtain a first edge image;
obtaining a difference image formed by difference values corresponding to each pixel point in the first edge image, wherein the difference value corresponding to each pixel point represents: the difference of the pixel value between the pixel point and the pixel point within a preset range of the pixel point is as follows: a range along the direction of the pixel unit;
performing edge extraction on the difference image to obtain a second edge image;
obtaining the distribution characteristics of edge pixel points in each pixel unit in the second edge image;
determining a fuzzy region including a to-be-cut edge in the to-be-processed image according to the obtained distribution characteristics, and cutting off the fuzzy region, wherein the to-be-cut edge is as follows: and the image to be processed is arranged on the image side in the direction of the pixel unit.
2. The method according to claim 1, wherein the obtaining a difference image formed by difference values corresponding to each pixel point in the first edge image comprises:
calculating a difference value corresponding to each pixel point in the first edge image along the direction of the pixel unit to obtain a first difference image;
calculating a difference value corresponding to each pixel point in the first difference image along the direction of the pixel unit to obtain a second difference image;
taking the second difference image as a new first difference image, and returning to the step of calculating the difference value corresponding to each pixel point in the first difference image along the direction of the pixel unit until the calculation times of the difference value reach preset times;
and taking the finally obtained second difference image as a difference image formed by the difference value corresponding to each pixel point in the first edge image.
3. The method according to claim 1 or 2, wherein the determining a blurred region including an edge to be cropped in the image to be processed according to the obtained distribution feature comprises:
calculating a variation value between distribution characteristics corresponding to every two adjacent pixel units in the second edge image;
and determining a fuzzy area including the edge to be cut in the image to be processed according to the calculated change value.
4. The method according to claim 3, wherein the determining, according to the calculated variation value, a blurred region including an edge to be clipped in the image to be processed comprises:
determining a first pixel unit pair with a variation value between first distribution characteristics larger than a preset threshold value and a second pixel unit pair with a variation value between last distribution characteristics larger than the preset threshold value in the second edge image along a direction vertical to the direction of the pixel units;
determining a region between a first pixel unit and a first edge to be cut in the image to be processed as a fuzzy region, and determining a region between a second pixel unit and a second edge to be cut in the image to be processed as a fuzzy region, wherein the first pixel unit is as follows: the first pixel unit is corresponding to one pixel unit in the pixel units in the image to be processed, and the first edge to be cut is: along the first pixel unit perpendicular with the direction in which pixel unit is located, the second pixel unit is: the second pixel unit is for one pixel unit in the corresponding pixel units in the image to be processed, and the second edge to be cut is: and the last pixel unit along the direction vertical to the direction of the pixel unit.
5. The method of claim 1 or 2, wherein the pixel cell comprises: rows and/or columns of pixels.
6. An image cropping device, characterized in that it comprises:
the first edge image obtaining module is used for carrying out edge extraction on the image to be processed to obtain a first edge image;
a difference image obtaining module, configured to obtain a difference image formed by a difference value corresponding to each pixel point in the first edge image, where the difference value corresponding to each pixel point represents: the difference of the pixel value between the pixel point and the pixel point within a preset range of the pixel point is as follows: a range along the direction of the pixel unit;
the second edge image obtaining module is used for carrying out edge extraction on the difference image to obtain a second edge image;
a distribution feature obtaining module, configured to obtain a distribution feature of edge pixel points in each pixel unit in the second edge image;
a fuzzy region clipping module, configured to determine, according to the obtained distribution characteristics, a fuzzy region in the image to be processed, where the fuzzy region includes a to-be-clipped edge, and clip and remove the fuzzy region, where the to-be-clipped edge is: and the image to be processed is arranged on the image side in the direction of the pixel unit.
7. The apparatus of claim 6, wherein the difference image obtaining module comprises:
the first difference image obtaining unit is used for calculating a difference value corresponding to each pixel point in the first edge image along the direction of the pixel unit to obtain a first difference image;
a second difference image obtaining unit, configured to calculate a difference value corresponding to each pixel point in the first difference image along a direction in which the pixel unit is located, so as to obtain a second difference image;
a new difference image determining unit, configured to determine the second difference image as a new first difference image, and trigger the second difference image obtaining unit until the number of times of calculating the difference value reaches a preset number of times;
and the difference image determining unit is used for determining the finally obtained second difference image as a difference image formed by the difference value corresponding to each pixel point in the first edge image.
8. The apparatus of claim 6 or 7, wherein the blurred region clipping module comprises:
the change value calculating unit is used for calculating the change value between the distribution characteristics corresponding to every two adjacent pixel units in the second edge image;
the fuzzy region determining unit is used for determining a fuzzy region comprising the edge to be cut in the image to be processed according to the change value obtained by calculation;
and the fuzzy region clipping unit is used for clipping and removing the fuzzy region.
9. The apparatus of claim 8,
the blurred region determining unit is specifically configured to determine, along a direction perpendicular to a direction in which the pixel units are located, a first pixel unit pair in which a variation value between first distribution features in the second edge image is greater than a preset threshold, and a second pixel unit pair in which a variation value between last distribution features in the second edge image is greater than the preset threshold;
determining a region between a first pixel unit and a first edge to be cut in the image to be processed as a fuzzy region, and determining a region between a second pixel unit and a second edge to be cut in the image to be processed as a fuzzy region, wherein the first pixel unit is as follows: the first pixel unit is corresponding to one pixel unit in the pixel units in the image to be processed, and the first edge to be cut is: along the first pixel unit perpendicular with the direction in which pixel unit is located, the second pixel unit is: the second pixel unit is for one pixel unit in the corresponding pixel units in the image to be processed, and the second edge to be cut is: and the last pixel unit along the direction vertical to the direction of the pixel unit.
10. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.
CN201910585564.9A 2019-07-01 2019-07-01 Image clipping method and device Active CN110298858B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910585564.9A CN110298858B (en) 2019-07-01 2019-07-01 Image clipping method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910585564.9A CN110298858B (en) 2019-07-01 2019-07-01 Image clipping method and device

Publications (2)

Publication Number Publication Date
CN110298858A CN110298858A (en) 2019-10-01
CN110298858B true CN110298858B (en) 2021-06-22

Family

ID=68029690

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910585564.9A Active CN110298858B (en) 2019-07-01 2019-07-01 Image clipping method and device

Country Status (1)

Country Link
CN (1) CN110298858B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110929675B (en) * 2019-12-03 2024-03-01 广州酷狗计算机科技有限公司 Image processing method, device, computer equipment and computer readable storage medium
CN111405314B (en) * 2020-03-09 2021-06-15 腾讯科技(深圳)有限公司 Information processing method, device, equipment and storage medium
CN111754487B (en) * 2020-06-24 2023-07-25 北京奇艺世纪科技有限公司 Black frame region cutting method and device and electronic equipment
CN113628229B (en) * 2021-08-04 2022-12-09 展讯通信(上海)有限公司 Image cropping method and related product
CN116542987B (en) * 2023-04-19 2024-06-04 翼存(上海)智能科技有限公司 Image clipping method and device, electronic equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103530878A (en) * 2013-10-12 2014-01-22 北京工业大学 Edge extraction method based on fusion strategy
CN104778669A (en) * 2015-04-16 2015-07-15 北京邮电大学 Fast image denoising method and device
CN104794696A (en) * 2015-05-04 2015-07-22 长沙金定信息技术有限公司 Image motion blur removing method and device
CN106127729A (en) * 2016-06-08 2016-11-16 浙江传媒学院 A kind of picture noise level estimation method based on gradient
WO2018070844A1 (en) * 2016-10-13 2018-04-19 경북대학교 산학협력단 Method for setting edge blur for edge modeling
CN109035158A (en) * 2018-06-25 2018-12-18 东软集团股份有限公司 Image fuzzy processing method, device, storage medium and electronic equipment
CN109934785A (en) * 2019-03-12 2019-06-25 湖南国科微电子股份有限公司 Image sharpening method and device

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8094958B2 (en) * 2006-11-09 2012-01-10 Electronics And Telecommunications Research Institute Apparatus and method for sharpening blurred enlarged image
CN102306377B (en) * 2011-09-21 2013-10-16 深圳市理邦精密仪器股份有限公司 Method and device for reducing noise in ultrasound image
US9280806B2 (en) * 2013-01-10 2016-03-08 Broadcom Corporation Edge smoothing block filtering and blending
CN105374047B (en) * 2015-12-15 2018-04-17 西安电子科技大学 SAR image change detection based on improved bilateral filtering with cluster
KR101877741B1 (en) * 2016-09-27 2018-08-09 청주대학교 산학협력단 Apparatus for detecting edge with image blur
CN107563977A (en) * 2017-08-28 2018-01-09 维沃移动通信有限公司 A kind of image processing method, mobile terminal and computer-readable recording medium
CN108846818B (en) * 2018-06-25 2021-03-02 Oppo(重庆)智能科技有限公司 Moire pattern removing method, device, terminal and computer readable storage medium
CN109523469B (en) * 2018-11-16 2022-12-27 深圳朗田亩半导体科技有限公司 Image scaling method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103530878A (en) * 2013-10-12 2014-01-22 北京工业大学 Edge extraction method based on fusion strategy
CN104778669A (en) * 2015-04-16 2015-07-15 北京邮电大学 Fast image denoising method and device
CN104794696A (en) * 2015-05-04 2015-07-22 长沙金定信息技术有限公司 Image motion blur removing method and device
CN106127729A (en) * 2016-06-08 2016-11-16 浙江传媒学院 A kind of picture noise level estimation method based on gradient
WO2018070844A1 (en) * 2016-10-13 2018-04-19 경북대학교 산학협력단 Method for setting edge blur for edge modeling
CN109035158A (en) * 2018-06-25 2018-12-18 东软集团股份有限公司 Image fuzzy processing method, device, storage medium and electronic equipment
CN109934785A (en) * 2019-03-12 2019-06-25 湖南国科微电子股份有限公司 Image sharpening method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Automated Threshold Driven Edge Detection Using 2-way Difference Calculation and Neighborhood Comparison;Soumyadeep Bhattacharjee 等;《2015 International Conference on Soft Computing Techniques and Implementations- (ICSCTI)》;20151010;122-125 *
基于梯度方向的非局部均值图像去噪算法;苗璐 等;《中北大学学报(自然科学版)》;20180228;第39卷(第1期);69-73 *

Also Published As

Publication number Publication date
CN110298858A (en) 2019-10-01

Similar Documents

Publication Publication Date Title
CN110298858B (en) Image clipping method and device
CN111079772B (en) Image edge extraction processing method, device and storage medium
US9852353B2 (en) Structure aware image denoising and noise variance estimation
CN110708568B (en) Video content mutation detection method and device
CN109446061B (en) Page detection method, computer readable storage medium and terminal device
US10748023B2 (en) Region-of-interest detection apparatus, region-of-interest detection method, and recording medium
CN109741287B (en) Image-oriented filtering method and device
CN110136069B (en) Text image correction method and device and electronic equipment
CN110544214A (en) Image restoration method and device and electronic equipment
CN112580668B (en) Background fraud detection method and device and electronic equipment
CN111882565B (en) Image binarization method, device, equipment and storage medium
JP2021135993A (en) Text recognition method, text recognition apparatus, electronic device, and storage medium
CN110287361B (en) Figure picture screening method and device
CN115619678B (en) Correction method and device for image deformation, computer equipment and storage medium
CN113239738B (en) Image blurring detection method and blurring detection device
CN111160358B (en) Image binarization method, device, equipment and medium
CN112861874A (en) Expert field denoising method and system based on multi-filter denoising result
CN108010020B (en) Silicon wafer slide detection method and device
CN114092925A (en) Video subtitle detection method and device, terminal equipment and storage medium
CN111757182A (en) Image screen-splash detection method, device, computer device and readable storage medium
CN110766644A (en) Image down-sampling method and device
CN113139629A (en) Font identification method and device, electronic equipment and storage medium
CN111754487B (en) Black frame region cutting method and device and electronic equipment
CN112118478B (en) Text processing method and device, electronic equipment and storage medium
CN110660011B (en) Image processing method and device, electronic device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant