WO2018082332A1 - Image processing method and device, and robot - Google Patents

Image processing method and device, and robot Download PDF

Info

Publication number
WO2018082332A1
WO2018082332A1 PCT/CN2017/092029 CN2017092029W WO2018082332A1 WO 2018082332 A1 WO2018082332 A1 WO 2018082332A1 CN 2017092029 W CN2017092029 W CN 2017092029W WO 2018082332 A1 WO2018082332 A1 WO 2018082332A1
Authority
WO
WIPO (PCT)
Prior art keywords
matrix
color
value
image frame
target object
Prior art date
Application number
PCT/CN2017/092029
Other languages
French (fr)
Chinese (zh)
Inventor
刘若鹏
欧阳一村
Original Assignee
深圳光启合众科技有限公司
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 深圳光启合众科技有限公司 filed Critical 深圳光启合众科技有限公司
Publication of WO2018082332A1 publication Critical patent/WO2018082332A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/40Analysis of texture
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics

Definitions

  • the present application relates to the field of images, and in particular to an image processing method and apparatus, and a robot.
  • the monitoring and tracking of target objects is an important part of the research of intelligent video systems. It plays an important role in the fields of technology, military, transportation, security, medical care, etc.
  • the image frames of video are extracted and processed. The results obtained are of low precision and cannot accurately determine the contour of the target object in the video.
  • the embodiment of the present application provides an image processing method and apparatus, and a robot, to at least solve the technical problem that the contour of the target object in the video cannot be accurately determined in the prior art.
  • an image processing method includes: acquiring a color reference value of a target object in a target image frame, wherein the color reference value is a number of occurrences of the target object in a preset area. a color value of a maximum color; acquiring a first region formed by a pixel point in the target image frame that has a difference from the color reference value that is less than or equal to a preset value; using the edge of the first region as the The outline of the target object.
  • acquiring the color reference value of the target object in the target image frame includes: selecting a second region in which the target object is located from the target image frame; and acquiring the pre-predetermined from a center point of the second region A plurality of pixel points in the area are set; a color value corresponding to the color having the most occurrences is searched for from the plurality of pixel points; and a color value corresponding to the color having the most occurrences is used as the color reference value.
  • the edge of the first region as the contour of the target object includes: acquiring a matrix formed by color values of all pixel points in the first region, wherein each element in the matrix represents one pixel a color value of the point; calculating a gradient of the matrix, and calculating an absolute value of the gradient; and mapping an absolute value of the gradient to the target image frame to obtain an outline of the target object.
  • selecting the second region where the target object is located from the target image frame includes: acquiring a third region of the target object in the target coordinate system; mapping coordinates corresponding to the third region to the aims In the image frame, target coordinates are obtained; an area in the target image frame corresponding to the target coordinates is used as the second area.
  • acquiring the third region of the target object in the target coordinate system comprises: acquiring a feature color value of the target object; using a difference between the color value of the target image frame and the feature color value as the first matrix Calculating the third region according to the first matrix.
  • calculating the third region according to the first matrix includes: determining a first coordinate point according to a color value of an element of the first matrix, wherein a color value of the first coordinate point is the first a largest of the elements of the matrix; a rectangular frame centered on the first coordinate point, wherein an average of color values of elements of the edge of the rectangular frame and a color value of an element within the frame of the rectangular frame The average value has a preset value relationship; when the target object is in the rectangular frame, the area where the rectangular frame is located is taken as the third area.
  • each element of the first matrix has three dimensions of red, green, and blue
  • determining the first coordinate point according to the color value of the element of the first matrix includes: each element in the first matrix The color values of the three dimensions of red, green, and blue are added to obtain a second matrix, wherein each element of the second matrix has one dimension; a preset number of peripherals of each element in the second matrix The color values of the elements are averaged, the average value is used as the color value of the elements in the second matrix; and the color values of the elements in the second matrix whose color values are within the first preset range are assigned Zero, a third matrix is obtained; the coordinates of the element having the largest color value in the third matrix are taken as the first coordinate point.
  • adding color values of three dimensions of red, green, and blue of each element in the first matrix to obtain a second matrix includes: red, green, and blue of the first element in the first matrix Multiplying the result of the color values of the three dimensions by the second element in the weight value change matrix to obtain the second matrix, wherein the first element is any one of the elements in the first matrix
  • the coordinates of the second element in the weight value change matrix are the same as the coordinates of the first element in the first matrix, and the weight value change matrix is as follows: Where R c is the uniaxial direction decreasing ratio, (N1 c , N2 c ) is the coordinate of the center point of the image, x is the abscissa of the pixel of the image, and y is the ordinate of the pixel of the image.
  • an image processing apparatus including: a first acquiring unit, configured to acquire a color reference value of a target object in a target image frame, wherein the color reference value is the a color value of the color of the color that is the most frequently occurring in the preset area; the second acquiring unit is configured to obtain a pixel point formed by the difference between the target image frame and the color reference value that is less than or equal to a preset value. a first area; a processing unit, configured to use an edge of the first area as an outline of the target object.
  • the first acquiring unit includes: a selecting subunit, configured to select a second area where the target object is located from the target image frame; and a first acquiring subunit, configured to acquire the second area
  • the central point is a plurality of pixel points in the preset area of the origin;
  • a search subunit is configured to search for color values corresponding to the most frequently occurring color from the plurality of pixel points; and determine a subunit for The color value corresponding to the most frequently occurring color is used as the color reference value.
  • the processing unit includes: a second acquiring subunit, configured to acquire a matrix formed by color values of all pixel points in the first region, where each element in the matrix represents a color of one pixel point a value; a calculation subunit, configured to calculate a gradient of the matrix, and calculate an absolute value of the gradient; a processing subunit configured to correspond an absolute value of the gradient to the target image frame to obtain the target The outline of the object.
  • the selecting subunit includes: an acquiring module, configured to acquire a third area of the target object in a target coordinate system; and a mapping module, configured to map coordinates corresponding to the third area to the target image In the frame, a target coordinate is obtained; and a determining module is configured to use an area in the target image frame corresponding to the target coordinate as the second area.
  • the obtaining module includes: an obtaining submodule, configured to acquire a feature color value of the target object; and a determining submodule, configured to use a difference between a color value of the target image frame and the feature color value as a a matrix; a calculation submodule for calculating the third region according to the first matrix.
  • the calculating submodule includes: a first determining large module, configured to determine a first coordinate point according to a color value of an element of the first matrix, wherein a color value of the first coordinate point is the first a largest of the elements of a matrix; processing a large module for making a rectangular frame centered on the first coordinate point, wherein an average of color values of elements of the edge of the rectangular frame and a frame of the rectangular frame a mean value relationship exists between the average values of the color values of the elements; determining a large module for determining whether the target object is in the rectangular frame; and second determining a large module for when the target object is in the When the rectangle is inside the frame, the area where the rectangular frame is located is taken as the third area.
  • each element of the first matrix has three dimensions of red, green, and blue
  • the first determining large module includes: a first computing small module, configured to use each element in the first matrix The color values of the three dimensions of red, green, and blue are added to obtain a second matrix, wherein each element of the second matrix has one dimension; and a second calculation small module is used for each of the second matrix
  • the color values of the elements of the preset number of elements are averaged, and the average value is used as the color value of the elements in the second matrix; the small module is used to set the color value in the second matrix
  • the color value of the element within a predetermined range is assigned a value of zero to obtain a third matrix; a small module is determined for using the coordinates of the element having the largest color value in the third matrix as the first coordinate point.
  • the first calculation small module is specifically configured to: add a result of adding color values of three dimensions of red, green, and blue of the first element in the first matrix, and a number in the weight value change matrix Multiplying two elements to obtain the second matrix, wherein the first element is any one of the first matrices, and the coordinates of the second element in the weight value change matrix are The coordinates of an element in the first matrix are the same, and the weight value change matrix is as follows: Where R c is the uniaxial direction decreasing ratio, (N1 c , N2 c ) is the coordinate of the center point of the image, x is the abscissa of the pixel of the image, and y is the ordinate of the pixel of the image.
  • a robot comprising: the above image processing apparatus.
  • the pixel point in the target image frame that is equal to or close to the color reference value is regarded as the pixel point of the target object, and the target is acquired.
  • the region where the color value and the color reference value are equal or close to each other the first region
  • the first region is processed, and the edge of the first region is used as the contour of the target object, and the accurate determination is realized.
  • the technical effect of the outline of the target object in the video further solves the technical problem in the prior art that the contour of the target object in the video cannot be accurately determined.
  • FIG. 1 is a flow chart of an image processing method according to an embodiment of the present invention.
  • FIG. 2 is a schematic diagram of a second area in a target image frame in an embodiment of the present invention.
  • FIG. 3 is a schematic view of a center point of a second region in an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a preset area in an embodiment of the present invention.
  • FIG. 5 is a schematic diagram showing the result obtained by clearing the color values of a plurality of pixel points in the second region in the embodiment of the present invention.
  • Figure 6 is a schematic view of a palm outline in an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of an image frame before reducing accuracy and color magnitude in an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of an image frame after reducing accuracy and color magnitude in an embodiment of the present invention.
  • FIG. 9 is a schematic diagram of a second image frame in an embodiment of the present invention.
  • FIG. 10 is a schematic diagram of recursive color values of a first image frame in an embodiment of the present invention.
  • FIG. 11 is a schematic diagram of an image frame in which a color value of a pixel is a first result in an embodiment of the present invention
  • FIG. 12 is a schematic diagram of an image frame in which a color value of a pixel is a second result in an embodiment of the present invention
  • FIG. 13 is a schematic diagram of an image frame corresponding to an absolute value of a gradient of a second color value in an embodiment of the present invention
  • FIG. 14 is a schematic diagram of an image frame corresponding to a gradient of a recursive color value of a first image frame in an embodiment of the present invention
  • FIG. 15 is a schematic diagram of an image frame in which a color value of a pixel is a third result in an embodiment of the present invention.
  • 16 is a schematic diagram of an image frame corresponding to a pixel point storing a preset ratio in an embodiment of the present invention
  • 17 is a schematic diagram of an image frame in which a color value of a pixel is a fourth result in an embodiment of the present invention.
  • FIG. 18 is a schematic diagram of an image frame in which a color value of a pixel point is a fifth result in an embodiment of the present invention.
  • 19 is a schematic diagram of an image frame corresponding to a first matrix calculated by using a second weighting formula in a color value of a pixel in an embodiment of the present invention
  • 20 is a schematic diagram of an image frame represented by a second matrix obtained according to a first matrix in an embodiment of the present invention
  • 21 is a schematic diagram of an image frame obtained after using a weight value change matrix according to an embodiment of the present invention.
  • 22 is a schematic diagram of an image frame after some pixel points are cleared in an embodiment of the present invention.
  • FIG. 23 is a schematic diagram of an image frame obtained by changing a color value of an image frame in an embodiment of the present invention.
  • 24 is a schematic diagram of an image frame obtained by replacing a color value of a pixel point with an average value of color values of peripheral pixel points in an embodiment of the present invention
  • 25 is a schematic diagram of an image frame in which a color value of a pixel point is a third matrix in an embodiment of the present invention.
  • 26 is a schematic diagram of an image frame including a first coordinate point and a color value of a pixel point as a third matrix in an embodiment of the present invention
  • Figure 27 is a schematic view showing the expansion of the rectangular frame to the first range in the embodiment of the present invention.
  • Figure 29 is a schematic view of the embodiment of the present invention after the rectangular frame is removed;
  • FIG. 30 is a schematic diagram of a plurality of rectangular frames in an embodiment of the present invention.
  • FIG. 31 is a schematic diagram of an image frame in a video in which a human fist is a target object according to an embodiment of the present invention
  • 32 is a schematic diagram showing a result obtained by clearing a color value of a plurality of pixel points in a second region when a human fist is used as a target object;
  • Figure 33 is a schematic view showing the outline of a human fist in the embodiment of the present invention.
  • Figure 34 is a schematic diagram of an image processing apparatus according to an embodiment of the present invention.
  • Color value The value of a color in a color mode. For example, when using the RGB color mode, the white color value is (255, 255, 255), the red color value is (255, 0, 0), the green color value is (0, 255, 0), and the blue color value is (0). , 0, 255), the yellow color value is (255, 255, 0), and the black color value is (0, 0, 0).
  • the gradient In the case of a univariate real-valued function, the gradient is the derivative, or, for a linear function, the gradient is the slope of the line.
  • the gradient of the scalar field In vector calculus, the gradient of the scalar field is a vector field. The gradient at a point in the scalar field points to the fastest growing direction of the scalar field, and the length of the gradient is the maximum rate of change.
  • Matrix Gradient Take a 3*3 matrix as an example to illustrate the algorithm of matrix gradient.
  • an embodiment of an image processing method is provided, it being noted that the steps illustrated in the flowchart of the figures may be performed in a computer system such as a set of computer executable instructions, and, although The logical order is shown in the flowcharts, but in some cases the steps shown or described may be performed in a different order than the ones described herein.
  • FIG. 1 is a flowchart of an image processing method according to an embodiment of the present invention. As shown in FIG. 1, the method includes the following steps:
  • Step S102 Acquire a color reference value of the target object in the target image frame, where the color reference value is a color value of a color in which the target object appears most frequently in the preset area.
  • Step S104 Acquire a first region formed by a pixel point in the target image frame whose difference from the color reference value is less than or equal to a preset value.
  • step S106 the edge of the first area is taken as the outline of the target object.
  • the color reference value of the target object is a color value that is very close to the true color of the target object. It can also be said that the color value in the target image frame is equal to or closer to the color reference value (the difference is less than or equal to the preset value).
  • the point is considered to be the pixel of the target object.
  • the first area is a set of pixel points in the target image frame whose difference from the color reference value is less than or equal to a preset value. The edge of the first area is taken as the outline of the target object.
  • the pixel point in the target image frame whose color value is equal to or close to the color reference value is regarded as the pixel point of the target object, and the color value and color in the target image frame are obtained.
  • the region where the reference value is equal or the set of relatively close pixel points (the first region) is processed, and the edge of the first region is used as the contour of the target object, which solves the problem that the target cannot be accurately determined in the prior art.
  • the technical problem of the contour of the object achieves the technical effect of accurately determining the contour of the target object.
  • acquiring the color reference value of the target object in the target image frame includes: selecting a second region where the target object is located from the target image frame; acquiring a plurality of pixels in the preset region with the center point of the second region as an origin Point; finds the color value corresponding to the most frequently occurring color from multiple pixels; uses the color value corresponding to the most frequently occurring color as the color reference value.
  • the preset area may be an area composed of a plurality of pixel points centered on the center point of the second area (the entire area shown in FIG. 2 is the second area) (the black dot in the palm shown in FIG. 3) (eg, In the area where the white box of the center of the palm is shown in FIG. 4, the color value corresponding to the most frequently occurring color is searched from the preset area, and the color value corresponding to the most frequently occurring color is used as the color reference value.
  • the preset area is an area consisting of 81 pixels centered on the center point of the second area, and the color value corresponding to the most frequently occurring color is searched from the 81 pixels, and the color number with the most occurrences will be displayed. The corresponding color value is used as the color reference value.
  • the color value of the pixel in which the difference between the color value and the color reference value in the second region is not in the preset range is cleared, and the result after the clearing is as shown in FIG. 5.
  • using the edge of the first area as the contour of the target object comprises: acquiring a matrix formed by color values of all pixel points in the first area, where each element in the matrix represents a color of one pixel point The value is calculated; the gradient of the matrix is calculated, and the absolute value of the gradient is calculated; the absolute value of the gradient is mapped to the target image frame to obtain the contour of the target object.
  • the matrix composed of the color values of all the pixels in the first region has a fast change in the color value at the edge position of the target object, and the rate of change is large, and the change in the color value at the non-edge position of the target object is slow, and the rate of change is small.
  • the gradient reflects the rate of change of the function
  • the absolute value of the color value of some elements in the matrix obtained by the gradient is small, and another part of the element
  • the absolute value of the color value is large, and the pixel represented by the element having a small absolute value of the color value is the pixel point of the non-edge position of the target object, and the pixel represented by the element having the larger absolute value of the color value is the target.
  • the pixel point at the edge position of the object corresponds to the absolute value of the gradient in the target image frame, thus obtaining the outline of the target object.
  • the matrix formed by the color values of all the pixels in the first region is subjected to a gradient to obtain a matrix, and all the elements of the matrix are taken as absolute values to obtain an absolute value of the gradient, and the absolute value of the gradient is corresponding to the target image frame. , get the outline of the target object, as shown in Figure 6, the white line of the palm edge.
  • Figure 6 is a schematic illustration of the outline of the palm of the embodiment of the present invention.
  • selecting the second region where the target object is located from the target image frame includes: acquiring a third region of the target object in the target coordinate system; mapping the coordinates corresponding to the third region to the target image frame to obtain the target coordinate; The area in the target image frame corresponding to the target coordinates is taken as the second area.
  • the accuracy of the video file can be reduced first, so that the operation speed of the computer can be improved, and the accuracy of the video file can be reduced by selecting one point for every four points in the single axis, that is, the fourth point. , 8th, 12th, and 16th are selected, and other data are ignored.
  • the color value of the video is then reduced (for example, from 256 colors to 64 colors) to facilitate comparison of color differences for different frames.
  • the coordinates of the region are mapped to the target In the image frame, the target coordinates are obtained, and the region in the target image frame indicated by the target coordinates is taken as the second region, and the precision of the target image frame is the same as the accuracy of the original video file.
  • FIG. 7 is a schematic diagram of an image frame before the accuracy and color magnitude are reduced in the embodiment of the present invention
  • FIG. 8 is a schematic diagram of an image frame after reducing the precision and the color magnitude in the embodiment of the present invention.
  • acquiring the third region of the target object in the target coordinate system comprises: acquiring a feature color value of the target object; using a difference between the color value of the target image frame and the feature color value as the first matrix; Three areas.
  • the first matrix may be calculated by using the difference between the color value of the target image frame and the feature color value as the first matrix, that is, subtracting the feature color value from the matrix of the color values of the target image frame.
  • the matrix obtained by the matrix is used as the first matrix.
  • the feature color value can characterize the color of the target object, and the feature color value is significantly different from the color value of the background. Taking the palm of the target object as an example, the characteristic color value of the target object can be defined as the color of the palm: (250, 200, 125) ⁇ (50, 50, 50).
  • a video file is usually composed of a plurality of image frames, and the first image frame and the second image frame are any two adjacent image frames in the same video file.
  • Each image frame is composed of several pixels, and the color value of each pixel constitutes the color value of the image frame.
  • the color value of the pixel in the first image frame is the first color value
  • the color value of the pixel in the second image frame is the second color value.
  • the color values of the image frames can be represented by a matrix.
  • the color value of the image frame Ti is a matrix Mi
  • the elements of the matrix Mi correspond to the color values of each pixel of the image frame Ti. Since the value of the color value is related to the color mode, in order to facilitate the description, in the embodiment of the present invention, the RGB color mode is adopted unless otherwise specified. It should be noted that the image processing method provided by the embodiment of the present invention can also be used in other color modes, and only needs to adjust the size of the color value according to the color mode. When using the RGB color mode, each element of the matrix M1 has three dimensions.
  • the element of the 10th row and the 20th column of the matrix M1 is (255, 255, 0), indicating that the image frame T1 is located at the 10th line and the 20th.
  • the color value of the pixel of the column is (255, 255, 0).
  • the recursive color value of the (N+1)th image frame (N+1th image frame + R* recursive color value of the Nth image frame) / (1+R).
  • R is the preset scale value, and R has a value range of (0, 1). For example, R can take 0.9.
  • the first image frame is the first frame image frame
  • the recursive color value of the first image frame is obtained according to the first color value.
  • the gradient of the recursive color value of the (N+1)th image frame (gradient of the N+1th image frame + R* gradient of the recursive color value of the Nth image frame) / (1 + R).
  • the process of obtaining the first result is: making a difference between the second color value of the second image frame and the recursive color value of the first image frame, and obtaining an absolute value, to obtain a first result.
  • 9 is a schematic diagram of a second image frame in an embodiment of the present invention.
  • Figure 10 is a diagram showing the recursive color values of a first image frame in an embodiment of the present invention.
  • 11 is a schematic diagram of an image frame in which a color value of a pixel is a first result in an embodiment of the present invention.
  • the process of obtaining the second result is: obtaining a difference between the second color value of the second image frame and the recursive color value of the first image frame, obtaining a gradient for the difference, and obtaining an absolute value to obtain a second result.
  • FIG. 12 is a schematic diagram of an image frame in which the color value of a pixel is a second result in the embodiment of the present invention.
  • the process of obtaining the third result is: finding the absolute value of the gradient of the second color value (representing the image as shown in FIG. 13) and the gradient of the recursive color value of the first image frame (the gradient representation of the recursive color value is as shown in the figure). The difference between the images shown in Fig. 14 and the absolute value (indicating the image shown in Fig. 15) is obtained, and a third result is obtained.
  • the process of obtaining the fourth result is: obtaining a gradient matrix of the difference between the second color value and the recursive color value of the first image frame, and saving the preset proportion of elements according to the order of the elements of the gradient matrix, the preservation pre-preservation
  • the gradient of the new gradient matrix after the proportional element is taken to find the absolute value as the fourth result. That is, the difference between the second color value and the recursive color value of the first image frame is a matrix, and the gradient is obtained for the matrix, that is, the gradient matrix of the difference between the second color value and the recursive color value of the first image frame is obtained.
  • the gradient matrix contains multiple elements, which arranges multiple elements from large to small, keeps the elements of the preset ratio unchanged, and the rest are cleared.
  • the preset ratio is the top 10%, and the remaining 90% of the elements are Cleared, after this processing, a new gradient matrix (representing the image shown in Figure 16) is obtained, and the gradient is obtained for the new gradient matrix to obtain another matrix (for convenience of description, using Mt), and the matrix Mt is All elements take an absolute value, resulting in a fourth result (representing the image shown in Figure 17).
  • the process of obtaining the fifth result is that the difference between the first color value and the feature color value of the first image frame is taken as a fifth result (representing the image as shown in FIG. 18).
  • the recursive color value is also a matrix. Since the result of finding the gradient on the matrix is still a matrix, the result of the gradient of the gradient of the matrix is still a matrix, and the addition, subtraction, multiplication, and division of the matrix are performed. The result obtained is still a matrix, so the first result, the second result, the third result, the fourth result, and the fifth result are all matrices.
  • 19 is a schematic diagram of an image frame in which a color value of a pixel is a first matrix in an embodiment of the present invention.
  • calculating the third region according to the first matrix includes: determining a first coordinate point according to a color value of an element of the first matrix, wherein a color value of the first coordinate point is the largest of the elements of the first matrix; A coordinate frame is centered as a rectangular frame, wherein the average value of the color values of the elements of the edge of the rectangular frame has a preset numerical relationship with the average value of the color values of the elements in the frame of the rectangular frame; determining whether the target object is in a rectangular frame Inside; if the target object is inside a rectangular box, use the area where the rectangle is located as the third area.
  • each element of the first matrix has three dimensions of red, green, and blue
  • determining the first coordinate point according to the color value of the element of the first matrix includes: red, green, and each element in the first matrix
  • the color values of the three dimensions of blue are added to obtain a second matrix, wherein each element of the second matrix has one dimension; the color values of the preset number of elements of each element in the second matrix are averaged, Using the average value as the color value of the element in the second matrix; assigning the color value of the element in the second matrix whose color value is within the first preset range to zero, to obtain a third matrix; and maximizing the color value in the third matrix
  • the coordinates of the element are taken as the first coordinate point.
  • the color values of the image frames may be represented by a matrix.
  • the color value of the image frame Ti is a matrix Mi
  • the elements of the matrix Mi correspond to the color values of each pixel of the image frame Ti.
  • each element of the matrix Mi representing the color value of the image frame Ti has three dimensions of red, green, and blue
  • each element of the first matrix also has three dimensions of red, green, and blue.
  • the color values of the three dimensions of red, green, and blue of each element of the first matrix are added to obtain a second matrix (as shown in FIG. 20). The following describes in detail how to obtain the second matrix from the first matrix.
  • the first matrix C1 is a matrix of 3 rows and 4 columns, a total of 12 elements, each of which has three dimensions of red, green and blue.
  • the elements in the second row and the third column of the first matrix C1 are (21, 32, 0), and the values of the elements in the second row and the third column of the first matrix C1 are in the three dimensions of red, green, and blue.
  • Add, that is, add 21, 32, and 0 to obtain 53 that is, the value of the element in the second row and the third column in the second matrix C2 is 53.
  • the calculation of the other elements in the first matrix is the same, and finally the second matrix is obtained.
  • the second matrix C2 is a matrix of 3 rows and 4 columns, a total of 12 elements, each element having only one dimension.
  • the color values of the three dimensions of the first element in the first matrix may be red, green and blue.
  • the result of the addition is multiplied by the second element in the weight value change matrix to obtain a second matrix, wherein the first element is any one of the elements in the first matrix, and the coordinates of the second element in the weight value change matrix
  • the image frame can also be processed by using the following method, for example, the palm of the palm is a large difference between the color of the palm and the color of the black and white. It can be considered that the pixel points in the image frame whose color values are very close to the black and white color values are not the pixels of the image constituting the palm, and therefore, the color values of these pixels can be cleared. Since the black color value is (0, 0, 0) and the white color value is (255, 255, 255), it can be set that when the color value of the element in the second matrix is less than 150 or greater than 675, the element is considered not to constitute a palm. The element of the image, which clears the color value of this element.
  • FIG. 22 is a schematic diagram of an image frame after some pixel points are cleared in the embodiment of the present invention.
  • the color value of the N+1th image frame (after the change) the color value of the N+1th image frame (before the change) +r* The color value of the Nth image frame (already filtered), where r is the preset Proportional value.
  • the color value of the third image frame is compared with the second image.
  • the sum of the filtered color values *r of the frame as the changed color value of the third image frame; after obtaining the color value of the fourth image frame, the color value of the fourth image frame and the third
  • the sum of the filtered color values *r of the image frame as the changed color value of the fourth image frame; after obtaining the color value of the fifth image frame, the color value of the fifth image frame and the fourth
  • 23 is a schematic diagram of an image frame obtained by changing a color value of an image frame in an embodiment of the present invention.
  • Figure 24 is a diagram showing an image frame obtained by replacing the color value of a pixel point with the average value of the color values of the peripheral pixel points in the embodiment of the present invention.
  • the color values of the replaced elements of the replaced second matrix are sorted from large to small, and the elements whose color values are within the first preset range are The color value is assigned a value of zero, and the color value of the element whose color value is not within the first preset range is subtracted from a certain preset value to obtain a third moment.
  • Array is the color value obtained after the image frame is filtered.
  • the first preset range may be that the color values are located 90%, 80%, etc. in the ranking.
  • the first preset range is taken as an example in which the color value is located in the back 80%.
  • the replaced second matrix is a matrix C4
  • all elements of the matrix C4 except the elements of the first row, the first column, the last row, and the last column are sorted according to the color values from large to small, and the color values are
  • the 80% of the elements in the sort are assigned zero, and the two elements of the 20% of the elements in the sort are subtracted from the third element in the sort by 14.11 (the fourth line in matrix C4)
  • the element in column 3) the third element has the smallest difference from the smallest of the two elements.
  • a third matrix C5 is obtained.
  • the image represented by the third matrix is as shown in FIG.
  • the coordinates of the element having the largest color value in the third matrix are taken as the first coordinate point, and the coordinates of the element 2.45 in the third row and the third column in the third matrix are taken as the first coordinate point, and the displayed image is as shown in FIG. Black dots.
  • the number of pixels of an image frame is on the order of thousands or tens of thousands. If the set of color values of the pixels of the image frame is represented by a matrix, the matrix contains thousands or even tens of thousands of elements. The number of rows or columns of this matrix may exceed 100.
  • the use of such a high-order matrix example is very inconvenient, so the method provided by the embodiment of the present invention can only be described by taking a low-order matrix as an example. It should be noted that the method provided by the embodiments of the present invention is completely applicable to the case of a high-order matrix.
  • the first coordinate point is taken as the center for the rectangular frame, and the rectangular frame is expanded from small to large (as shown in FIG. 27), and the expansion of the rectangular frame can be performed in various ways, for example, the first one: the first coordinate point As a center for a rectangular frame, the rectangular frame is expanded from small to large until the average value of the color values of the elements of the edge of the rectangular frame and the average value of the color values of the elements in the frame of the rectangular frame satisfy a preset numerical relationship (for example, The average value of the color values of the elements of the edge of the rectangular frame is equal to the product of the average value of the color values of the elements in the frame of the rectangular frame and a certain preset ratio value. At this time, the expansion of the rectangular frame is stopped.
  • Method 2 The first coordinate point is taken as the center as a rectangular frame, and the rectangular frame is expanded from small to large. During the expansion process, as long as an element whose color value is greater than 0 is found, the rectangular frame is expanded until the rectangular frame contains the element. After the expansion is completed, the rectangular frame is contracted (the contracted image is as shown in FIG. 28) until the average value of the color values of the elements of the edge of the rectangular frame and the average value of the color values of the elements in the frame of the rectangular frame satisfy. Preset numerical relationship.
  • FIG. 29 is a schematic view after the rectangular frame is removed in the embodiment of the present invention. Use the same method to continue looking for the next rectangle.
  • Figure 30 is a schematic illustration of a plurality of rectangular frames in an embodiment of the present invention. If a plurality of rectangular frames are found in total, the average value of the color values of the elements in the frame of each rectangular frame is determined, and the rectangular frame Km having the largest average value of the color values of the elements in the frame is filtered, and then the target object is judged whether In the rectangular box Km.
  • a rectangular frame Km can be obtained according to the image frame T1 and the image frame T2 according to the method provided by the embodiment of the present invention.
  • the rectangular frame Km determined by different adjacent image frames is also different. That is to say, a plurality of different rectangular frames Km can be obtained by processing different adjacent image frames.
  • the target object is in the rectangular frame Km by determining whether the rectangular frame Km satisfies the preset condition.
  • the rectangular frame Km is considered to be a valid rectangular frame, and the position and size information thereof are recorded.
  • the preset condition may be any one or more of the following: (1) the average value of the color values of the elements in the frame of the rectangular frame is greater than a certain preset value; (2) the area of the rectangular frame is in a certain pre- Within the range; (3) the ratio of the length to the height of the rectangular frame is within a certain preset range; (4) the length or height of the rectangular frame is within a certain preset range; (5) the rectangle The total value of the color values of the elements in the box is greater than the average of the total value of the color values of the elements in the existing 10 valid rectangular boxes (for example, 85%); (6) The most frequently occurring occurrences in the rectangular frame The difference between the color value corresponding to the color and the average value of the color value corresponding to the most frequently occurring color in the existing 10 valid rectangular frames is within a certain range.
  • the area in which the rectangular frame Km is located is taken as the third area.
  • the method provided by the embodiment of the present invention can be used to determine the contour of the fist by using an image processing method similar to the target object as a palm.
  • the color reference value of the target object in the target image frame (as shown in FIG. 31) is acquired, where the color reference value is the color value of the color having the most occurrences in the preset area of the target object, for example, the preset area is An area consisting of 81 pixels centered on the center point of the second region, and the color value corresponding to the most frequently occurring color is searched from the 81 pixels, and the color value corresponding to the color having the most occurrence is used as the color. Reference.
  • the color value of the pixel in which the difference between the color value and the color reference value in the second region is not in the preset range is cleared, and the result after the clearing is as shown in FIG.
  • the first region of the pixel in the target image frame whose difference from the color reference value is less than or equal to the preset value is obtained, and the edge of the first region is used as the contour of the target object (as shown in FIG. 33).
  • an image processing apparatus is also provided.
  • the image processing apparatus can execute the image processing method described above, and the image processing method can be implemented by the image processing apparatus.
  • Figure 34 is a schematic diagram of an image processing apparatus according to an embodiment of the present invention. As shown in FIG. 34, the image processing apparatus includes a first acquisition unit 10, a second acquisition unit 20, and a processing unit 30.
  • the first obtaining unit 10 is configured to acquire a color reference value of the target object in the target image frame, where the color reference value is a color value of a color in which the target object appears most frequently in the preset area.
  • the second obtaining unit 20 is configured to acquire a first region formed by a pixel point in the target image frame that has a difference from the color reference value that is less than or equal to a preset value.
  • the processing unit 30 is configured to use an edge of the first area as a contour of the target object.
  • the first obtaining unit 10 uses the color value of the color having the most occurrence as the color reference value, and the pixel point in the target image frame that is equal to or close to the color reference value is regarded as the pixel point of the target object
  • the second acquiring unit 20 Obtaining an area (first area) in which the set of pixel points whose color value is equal to or close to the color reference value in the target image frame
  • the processing unit 30 processes the area where the set is located, and the edge of the first area is used as the target object.
  • the contour solves the technical problem that the contour of the target object cannot be accurately determined in the prior art, and achieves the technical effect of accurately determining the contour of the target object.
  • the first obtaining unit 10 includes: a selecting subunit, configured to select a second area where the target object is located from the target image frame; and a first acquiring subunit, configured to acquire the center point of the second area as an origin a plurality of pixels in the preset area; a search subunit for finding a color value corresponding to the most frequently occurring color from the plurality of pixels; determining a subunit for using the color corresponding to the most frequently occurring color The value is used as a color reference.
  • the processing unit 30 includes: a second acquiring subunit, configured to acquire a matrix formed by color values of all pixel points in the first region, where each element in the matrix represents a color value of one pixel point; a unit for calculating a gradient of the matrix and calculating an absolute value of the gradient; a processing subunit for matching the absolute value of the gradient in the target image frame to obtain an outline of the target object.
  • the selecting subunit includes: an obtaining module, configured to acquire a third area of the target object in the target coordinate system; and a mapping module, configured to map the coordinate corresponding to the third area into the target image frame to obtain the target coordinate; And a determining module, configured to use an area in the target image frame corresponding to the target coordinate as the second area.
  • the obtaining module includes: an obtaining submodule, configured to acquire a feature color value of the target object; and a determining submodule, configured to use a difference between a color value of the target image frame and a color value of the feature as the first matrix; For calculating a third region according to the first matrix.
  • the calculating submodule includes: a first determining large module, configured to determine a first coordinate point according to a color value of an element of the first matrix, wherein a color value of the first coordinate point is the largest of the elements of the first matrix Processing a large module for making a rectangular frame centered on the first coordinate point, wherein the average value of the color values of the elements of the edge of the rectangular frame and the average value of the color values of the elements in the frame of the rectangular frame have a preset value The relationship is determined by determining a large module for determining whether the target object is in a rectangular frame.
  • the second determining large module is configured to use the area where the rectangular frame is located as the third area when the target object is in the rectangular frame.
  • each element of the first matrix has three dimensions of red, green, and blue
  • the first determining large module includes: a first computing small module, configured to red, green, and blue for each element in the first matrix The color values of the three dimensions are added to obtain a second matrix, wherein each element of the second matrix has one dimension; and a second calculation small module is used to preset a predetermined number of elements around each element in the second matrix The color values are averaged, and the average value is used as the color value of the elements in the second matrix; the small module is assigned to assign the color value of the element in the second matrix whose color value is within the first preset range to zero.
  • the first calculation small module is specifically configured to: add a result of adding color values of three dimensions of red, green, and blue of the first element in the first matrix, and the second element in the weight value change matrix Multiply, to obtain a second matrix, wherein the first element is any one of the elements in the first matrix, the coordinates of the second element in the weight value change matrix are the same as the coordinates of the first element in the first matrix, and the weight value change matrix is as follows : Where R c is the uniaxial direction decreasing ratio, (N1 c , N2 c ) is the coordinate of the center point of the image, x is the abscissa of the pixel of the image, and y is the ordinate of the pixel of the image.
  • a robot is also provided.
  • the robot includes the image processing apparatus described above.
  • the first acquiring unit 10 of the image processing apparatus uses the color value of the color having the most occurrence as the color reference value, and the pixel value in the target image frame that is equal to or close to the color reference value is regarded as the pixel point of the target object,
  • the acquiring unit 20 acquires an area (first area) in which the set of pixel points whose color values and color reference values are equal or close to each other in the target image frame, and the processing unit 30 processes the area where the set is located, and the first area is processed.
  • the edge as the contour of the target object solves the technical problem that the contour of the target object cannot be accurately determined in the prior art, and achieves the technical effect of accurately determining the contour of the target object.
  • the disclosed technical contents may be implemented in other manners.
  • the device embodiments described above are only schematic.
  • the division of the unit may be a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or may be Integrate into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, unit or module, and may be electrical or otherwise.
  • the unit described as a separate component may or may not be physically separated as a unit display
  • the components shown may or may not be physical units, ie may be located in one place or may be distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • a computer readable storage medium A number of instructions are included to cause a computer device (which may be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application.
  • the foregoing storage medium includes: a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and the like. .

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

Disclosed are an image processing method and device, and a robot. The method comprises: obtaining a color reference value of a target object in a target image frame, wherein the color reference value is a color value of the color of the target object that occurs most frequently in a preset area; obtaining a first area formed by pixels in the target image frame where the difference between the pixels and the color reference value is less than or equal to a preset value; and using the edge of the first area as the contour of the target object. The present application resolves the technical problem in the prior art of being unable to determine the contour of a target object in a video.

Description

图像处理方法和装置、机器人Image processing method and device, robot 技术领域Technical field
本申请涉及图像领域,具体而言,涉及一种图像处理方法和装置、机器人。The present application relates to the field of images, and in particular to an image processing method and apparatus, and a robot.
背景技术Background technique
目标对象的监测与追踪是智能视频系统研究的重要内容,在科技、军事、交通、安全、医疗等领域都发挥了举足轻重的作用,在现有技术中,对视频的图像帧进行提取以及处理,得到的结果精确度低,无法准确确定视频中的目标对象的轮廓。The monitoring and tracking of target objects is an important part of the research of intelligent video systems. It plays an important role in the fields of technology, military, transportation, security, medical care, etc. In the prior art, the image frames of video are extracted and processed. The results obtained are of low precision and cannot accurately determine the contour of the target object in the video.
针对上述的问题,目前尚未提出有效的解决方案。In response to the above problems, no effective solution has been proposed yet.
发明内容Summary of the invention
本申请实施例提供了一种图像处理方法和装置、机器人,以至少解决现有技术中无法准确确定视频中目标对象的轮廓的技术问题。The embodiment of the present application provides an image processing method and apparatus, and a robot, to at least solve the technical problem that the contour of the target object in the video cannot be accurately determined in the prior art.
根据本申请实施例的一个方面,提供了一种图像处理方法,包括:获取目标图像帧中目标对象的颜色参考值,其中,所述颜色参考值为所述目标对象在预设区域内出现次数最多的颜色的颜色值;获取由所述目标图像帧中与所述颜色参考值的差值小于或者等于预设值的像素点形成的第一区域;将所述第一区域的边缘作为所述目标对象的轮廓。According to an aspect of an embodiment of the present application, an image processing method includes: acquiring a color reference value of a target object in a target image frame, wherein the color reference value is a number of occurrences of the target object in a preset area. a color value of a maximum color; acquiring a first region formed by a pixel point in the target image frame that has a difference from the color reference value that is less than or equal to a preset value; using the edge of the first region as the The outline of the target object.
进一步地,获取目标图像帧中目标对象的颜色参考值包括:从所述目标图像帧中选择所述目标对象所在的第二区域;获取以所述第二区域的中心点为原点的所述预设区域内的多个像素点;从所述多个像素点中查找出现次数最多的颜色所对应的颜色值;将出现次数最多的颜色所对应的颜色值作为所述颜色参考值。Further, acquiring the color reference value of the target object in the target image frame includes: selecting a second region in which the target object is located from the target image frame; and acquiring the pre-predetermined from a center point of the second region A plurality of pixel points in the area are set; a color value corresponding to the color having the most occurrences is searched for from the plurality of pixel points; and a color value corresponding to the color having the most occurrences is used as the color reference value.
进一步地,将所述第一区域的边缘作为所述目标对象的轮廓包括:获取所述第一区域中全部像素点的颜色值所构成的矩阵,其中,所述矩阵中每个元素表示一个像素点的颜色值;计算所述矩阵的梯度,并计算所述梯度的绝对值;将所述梯度的绝对值对应在所述目标图像帧中,得到所述目标对象的轮廓。Further, the edge of the first region as the contour of the target object includes: acquiring a matrix formed by color values of all pixel points in the first region, wherein each element in the matrix represents one pixel a color value of the point; calculating a gradient of the matrix, and calculating an absolute value of the gradient; and mapping an absolute value of the gradient to the target image frame to obtain an outline of the target object.
进一步地,从所述目标图像帧中选择所述目标对象所在的第二区域包括:获取所述目标对象在目标坐标系中的第三区域;将所述第三区域对应的坐标映射到所述目标 图像帧中,得到目标坐标;将所述目标坐标所对应的所述目标图像帧中的区域作为所述第二区域。Further, selecting the second region where the target object is located from the target image frame includes: acquiring a third region of the target object in the target coordinate system; mapping coordinates corresponding to the third region to the aims In the image frame, target coordinates are obtained; an area in the target image frame corresponding to the target coordinates is used as the second area.
进一步地,获取所述目标对象在目标坐标系中的第三区域包括:获取所述目标对象的特征颜色值;将所述目标图像帧的颜色值和所述特征颜色值之差作为第一矩阵;根据所述第一矩阵计算所述第三区域。Further, acquiring the third region of the target object in the target coordinate system comprises: acquiring a feature color value of the target object; using a difference between the color value of the target image frame and the feature color value as the first matrix Calculating the third region according to the first matrix.
进一步地,根据所述第一矩阵计算所述第三区域包括:根据所述第一矩阵的元素的颜色值确定第一坐标点,其中,所述第一坐标点的颜色值是所述第一矩阵的元素中最大的;以所述第一坐标点为中心作矩形框,其中,所述矩形框的边沿的元素的颜色值的平均值与所述矩形框的框内的元素的颜色值的平均值存在预设数值关系;在所述目标对象处于所述矩形框内时,将所述矩形框所在的区域作为所述第三区域。Further, calculating the third region according to the first matrix includes: determining a first coordinate point according to a color value of an element of the first matrix, wherein a color value of the first coordinate point is the first a largest of the elements of the matrix; a rectangular frame centered on the first coordinate point, wherein an average of color values of elements of the edge of the rectangular frame and a color value of an element within the frame of the rectangular frame The average value has a preset value relationship; when the target object is in the rectangular frame, the area where the rectangular frame is located is taken as the third area.
进一步地,所述第一矩阵的每个元素具有红、绿、蓝三个维度,根据所述第一矩阵的元素的颜色值确定第一坐标点包括:将所述第一矩阵中每个元素的红、绿、蓝三个维度的颜色值相加,得到第二矩阵,其中,所述第二矩阵的每个元素具有一个维度;将所述第二矩阵中每个元素的周边预设数量的元素的颜色值求平均值,将所述平均值作为所述第二矩阵中元素的颜色值;将所述第二矩阵中颜色值在第一预设范围之内的元素的颜色值赋值为零,得到第三矩阵;将所述第三矩阵中颜色值最大的元素的坐标作为所述第一坐标点。Further, each element of the first matrix has three dimensions of red, green, and blue, and determining the first coordinate point according to the color value of the element of the first matrix includes: each element in the first matrix The color values of the three dimensions of red, green, and blue are added to obtain a second matrix, wherein each element of the second matrix has one dimension; a preset number of peripherals of each element in the second matrix The color values of the elements are averaged, the average value is used as the color value of the elements in the second matrix; and the color values of the elements in the second matrix whose color values are within the first preset range are assigned Zero, a third matrix is obtained; the coordinates of the element having the largest color value in the third matrix are taken as the first coordinate point.
进一步地,将所述第一矩阵中每个元素的红、绿、蓝三个维度的颜色值相加,得到第二矩阵包括:将所述第一矩阵中第一元素的红、绿、蓝三个维度的颜色值相加得到的结果,与权重值更改矩阵中的第二元素相乘,得到所述第二矩阵,其中,所述第一元素为所述第一矩阵中的任意一个元素,所述第二元素在所述权重值更改矩阵中的坐标与所述第一元素在所述第一矩阵的坐标相同,所述权重值更改矩阵如下:
Figure PCTCN2017092029-appb-000001
其中,Rc为单轴方向下降比例,(N1c,N2c)为图像的中心点的坐标,x为图像的像素点的横坐标,y为图像的像素点的纵坐标。
Further, adding color values of three dimensions of red, green, and blue of each element in the first matrix to obtain a second matrix includes: red, green, and blue of the first element in the first matrix Multiplying the result of the color values of the three dimensions by the second element in the weight value change matrix to obtain the second matrix, wherein the first element is any one of the elements in the first matrix The coordinates of the second element in the weight value change matrix are the same as the coordinates of the first element in the first matrix, and the weight value change matrix is as follows:
Figure PCTCN2017092029-appb-000001
Where R c is the uniaxial direction decreasing ratio, (N1 c , N2 c ) is the coordinate of the center point of the image, x is the abscissa of the pixel of the image, and y is the ordinate of the pixel of the image.
根据本申请实施例的另一方面,还提供了一种图像处理装置,包括:第一获取单元,用于获取目标图像帧中目标对象的颜色参考值,其中,所述颜色参考值为所述目标对象在预设区域内出现次数最多的颜色的颜色值;第二获取单元,用于获取由所述目标图像帧中与所述颜色参考值的差值小于或者等于预设值的像素点形成的第一区域;处理单元,用于将所述第一区域的边缘作为所述目标对象的轮廓。 According to another aspect of the embodiments of the present application, there is provided an image processing apparatus, including: a first acquiring unit, configured to acquire a color reference value of a target object in a target image frame, wherein the color reference value is the a color value of the color of the color that is the most frequently occurring in the preset area; the second acquiring unit is configured to obtain a pixel point formed by the difference between the target image frame and the color reference value that is less than or equal to a preset value. a first area; a processing unit, configured to use an edge of the first area as an outline of the target object.
进一步地,所述第一获取单元包括:选择子单元,用于从所述目标图像帧中选择所述目标对象所在的第二区域;第一获取子单元,用于获取以所述第二区域的中心点为原点的所述预设区域内的多个像素点;查找子单元,用于从所述多个像素点中查找出现次数最多的颜色所对应的颜色值;确定子单元,用于将出现次数最多的颜色所对应的颜色值作为所述颜色参考值。Further, the first acquiring unit includes: a selecting subunit, configured to select a second area where the target object is located from the target image frame; and a first acquiring subunit, configured to acquire the second area The central point is a plurality of pixel points in the preset area of the origin; a search subunit is configured to search for color values corresponding to the most frequently occurring color from the plurality of pixel points; and determine a subunit for The color value corresponding to the most frequently occurring color is used as the color reference value.
进一步地,所述处理单元包括:第二获取子单元,用于获取所述第一区域中全部像素点的颜色值所构成的矩阵,其中,所述矩阵中每个元素表示一个像素点的颜色值;计算子单元,用于计算所述矩阵的梯度,并计算所述梯度的绝对值;处理子单元,用于将所述梯度的绝对值对应在所述目标图像帧中,得到所述目标对象的轮廓。Further, the processing unit includes: a second acquiring subunit, configured to acquire a matrix formed by color values of all pixel points in the first region, where each element in the matrix represents a color of one pixel point a value; a calculation subunit, configured to calculate a gradient of the matrix, and calculate an absolute value of the gradient; a processing subunit configured to correspond an absolute value of the gradient to the target image frame to obtain the target The outline of the object.
进一步地,所述选择子单元包括:获取模块,用于获取所述目标对象在目标坐标系中的第三区域;映射模块,用于将所述第三区域对应的坐标映射到所述目标图像帧中,得到目标坐标;确定模块,用于将所述目标坐标所对应的所述目标图像帧中的区域作为所述第二区域。Further, the selecting subunit includes: an acquiring module, configured to acquire a third area of the target object in a target coordinate system; and a mapping module, configured to map coordinates corresponding to the third area to the target image In the frame, a target coordinate is obtained; and a determining module is configured to use an area in the target image frame corresponding to the target coordinate as the second area.
进一步地,所述获取模块包括:获取子模块,用于获取所述目标对象的特征颜色值;确定子模块,用于将所述目标图像帧的颜色值和所述特征颜色值之差作为第一矩阵;计算子模块,用于根据所述第一矩阵计算所述第三区域。Further, the obtaining module includes: an obtaining submodule, configured to acquire a feature color value of the target object; and a determining submodule, configured to use a difference between a color value of the target image frame and the feature color value as a a matrix; a calculation submodule for calculating the third region according to the first matrix.
进一步地,所述计算子模块包括:第一确定大模块,用于根据所述第一矩阵的元素的颜色值确定第一坐标点,其中,所述第一坐标点的颜色值是所述第一矩阵的元素中最大的;处理大模块,用于以所述第一坐标点为中心作矩形框,其中,所述矩形框的边沿的元素的颜色值的平均值与所述矩形框的框内的元素的颜色值的平均值存在预设数值关系;判断大模块,用于判断所述目标对象是否处于所述矩形框内;第二确定大模块,用于当所述目标对象处于所述矩形框内时,将所述矩形框所在的区域作为所述第三区域。Further, the calculating submodule includes: a first determining large module, configured to determine a first coordinate point according to a color value of an element of the first matrix, wherein a color value of the first coordinate point is the first a largest of the elements of a matrix; processing a large module for making a rectangular frame centered on the first coordinate point, wherein an average of color values of elements of the edge of the rectangular frame and a frame of the rectangular frame a mean value relationship exists between the average values of the color values of the elements; determining a large module for determining whether the target object is in the rectangular frame; and second determining a large module for when the target object is in the When the rectangle is inside the frame, the area where the rectangular frame is located is taken as the third area.
进一步地,所述第一矩阵的每个元素具有红、绿、蓝三个维度,所述第一确定大模块包括:第一计算小模块,用于将所述第一矩阵中每个元素的红、绿、蓝三个维度的颜色值相加,得到第二矩阵,其中,所述第二矩阵的每个元素具有一个维度;第二计算小模块,用于将所述第二矩阵中每个元素的周边预设数量的元素的颜色值求平均值,将所述平均值作为所述第二矩阵中元素的颜色值;赋值小模块,用于将所述第二矩阵中颜色值在第一预设范围之内的元素的颜色值赋值为零,得到第三矩阵;确定小模块,用于将所述第三矩阵中颜色值最大的元素的坐标作为所述第一坐标点。Further, each element of the first matrix has three dimensions of red, green, and blue, and the first determining large module includes: a first computing small module, configured to use each element in the first matrix The color values of the three dimensions of red, green, and blue are added to obtain a second matrix, wherein each element of the second matrix has one dimension; and a second calculation small module is used for each of the second matrix The color values of the elements of the preset number of elements are averaged, and the average value is used as the color value of the elements in the second matrix; the small module is used to set the color value in the second matrix The color value of the element within a predetermined range is assigned a value of zero to obtain a third matrix; a small module is determined for using the coordinates of the element having the largest color value in the third matrix as the first coordinate point.
进一步地,所述第一计算小模块具体用于:将所述第一矩阵中第一元素的红、绿、 蓝三个维度的颜色值相加得到的结果,与权重值更改矩阵中的第二元素相乘,得到所述第二矩阵,其中,所述第一元素为所述第一矩阵中的任意一个元素,所述第二元素在所述权重值更改矩阵中的坐标与所述第一元素在所述第一矩阵的坐标相同,所述权重值更改矩阵如下:
Figure PCTCN2017092029-appb-000002
其中,Rc为单轴方向下降比例,(N1c,N2c)为图像的中心点的坐标,x为图像的像素点的横坐标,y为图像的像素点的纵坐标。
Further, the first calculation small module is specifically configured to: add a result of adding color values of three dimensions of red, green, and blue of the first element in the first matrix, and a number in the weight value change matrix Multiplying two elements to obtain the second matrix, wherein the first element is any one of the first matrices, and the coordinates of the second element in the weight value change matrix are The coordinates of an element in the first matrix are the same, and the weight value change matrix is as follows:
Figure PCTCN2017092029-appb-000002
Where R c is the uniaxial direction decreasing ratio, (N1 c , N2 c ) is the coordinate of the center point of the image, x is the abscissa of the pixel of the image, and y is the ordinate of the pixel of the image.
根据本申请实施例的另一方面,还提供了一种机器人,包括:上述图像处理装置。According to another aspect of an embodiment of the present application, there is also provided a robot comprising: the above image processing apparatus.
在本申请实施例中,通过将出现次数最多的颜色的颜色值作为颜色参考值,将目标图像帧中颜色值与颜色参考值相等或者比较接近的像素点认为是目标对象的像素点,获取目标图像帧中颜色值与颜色参考值相等或者比较接近的像素点的集合所在的区域(第一区域),对第一区域进行处理,将第一区域的边缘作为目标对象的轮廓,实现了准确确定视频中的目标对象的轮廓的技术效果,进而解决了现有技术中无法准确确定视频中目标对象的轮廓的技术问题。In the embodiment of the present application, by using the color value of the color having the most occurrence as the color reference value, the pixel point in the target image frame that is equal to or close to the color reference value is regarded as the pixel point of the target object, and the target is acquired. In the image frame, the region where the color value and the color reference value are equal or close to each other (the first region), the first region is processed, and the edge of the first region is used as the contour of the target object, and the accurate determination is realized. The technical effect of the outline of the target object in the video further solves the technical problem in the prior art that the contour of the target object in the video cannot be accurately determined.
附图说明DRAWINGS
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described herein are intended to provide a further understanding of the present application, and are intended to be a part of this application. In the drawing:
图1是根据本发明实施例的图像处理方法的流程图;1 is a flow chart of an image processing method according to an embodiment of the present invention;
图2是本发明实施例中目标图像帧中第二区域的示意图;2 is a schematic diagram of a second area in a target image frame in an embodiment of the present invention;
图3是本发明实施例中第二区域的中心点的示意图;3 is a schematic view of a center point of a second region in an embodiment of the present invention;
图4是本发明实施例中预设区域的示意图;4 is a schematic diagram of a preset area in an embodiment of the present invention;
图5是本发明实施例中将第二区域内若干像素点的颜色值清零之后得到结果的示意图;FIG. 5 is a schematic diagram showing the result obtained by clearing the color values of a plurality of pixel points in the second region in the embodiment of the present invention; FIG.
图6是本发明实施例中手掌轮廓的示意图;Figure 6 is a schematic view of a palm outline in an embodiment of the present invention;
图7是本发明实施例中降低精度及颜色量值之前的图像帧的示意图;7 is a schematic diagram of an image frame before reducing accuracy and color magnitude in an embodiment of the present invention;
图8是本发明实施例中降低精度及颜色量值之后的图像帧的示意图;8 is a schematic diagram of an image frame after reducing accuracy and color magnitude in an embodiment of the present invention;
图9是本发明实施例中第二图像帧的示意图; 9 is a schematic diagram of a second image frame in an embodiment of the present invention;
图10是本发明实施例中第一图像帧的递推颜色值的示意图;10 is a schematic diagram of recursive color values of a first image frame in an embodiment of the present invention;
图11是本发明实施例中像素点的颜色值为第一结果的图像帧的示意图;11 is a schematic diagram of an image frame in which a color value of a pixel is a first result in an embodiment of the present invention;
图12是本发明实施例中像素点的颜色值为第二结果的图像帧的示意图;12 is a schematic diagram of an image frame in which a color value of a pixel is a second result in an embodiment of the present invention;
图13是本发明实施例中第二颜色值的梯度的绝对值对应的图像帧的示意图;13 is a schematic diagram of an image frame corresponding to an absolute value of a gradient of a second color value in an embodiment of the present invention;
图14是本发明实施例中第一图像帧的递推颜色值的梯度对应的图像帧的示意图;14 is a schematic diagram of an image frame corresponding to a gradient of a recursive color value of a first image frame in an embodiment of the present invention;
图15是本发明实施例中像素点的颜色值为第三结果的图像帧的示意图;15 is a schematic diagram of an image frame in which a color value of a pixel is a third result in an embodiment of the present invention;
图16是本发明实施例中保存预设比例的像素点对应的图像帧的示意图;16 is a schematic diagram of an image frame corresponding to a pixel point storing a preset ratio in an embodiment of the present invention;
图17是本发明实施例中像素点的颜色值为第四结果的图像帧的示意图;17 is a schematic diagram of an image frame in which a color value of a pixel is a fourth result in an embodiment of the present invention;
图18是本发明实施例中像素点的颜色值为第五结果的图像帧的示意图;18 is a schematic diagram of an image frame in which a color value of a pixel point is a fifth result in an embodiment of the present invention;
图19是本发明实施例中像素点的颜色值为使用第二加权公式计算出的第一矩阵对应的图像帧的示意图;19 is a schematic diagram of an image frame corresponding to a first matrix calculated by using a second weighting formula in a color value of a pixel in an embodiment of the present invention;
图20是本发明实施例中根据第一矩阵得到的第二矩阵表示的图像帧的示意图;20 is a schematic diagram of an image frame represented by a second matrix obtained according to a first matrix in an embodiment of the present invention;
图21是本发明实施例使用权重值更改矩阵之后得到的图像帧的示意图;21 is a schematic diagram of an image frame obtained after using a weight value change matrix according to an embodiment of the present invention;
图22是本发明实施例中将一些像素点清零之后的图像帧的示意图;22 is a schematic diagram of an image frame after some pixel points are cleared in an embodiment of the present invention;
图23是本发明实施例中将图像帧的颜色值进行更改后得到的图像帧的示意图;23 is a schematic diagram of an image frame obtained by changing a color value of an image frame in an embodiment of the present invention;
图24是本发明实施例中将像素点的颜色值替换成周边像素点的颜色值的平均值之后得到的图像帧的示意图;24 is a schematic diagram of an image frame obtained by replacing a color value of a pixel point with an average value of color values of peripheral pixel points in an embodiment of the present invention;
图25是本发明实施例中像素点的颜色值为第三矩阵的图像帧的示意图;25 is a schematic diagram of an image frame in which a color value of a pixel point is a third matrix in an embodiment of the present invention;
图26是本发明实施例中包含第一坐标点并且像素点的颜色值为第三矩阵的图像帧的示意图;26 is a schematic diagram of an image frame including a first coordinate point and a color value of a pixel point as a third matrix in an embodiment of the present invention;
图27是本发明实施例中将矩形框扩张至第一范围的示意图;Figure 27 is a schematic view showing the expansion of the rectangular frame to the first range in the embodiment of the present invention;
图28是本发明实施例中将矩形框收缩至第二范围的示意图;28 is a schematic diagram of shrinking a rectangular frame to a second range in an embodiment of the present invention;
图29是本发明实施例中将矩形框清除之后的示意图;Figure 29 is a schematic view of the embodiment of the present invention after the rectangular frame is removed;
图30是本发明实施例中多个矩形框的示意图;30 is a schematic diagram of a plurality of rectangular frames in an embodiment of the present invention;
图31是本发明实施例将人的拳头作为目标对象的视频中的图像帧的示意图; 31 is a schematic diagram of an image frame in a video in which a human fist is a target object according to an embodiment of the present invention;
图32是将人的拳头作为目标对象时,将第二区域内若干像素点的颜色值清零之后得到结果的示意图;32 is a schematic diagram showing a result obtained by clearing a color value of a plurality of pixel points in a second region when a human fist is used as a target object;
图33是本发明实施例中人的拳头的轮廓的示意图;Figure 33 is a schematic view showing the outline of a human fist in the embodiment of the present invention;
图34是根据本发明实施例的图像处理装置的示意图。Figure 34 is a schematic diagram of an image processing apparatus according to an embodiment of the present invention.
具体实施方式detailed description
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。The technical solutions in the embodiments of the present application are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present application. It is an embodiment of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present application without departing from the inventive scope shall fall within the scope of the application.
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or order. It is to be understood that the data so used may be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "comprises" and "comprises" and "the" and "the" are intended to cover a non-exclusive inclusion, for example, a process, method, system, product, or device that comprises a series of steps or units is not necessarily limited to Those steps or units may include other steps or units not explicitly listed or inherent to such processes, methods, products or devices.
首先对本申请实施例所涉及的技术术语作如下解释:First, the technical terms involved in the embodiments of the present application are explained as follows:
颜色值:一种颜色在某种颜色模式中所对应的值。例如,当使用RGB颜色模式时,白色的颜色值为(255,255,255),红色的颜色值为(255,0,0),绿色的颜色值为(0,255,0),蓝色的颜色值为(0,0,255),黄色的颜色值为(255,255,0),黑色的颜色值为(0,0,0)。Color value: The value of a color in a color mode. For example, when using the RGB color mode, the white color value is (255, 255, 255), the red color value is (255, 0, 0), the green color value is (0, 255, 0), and the blue color value is (0). , 0, 255), the yellow color value is (255, 255, 0), and the black color value is (0, 0, 0).
梯度:在单变量的实值函数的情况下,梯度是导数,或者,对于一个线性函数,梯度是线的斜率。在向量微积分中,标量场的梯度是一个向量场。标量场中某一点上的梯度指向标量场增长最快的方向,梯度的长度是这个最大的变化率。Gradient: In the case of a univariate real-valued function, the gradient is the derivative, or, for a linear function, the gradient is the slope of the line. In vector calculus, the gradient of the scalar field is a vector field. The gradient at a point in the scalar field points to the fastest growing direction of the scalar field, and the length of the gradient is the maximum rate of change.
矩阵的梯度:以一个3*3矩阵为例,说明矩阵梯度的算法。 Matrix Gradient: Take a 3*3 matrix as an example to illustrate the algorithm of matrix gradient.
矩阵
Figure PCTCN2017092029-appb-000003
[x,y]=梯度(C),则
Figure PCTCN2017092029-appb-000004
其中,x是矩阵的横向梯度,x的第一列的数值是矩阵C的第二列减去矩阵C的第一列,例如-5=(2-7)/1,x的第二列的数值是矩阵C的第二列减去第一列的值加上第三列减去第二列的值再除以2,例如-3=((2-7)+(1-2))/2。X的最后一列的数值等于矩阵C的最后一列减去倒数第二列的值除以1,例如-1=(1-2)/2。
matrix
Figure PCTCN2017092029-appb-000003
[x,y]=gradient (C), then
Figure PCTCN2017092029-appb-000004
Where x is the lateral gradient of the matrix, and the value of the first column of x is the second column of matrix C minus the first column of matrix C, eg, -5=(2-7)/1, the second column of x The value is the second column of matrix C minus the value of the first column plus the third column minus the value of the second column divided by 2, for example -3=((2-7)+(1-2))/ 2. The value of the last column of X is equal to the last column of matrix C minus the value of the second to last column divided by 1, for example -1 = (1-2)/2.
根据本申请实施例,提供了一种图像处理方法的实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。In accordance with an embodiment of the present application, an embodiment of an image processing method is provided, it being noted that the steps illustrated in the flowchart of the figures may be performed in a computer system such as a set of computer executable instructions, and, although The logical order is shown in the flowcharts, but in some cases the steps shown or described may be performed in a different order than the ones described herein.
图1是根据本发明实施例的图像处理方法的流程图,如图1所示,该方法包括如下步骤:FIG. 1 is a flowchart of an image processing method according to an embodiment of the present invention. As shown in FIG. 1, the method includes the following steps:
步骤S102,获取目标图像帧中目标对象的颜色参考值,其中,颜色参考值为目标对象在预设区域内出现次数最多的颜色的颜色值。Step S102: Acquire a color reference value of the target object in the target image frame, where the color reference value is a color value of a color in which the target object appears most frequently in the preset area.
步骤S104,获取由目标图像帧中与颜色参考值的差值小于或者等于预设值的像素点形成的第一区域。Step S104: Acquire a first region formed by a pixel point in the target image frame whose difference from the color reference value is less than or equal to a preset value.
步骤S106,将第一区域的边缘作为目标对象的轮廓。In step S106, the edge of the first area is taken as the outline of the target object.
目标对象的颜色参考值是很接近目标对象的真实颜色的颜色值的,也可以说,将目标图像帧中颜色值与颜色参考值相等或者比较接近(差值小于或者等于预设值)的像素点认为是目标对象的像素点。第一区域即为目标图像帧中与颜色参考值的差值小于或者等于预设值的像素点集合。将第一区域的边缘作为目标对象的轮廓。The color reference value of the target object is a color value that is very close to the true color of the target object. It can also be said that the color value in the target image frame is equal to or closer to the color reference value (the difference is less than or equal to the preset value). The point is considered to be the pixel of the target object. The first area is a set of pixel points in the target image frame whose difference from the color reference value is less than or equal to a preset value. The edge of the first area is taken as the outline of the target object.
通过将出现次数最多的颜色的颜色值作为颜色参考值,将目标图像帧中颜色值与颜色参考值相等或者比较接近的像素点认为是目标对象的像素点,获取目标图像帧中颜色值与颜色参考值相等或者比较接近的像素点的集合所在的区域(第一区域),对第一区域进行处理,将第一区域的边缘作为目标对象的轮廓,解决了现有技术中无法准确确定出目标对象的轮廓的技术问题,达到了准确确定出目标对象的轮廓的技术效果。By using the color value of the most frequently occurring color as the color reference value, the pixel point in the target image frame whose color value is equal to or close to the color reference value is regarded as the pixel point of the target object, and the color value and color in the target image frame are obtained. The region where the reference value is equal or the set of relatively close pixel points (the first region) is processed, and the edge of the first region is used as the contour of the target object, which solves the problem that the target cannot be accurately determined in the prior art. The technical problem of the contour of the object achieves the technical effect of accurately determining the contour of the target object.
可选地,获取目标图像帧中目标对象的颜色参考值包括:从目标图像帧中选择目标对象所在的第二区域;获取以第二区域的中心点为原点的预设区域内的多个像素点;从多个像素点中查找出现次数最多的颜色所对应的颜色值;将出现次数最多的颜色所对应的颜色值作为颜色参考值。 Optionally, acquiring the color reference value of the target object in the target image frame includes: selecting a second region where the target object is located from the target image frame; acquiring a plurality of pixels in the preset region with the center point of the second region as an origin Point; finds the color value corresponding to the most frequently occurring color from multiple pixels; uses the color value corresponding to the most frequently occurring color as the color reference value.
预设区域可以是以第二区域(图2所示的整个区域为第二区域)的中心点(如图3所示手掌中黑色的圆点)为中心的多个像素点组成的区域(如图4所示的手掌中心的白色方框所在的区域),从预设区域中查找出现次数最多的颜色所对应的颜色值,将出现次数最多的颜色所对应的颜色值作为颜色参考值。例如,预设区域是以第二区域的中心点为中心的81个像素点组成的区域,从这81个像素点中查找出现次数最多的颜色所对应的颜色值,将出现次数最多的颜色所对应的颜色值作为颜色参考值。将第二区域内颜色值与颜色参考值的差不在预设范围的像素点的颜色值清零,清零后的结果如图5所示。The preset area may be an area composed of a plurality of pixel points centered on the center point of the second area (the entire area shown in FIG. 2 is the second area) (the black dot in the palm shown in FIG. 3) (eg, In the area where the white box of the center of the palm is shown in FIG. 4, the color value corresponding to the most frequently occurring color is searched from the preset area, and the color value corresponding to the most frequently occurring color is used as the color reference value. For example, the preset area is an area consisting of 81 pixels centered on the center point of the second area, and the color value corresponding to the most frequently occurring color is searched from the 81 pixels, and the color number with the most occurrences will be displayed. The corresponding color value is used as the color reference value. The color value of the pixel in which the difference between the color value and the color reference value in the second region is not in the preset range is cleared, and the result after the clearing is as shown in FIG. 5.
可选地,将所述第一区域的边缘作为所述目标对象的轮廓包括:获取第一区域中全部像素点的颜色值所构成的矩阵,其中,矩阵中每个元素表示一个像素点的颜色值;计算矩阵的梯度,并计算梯度的绝对值;将梯度的绝对值对应在目标图像帧中,得到目标对象的轮廓。Optionally, using the edge of the first area as the contour of the target object comprises: acquiring a matrix formed by color values of all pixel points in the first area, where each element in the matrix represents a color of one pixel point The value is calculated; the gradient of the matrix is calculated, and the absolute value of the gradient is calculated; the absolute value of the gradient is mapped to the target image frame to obtain the contour of the target object.
第一区域中全部像素点的颜色值所构成的矩阵在目标对象的边缘位置颜色值的变化快,变化率大,而在目标对象的非边缘位置的颜色值的变化慢,变化率小。由于梯度体现函数的变化率,通过对第一区域中全部像素点的颜色值所构成的矩阵求梯度,能够发现求梯度得到的矩阵中的一部分元素的颜色值的绝对值较小,另一部分元素的颜色值的绝对值较大,颜色值的绝对值较小的元素所表示的像素点为目标对象的非边缘位置的像素点,颜色值的绝对值较大的元素所表示的像素点为目标对象的边缘位置的像素点,将梯度的绝对值对应在目标图像帧中,这样就得到了目标对象的轮廓。The matrix composed of the color values of all the pixels in the first region has a fast change in the color value at the edge position of the target object, and the rate of change is large, and the change in the color value at the non-edge position of the target object is slow, and the rate of change is small. Since the gradient reflects the rate of change of the function, by finding the gradient of the matrix formed by the color values of all the pixels in the first region, it can be found that the absolute value of the color value of some elements in the matrix obtained by the gradient is small, and another part of the element The absolute value of the color value is large, and the pixel represented by the element having a small absolute value of the color value is the pixel point of the non-edge position of the target object, and the pixel represented by the element having the larger absolute value of the color value is the target. The pixel point at the edge position of the object corresponds to the absolute value of the gradient in the target image frame, thus obtaining the outline of the target object.
将第一区域中全部像素点的颜色值所构成的矩阵求梯度,得到一个矩阵,将这个矩阵的全部元素取绝对值,得到上述梯度的绝对值,将梯度的绝对值对应在目标图像帧中,得到目标对象的轮廓,如图6所示的手掌边缘的白色线条。图6是本发明实施例中手掌轮廓的示意图。The matrix formed by the color values of all the pixels in the first region is subjected to a gradient to obtain a matrix, and all the elements of the matrix are taken as absolute values to obtain an absolute value of the gradient, and the absolute value of the gradient is corresponding to the target image frame. , get the outline of the target object, as shown in Figure 6, the white line of the palm edge. Figure 6 is a schematic illustration of the outline of the palm of the embodiment of the present invention.
可选地,从目标图像帧中选择目标对象所在的第二区域包括:获取目标对象在目标坐标系中的第三区域;将第三区域对应的坐标映射到目标图像帧中,得到目标坐标;将目标坐标所对应的目标图像帧中的区域作为第二区域。Optionally, selecting the second region where the target object is located from the target image frame includes: acquiring a third region of the target object in the target coordinate system; mapping the coordinates corresponding to the third region to the target image frame to obtain the target coordinate; The area in the target image frame corresponding to the target coordinates is taken as the second area.
在执行上述步骤S102之前,可以先降低视频文件的精度,这样能够提高计算机的运算速度,降低视频文件的精度的方法是:在单轴中每4个点选择1个点出来,即将第4点、第8点、第12点、第16点选择出来,其他数据忽略。再将视频的颜色值降低(例如,由256色降低为64色),以方便比较不同帧的颜色差值。当使用本发明实施例所提供的方法时,需要获取目标对象在低精度的图像帧中的第三区域,将低精度的图像帧的坐标还原为原始图像帧的坐标,即将用于指示第三区域的坐标映射到目标 图像帧中,得到目标坐标,将目标坐标所指示的目标图像帧中的区域作为第二区域,目标图像帧的精度与原始视频文件的精度是相同的。Before performing the above step S102, the accuracy of the video file can be reduced first, so that the operation speed of the computer can be improved, and the accuracy of the video file can be reduced by selecting one point for every four points in the single axis, that is, the fourth point. , 8th, 12th, and 16th are selected, and other data are ignored. The color value of the video is then reduced (for example, from 256 colors to 64 colors) to facilitate comparison of color differences for different frames. When the method provided by the embodiment of the present invention is used, the third region of the target object in the low-precision image frame needs to be acquired, and the coordinates of the low-precision image frame are restored to the coordinates of the original image frame, which is used to indicate the third. The coordinates of the region are mapped to the target In the image frame, the target coordinates are obtained, and the region in the target image frame indicated by the target coordinates is taken as the second region, and the precision of the target image frame is the same as the accuracy of the original video file.
图7是本发明实施例中降低精度及颜色量值之前的图像帧的示意图,图8是本发明实施例中降低精度及颜色量值之后的图像帧的示意图。7 is a schematic diagram of an image frame before the accuracy and color magnitude are reduced in the embodiment of the present invention, and FIG. 8 is a schematic diagram of an image frame after reducing the precision and the color magnitude in the embodiment of the present invention.
可选地,获取目标对象在目标坐标系中的第三区域包括:获取目标对象的特征颜色值;将目标图像帧的颜色值和特征颜色值之差作为第一矩阵;根据第一矩阵计算第三区域。Optionally, acquiring the third region of the target object in the target coordinate system comprises: acquiring a feature color value of the target object; using a difference between the color value of the target image frame and the feature color value as the first matrix; Three areas.
作为一种可选的实施例,可以采用以下方法计算第一矩阵:将目标图像帧的颜色值和特征颜色值之差作为第一矩阵,即将目标图像帧的颜色值的矩阵减去特征颜色值的矩阵得到的矩阵作为第一矩阵。特征颜色值能够表征目标对象的颜色的特征,特征颜色值与背景的颜色值有较大的区别。以目标对象为人的手掌为例,则目标对象的特征颜色值可以定义为手掌的颜色:(250,200,125)±(50,50,50)。As an optional embodiment, the first matrix may be calculated by using the difference between the color value of the target image frame and the feature color value as the first matrix, that is, subtracting the feature color value from the matrix of the color values of the target image frame. The matrix obtained by the matrix is used as the first matrix. The feature color value can characterize the color of the target object, and the feature color value is significantly different from the color value of the background. Taking the palm of the target object as an example, the characteristic color value of the target object can be defined as the color of the palm: (250, 200, 125) ± (50, 50, 50).
作为另一种可选的实施例,也可以使用第一加权公式计算第一矩阵,其中第一加权公式是:第一矩阵=第一系数*第一结果+第二系数*第二结果+第三系数*第三结果+第四系数*第四结果+第五系数*第五结果,其中,第一系数、第二系数、第三系数、第四系数和第五系数中至少一个不等于零。As another optional embodiment, the first matrix may also be calculated using a first weighting formula, where the first weighting formula is: first matrix = first coefficient * first result + second coefficient * second result + first Third coefficient * third result + fourth coefficient * fourth result + fifth coefficient * fifth result, wherein at least one of the first coefficient, the second coefficient, the third coefficient, the fourth coefficient, and the fifth coefficient is not equal to zero.
获取第一结果、第二结果、第三结果、第四结果、第五结果的具体过程在下文有详细说明。The specific process of obtaining the first result, the second result, the third result, the fourth result, and the fifth result is described in detail below.
一个视频文件通常由多个图像帧组成,第一图像帧、第二图像帧为同一个视频文件中任意相邻的两个图像帧。每个图像帧都是由若干个像素点构成的,每个像素点的颜色值即构成了图像帧的颜色值。第一图像帧中的像素点的颜色值为第一颜色值,第二图像帧中的像素点的颜色值为第二颜色值。A video file is usually composed of a plurality of image frames, and the first image frame and the second image frame are any two adjacent image frames in the same video file. Each image frame is composed of several pixels, and the color value of each pixel constitutes the color value of the image frame. The color value of the pixel in the first image frame is the first color value, and the color value of the pixel in the second image frame is the second color value.
一般来说,可以用矩阵表示图像帧的颜色值,例如,图像帧Ti的颜色值为矩阵Mi,矩阵Mi的元素对应着图像帧Ti的每个像素点的颜色值。由于颜色值的取值与颜色模式有关,为了方便叙述,在本发明实施例中,如无特殊说明,均采用RGB颜色模式。需要说明的是,本发明实施例所提供的图像处理方法在其他颜色模式下也能够使用,只需要将颜色值的大小根据颜色模式作调整即可。当采用RGB颜色模式时,矩阵M1的每个元素都有三个维度,例如,矩阵M1的第10行第20列的元素是(255,255,0),则表示图像帧T1中位于第10行第20列的像素点的颜色值是(255,255,0)。In general, the color values of the image frames can be represented by a matrix. For example, the color value of the image frame Ti is a matrix Mi, and the elements of the matrix Mi correspond to the color values of each pixel of the image frame Ti. Since the value of the color value is related to the color mode, in order to facilitate the description, in the embodiment of the present invention, the RGB color mode is adopted unless otherwise specified. It should be noted that the image processing method provided by the embodiment of the present invention can also be used in other color modes, and only needs to adjust the size of the color value according to the color mode. When using the RGB color mode, each element of the matrix M1 has three dimensions. For example, the element of the 10th row and the 20th column of the matrix M1 is (255, 255, 0), indicating that the image frame T1 is located at the 10th line and the 20th. The color value of the pixel of the column is (255, 255, 0).
第N+1图像帧的递推颜色值、第N+1图像帧与第N图像帧的递推颜色值这三者之间存在如下关系: The following relationship exists between the recursive color value of the N+1th image frame, the recursive color value of the N+1th image frame and the Nth image frame:
第N+1图像帧的递推颜色值=(第N+1图像帧+R*第N图像帧的递推颜色值)/(1+R)。R为预设比例值,R的取值范围为(0,1)。例如,R可以取0.9。在第一图像帧为第一帧图像帧时,第一图像帧的递推颜色值根据第一颜色值得到。The recursive color value of the (N+1)th image frame = (N+1th image frame + R* recursive color value of the Nth image frame) / (1+R). R is the preset scale value, and R has a value range of (0, 1). For example, R can take 0.9. When the first image frame is the first frame image frame, the recursive color value of the first image frame is obtained according to the first color value.
对该式的等号的左右两边同时求梯度,得:Find the gradient on both the left and right sides of the equal sign of the equation to obtain:
第N+1图像帧的递推颜色值的梯度=(第N+1图像帧的梯度+R*第N图像帧的递推颜色值的梯度)/(1+R)。The gradient of the recursive color value of the (N+1)th image frame = (gradient of the N+1th image frame + R* gradient of the recursive color value of the Nth image frame) / (1 + R).
Figure PCTCN2017092029-appb-000005
当使用矩阵表示图像的颜色值时,对于矩阵求梯度详见上面说明。
Figure PCTCN2017092029-appb-000005
When using a matrix to represent the color values of an image, the gradient for the matrix is detailed above.
获取第一结果的过程是:将第二图像帧的第二颜色值与第一图像帧的递推颜色值作差,并且求绝对值,得到第一结果。图9是本发明实施例中第二图像帧的示意图。图10是本发明实施例中第一图像帧的递推颜色值的示意图。图11是本发明实施例中像素点的颜色值为第一结果的图像帧的示意图。The process of obtaining the first result is: making a difference between the second color value of the second image frame and the recursive color value of the first image frame, and obtaining an absolute value, to obtain a first result. 9 is a schematic diagram of a second image frame in an embodiment of the present invention. Figure 10 is a diagram showing the recursive color values of a first image frame in an embodiment of the present invention. 11 is a schematic diagram of an image frame in which a color value of a pixel is a first result in an embodiment of the present invention.
获取第二结果的过程是:获取第二图像帧的第二颜色值与第一图像帧的递推颜色值的差值,对差值求梯度,并且求绝对值,得到第二结果。图12是本发明实施例中像素点的颜色值为第二结果的图像帧的示意图。The process of obtaining the second result is: obtaining a difference between the second color value of the second image frame and the recursive color value of the first image frame, obtaining a gradient for the difference, and obtaining an absolute value to obtain a second result. FIG. 12 is a schematic diagram of an image frame in which the color value of a pixel is a second result in the embodiment of the present invention.
获取第三结果的过程是:求第二颜色值的梯度的绝对值(表示如图13所示的图像)与第一图像帧的递推颜色值的梯度(递推颜色值的梯度表示如图14所示的图像)之差,并且求绝对值(表示如图15所示的图像),得到第三结果。The process of obtaining the third result is: finding the absolute value of the gradient of the second color value (representing the image as shown in FIG. 13) and the gradient of the recursive color value of the first image frame (the gradient representation of the recursive color value is as shown in the figure The difference between the images shown in Fig. 14 and the absolute value (indicating the image shown in Fig. 15) is obtained, and a third result is obtained.
获取第四结果的过程是:获取第二颜色值与第一图像帧的递推颜色值之差的梯度矩阵,按照梯度矩阵的元素由大到小的顺序保存预设比例的元素,将保存预设比例的元素之后的新的梯度矩阵的梯度求绝对值,作为第四结果。即,第二颜色值与第一图像帧的递推颜色值之差为一个矩阵,对这个矩阵求梯度,即得到第二颜色值与第一图像帧的递推颜色值之差的梯度矩阵,梯度矩阵中包含多个元素,将多个元素从大到小进行排列,将预设比例的元素保持不变,其余均清零,例如,预设比例为前10%,其余90%的元素均清零,这样处理之后,得到新的梯度矩阵(表示如图16所示的图像),对这个新的梯度矩阵求梯度,得到另一个矩阵(为方便叙述,使用Mt表示),将矩阵Mt中的所有元素取绝对值,得到第四结果(表示如图17所示的图像)。The process of obtaining the fourth result is: obtaining a gradient matrix of the difference between the second color value and the recursive color value of the first image frame, and saving the preset proportion of elements according to the order of the elements of the gradient matrix, the preservation pre-preservation The gradient of the new gradient matrix after the proportional element is taken to find the absolute value as the fourth result. That is, the difference between the second color value and the recursive color value of the first image frame is a matrix, and the gradient is obtained for the matrix, that is, the gradient matrix of the difference between the second color value and the recursive color value of the first image frame is obtained. The gradient matrix contains multiple elements, which arranges multiple elements from large to small, keeps the elements of the preset ratio unchanged, and the rest are cleared. For example, the preset ratio is the top 10%, and the remaining 90% of the elements are Cleared, after this processing, a new gradient matrix (representing the image shown in Figure 16) is obtained, and the gradient is obtained for the new gradient matrix to obtain another matrix (for convenience of description, using Mt), and the matrix Mt is All elements take an absolute value, resulting in a fourth result (representing the image shown in Figure 17).
获取第五结果的过程是:将第一图像帧的第一颜色值和特征颜色值之差作为第五结果(表示如图18所示的图像)。 The process of obtaining the fifth result is that the difference between the first color value and the feature color value of the first image frame is taken as a fifth result (representing the image as shown in FIG. 18).
当使用矩阵表示图像帧的颜色值时,递推颜色值也是一个矩阵,由于对矩阵求梯度的结果仍旧是矩阵,对矩阵的梯度求梯度的结果仍旧是矩阵,对矩阵进行加减乘除运算后得到的结果仍旧是矩阵,因此第一结果、第二结果、第三结果、第四结果和第五结果均为矩阵。When a matrix is used to represent the color value of an image frame, the recursive color value is also a matrix. Since the result of finding the gradient on the matrix is still a matrix, the result of the gradient of the gradient of the matrix is still a matrix, and the addition, subtraction, multiplication, and division of the matrix are performed. The result obtained is still a matrix, so the first result, the second result, the third result, the fourth result, and the fifth result are all matrices.
由于在获取第一结果、第二结果、第三结果、第四结果、第五结果中的任何一个时都存在误差,通过使用多个加权的方法计算第一矩阵,能够降低误差,提高计算第一矩阵的精度值。Since there is an error in acquiring any of the first result, the second result, the third result, the fourth result, and the fifth result, by calculating the first matrix using a plurality of weighting methods, the error can be reduced, and the calculation is improved. The precision value of a matrix.
考虑到将颜色值差的影响平均化,可以使用第二加权公式计算第一矩阵,其中,第二加权公式是:第一矩阵=第一系数*㏒a(第一结果)+第二系数*㏒a(第二结果)+第三系数*㏒a(第三结果)+第四系数*㏒a(第四结果)+第五系数*㏒a(第五结果),其中,a可以取2、e(自然对数的底)、5、10等数值。图19是本发明实施例中像素点的颜色值为第一矩阵的图像帧的示意图。In consideration of averaging the effects of the color value differences, the first matrix may be calculated using a second weighting formula, wherein the second weighting formula is: first matrix = first coefficient *log a (first result) + second coefficient * Log a (second result) + third coefficient * log a (third result) + fourth coefficient * log a (fourth result) + fifth coefficient * log a (fifth result), where a can take 2 , e (the bottom of the natural logarithm), 5, 10 and so on. 19 is a schematic diagram of an image frame in which a color value of a pixel is a first matrix in an embodiment of the present invention.
可选地,根据第一矩阵计算第三区域包括:根据第一矩阵的元素的颜色值确定第一坐标点,其中,第一坐标点的颜色值是第一矩阵的元素中最大的;以第一坐标点为中心作矩形框,其中,矩形框的边沿的元素的颜色值的平均值与矩形框的框内的元素的颜色值的平均值存在预设数值关系;判断目标对象是否处于矩形框内;如果目标对象处于矩形框内,将矩形框所在的区域作为第三区域。Optionally, calculating the third region according to the first matrix includes: determining a first coordinate point according to a color value of an element of the first matrix, wherein a color value of the first coordinate point is the largest of the elements of the first matrix; A coordinate frame is centered as a rectangular frame, wherein the average value of the color values of the elements of the edge of the rectangular frame has a preset numerical relationship with the average value of the color values of the elements in the frame of the rectangular frame; determining whether the target object is in a rectangular frame Inside; if the target object is inside a rectangular box, use the area where the rectangle is located as the third area.
可选地,第一矩阵的每个元素具有红、绿、蓝三个维度,根据第一矩阵的元素的颜色值确定第一坐标点包括:将第一矩阵中每个元素的红、绿、蓝三个维度的颜色值相加,得到第二矩阵,其中,第二矩阵的每个元素具有一个维度;将第二矩阵中每个元素的周边预设数量的元素的颜色值求平均值,将平均值作为第二矩阵中元素的颜色值;将第二矩阵中颜色值在第一预设范围之内的元素的颜色值赋值为零,得到第三矩阵;将第三矩阵中颜色值最大的元素的坐标作为第一坐标点。Optionally, each element of the first matrix has three dimensions of red, green, and blue, and determining the first coordinate point according to the color value of the element of the first matrix includes: red, green, and each element in the first matrix The color values of the three dimensions of blue are added to obtain a second matrix, wherein each element of the second matrix has one dimension; the color values of the preset number of elements of each element in the second matrix are averaged, Using the average value as the color value of the element in the second matrix; assigning the color value of the element in the second matrix whose color value is within the first preset range to zero, to obtain a third matrix; and maximizing the color value in the third matrix The coordinates of the element are taken as the first coordinate point.
如前文所述,可以用矩阵表示图像帧的颜色值,例如,图像帧Ti的颜色值为矩阵Mi,矩阵Mi的元素对应着图像帧Ti的每个像素点的颜色值。当采用RGB颜色模式时,表示图像帧Ti的颜色值的矩阵Mi的每个元素都有红、绿、蓝三个维度,第一矩阵的每个元素也有红、绿、蓝三个维度。在本申请实施例中,将第一矩阵的每个元素的红、绿、蓝三个维度的颜色值相加,得到第二矩阵(如图20所示)。下面详细说明怎样由第一矩阵求得第二矩阵。 As described above, the color values of the image frames may be represented by a matrix. For example, the color value of the image frame Ti is a matrix Mi, and the elements of the matrix Mi correspond to the color values of each pixel of the image frame Ti. When the RGB color mode is adopted, each element of the matrix Mi representing the color value of the image frame Ti has three dimensions of red, green, and blue, and each element of the first matrix also has three dimensions of red, green, and blue. In the embodiment of the present application, the color values of the three dimensions of red, green, and blue of each element of the first matrix are added to obtain a second matrix (as shown in FIG. 20). The following describes in detail how to obtain the second matrix from the first matrix.
例如,当第一矩阵
Figure PCTCN2017092029-appb-000006
时,求第二矩阵C2。第一矩阵C1是一个3行4列的矩阵,一共有12个元素,每个元素都有红、绿、蓝三个维度。其中,第一矩阵C1中第2行第3列的元素是(21,32,0),将第一矩阵C1中第2行第3列的元素在红、绿、蓝三个维度的值相加,即将21、32、0相加,得到53,即第二矩阵C2中第2行第3列的元素的值为53。对第一矩阵中的其他元素进行的计算同理,最后得到第二矩阵
Figure PCTCN2017092029-appb-000007
第二矩阵C2是一个3行4列的矩阵,一共有12个元素,每个元素只有一个维度。
For example, when the first matrix
Figure PCTCN2017092029-appb-000006
When the second matrix C2 is found. The first matrix C1 is a matrix of 3 rows and 4 columns, a total of 12 elements, each of which has three dimensions of red, green and blue. The elements in the second row and the third column of the first matrix C1 are (21, 32, 0), and the values of the elements in the second row and the third column of the first matrix C1 are in the three dimensions of red, green, and blue. Add, that is, add 21, 32, and 0 to obtain 53, that is, the value of the element in the second row and the third column in the second matrix C2 is 53. The calculation of the other elements in the first matrix is the same, and finally the second matrix is obtained.
Figure PCTCN2017092029-appb-000007
The second matrix C2 is a matrix of 3 rows and 4 columns, a total of 12 elements, each element having only one dimension.
为了降低图像帧的周边位置的权重,提升图像帧的中间位置的重要性,作为一种可选的实施例,可以将第一矩阵中第一元素的红、绿、蓝三个维度的颜色值相加得到的结果,与权重值更改矩阵中的第二元素相乘,得到第二矩阵,其中,第一元素为第一矩阵中的任意一个元素,第二元素在权重值更改矩阵中的坐标与第一元素在第一矩阵的坐标相同,权重值更改矩阵如下:
Figure PCTCN2017092029-appb-000008
其中,Rc为单轴方向下降比例,(N1c,N2c)为图像的中心点的坐标,x为图像帧的像素点的横坐标,y为图像帧的像素点的纵坐标。图21是本发明实施例使用权重值更改矩阵之后得到的图像帧的示意图。
In order to reduce the weight of the peripheral position of the image frame and increase the importance of the intermediate position of the image frame, as an optional embodiment, the color values of the three dimensions of the first element in the first matrix may be red, green and blue. The result of the addition is multiplied by the second element in the weight value change matrix to obtain a second matrix, wherein the first element is any one of the elements in the first matrix, and the coordinates of the second element in the weight value change matrix The coordinates of the first element are the same as those of the first element, and the weight value change matrix is as follows:
Figure PCTCN2017092029-appb-000008
Where R c is the uniaxial direction decreasing ratio, (N1 c , N2 c ) is the coordinate of the center point of the image, x is the abscissa of the pixel of the image frame, and y is the ordinate of the pixel of the image frame. 21 is a schematic diagram of an image frame obtained after using a weight value change matrix in an embodiment of the present invention.
当目标对象的各处的颜色值比较接近时,还可以使用下述方法对图像帧进行处理,以目标对象是手掌为例,由于手掌的颜色与黑色、白色的颜色值的差距较大,因此,可以认为,图像帧中那些颜色值与黑色、白色的颜色值非常接近的像素点不是组成手掌的图像的像素点,因此,可以将这些像素点的颜色值清零。由于黑色的颜色值是(0,0,0),白色的颜色值是(255,255,255),可以设定当第二矩阵中元素的颜色值小于150,或者大于675时,认为这个元素不是组成手掌的图像的元素,将这个元素的颜色值清零。图22是本发明实施例中将一些像素点清零之后的图像帧的示意图。When the color values of the target objects are relatively close, the image frame can also be processed by using the following method, for example, the palm of the palm is a large difference between the color of the palm and the color of the black and white. It can be considered that the pixel points in the image frame whose color values are very close to the black and white color values are not the pixels of the image constituting the palm, and therefore, the color values of these pixels can be cleared. Since the black color value is (0, 0, 0) and the white color value is (255, 255, 255), it can be set that when the color value of the element in the second matrix is less than 150 or greater than 675, the element is considered not to constitute a palm. The element of the image, which clears the color value of this element. FIG. 22 is a schematic diagram of an image frame after some pixel points are cleared in the embodiment of the present invention.
然后,使用下一公式对图像帧的颜色值进行更改:Then, use the next formula to change the color value of the image frame:
第N+1图像帧的颜色值(更改后)=第N+1图像帧的颜色值(更改前)+r*第N图像帧的颜色值(已被过滤),其中,r为预设的比例值。The color value of the N+1th image frame (after the change) = the color value of the N+1th image frame (before the change) +r* The color value of the Nth image frame (already filtered), where r is the preset Proportional value.
例如,当得到第3个图像帧的颜色值之后,将第3个图像帧的颜色值与第2个图 像帧的已过滤的颜色值*r的和作为第3个图像帧的更改后的颜色值;当得到第4个图像帧的颜色值之后,将第4个图像帧的颜色值与第3个图像帧的已过滤的颜色值*r的和作为第4个图像帧的更改后的颜色值;当得到第5个图像帧的颜色值之后,将第5个图像帧的颜色值与第4个图像帧的已过滤的颜色值*r的和作为第5个图像帧的更改后的颜色值。For example, when the color value of the third image frame is obtained, the color value of the third image frame is compared with the second image. The sum of the filtered color values *r of the frame as the changed color value of the third image frame; after obtaining the color value of the fourth image frame, the color value of the fourth image frame and the third The sum of the filtered color values *r of the image frame as the changed color value of the fourth image frame; after obtaining the color value of the fifth image frame, the color value of the fifth image frame and the fourth The sum of the filtered color values *r of the image frame as the changed color value of the 5th image frame.
图23是本发明实施例中将图像帧的颜色值进行更改后得到的图像帧的示意图。23 is a schematic diagram of an image frame obtained by changing a color value of an image frame in an embodiment of the present invention.
将第二矩阵中每个元素的周边预设数量的元素的颜色值求平均值,将平均值作为第二矩阵中元素的颜色值,例如预设数量为9时,将以第二矩阵中元素a为中心的3行3列的9个元素的颜色值求平均值,将求得的平均值替换元素a的颜色值。再例如预设数量为25时,将以元素a为中心的5行5列的25个元素的颜色值求平均值,将求得的平均值替换元素a的坐标。Averaging the color values of the preset number of elements of each element in the second matrix, and using the average value as the color value of the elements in the second matrix, for example, when the preset number is 9, the elements in the second matrix will be a is the average of the color values of the nine elements of the three rows and three columns at the center, and replaces the obtained average value with the color value of the element a. Further, for example, when the preset number is 25, the color values of 25 elements of 5 rows and 5 columns centered on the element a are averaged, and the obtained average value is substituted for the coordinates of the element a.
假设矩阵
Figure PCTCN2017092029-appb-000009
将矩阵C3中的每一个元素(注意:第一行、第一列、最后一行和最后一列的元素除外)替换成以该元素为中心的3行3列的元素的颜色值的平均值,然后,将第一行、第一列、最后一行和最后一列的元素的值清零,得到矩阵C4。以矩阵C3中的第3行第3列的元素12为例说明。以该元素12为中心的3行3列的9个元素的颜色值为4、9、15、8、12、11、20、30、40,求这9个颜色值的平均值,得到16.56,因此,矩阵C4的第3行第3列的元素的颜色值为16.56。矩阵C4的其他元素的计算以此类推,最后求得矩阵C4:
Hypothetical matrix
Figure PCTCN2017092029-appb-000009
Replace each element in matrix C3 (except for the elements of the first row, the first column, the last row, and the last column) with the average of the color values of the elements of the 3 rows and 3 columns centered on the element, and then Clear the values of the elements of the first row, the first column, the last row, and the last column to get the matrix C4. The element 12 of the third row and the third column in the matrix C3 is taken as an example. The color values of the nine elements of the three rows and three columns centered on the element 12 are 4, 9, 15, 8, 12, 11, 20, 30, and 40, and the average of the nine color values is obtained to obtain 16.56. Therefore, the color of the elements of the third row and third column of the matrix C4 has a value of 16.56. The calculation of the other elements of the matrix C4 and so on, and finally the matrix C4:
Figure PCTCN2017092029-appb-000010
Figure PCTCN2017092029-appb-000010
图24是本发明实施例中将像素点的颜色值替换成周边像素点的颜色值的平均值之后得到的图像帧的示意图。Figure 24 is a diagram showing an image frame obtained by replacing the color value of a pixel point with the average value of the color values of the peripheral pixel points in the embodiment of the present invention.
在将第二矩阵中的每个元素进行替换之后,将替换后的第二矩阵的替换后的那些元素的颜色值从大到小进行排序,颜色值在第一预设范围之内的元素的颜色值赋值为零,将颜色值不在第一预设范围之内的元素的颜色值减去某一个预设值,得到第三矩 阵。第三矩阵即为图像帧完成过滤后得到的颜色值。After each element in the second matrix is replaced, the color values of the replaced elements of the replaced second matrix are sorted from large to small, and the elements whose color values are within the first preset range are The color value is assigned a value of zero, and the color value of the element whose color value is not within the first preset range is subtracted from a certain preset value to obtain a third moment. Array. The third matrix is the color value obtained after the image frame is filtered.
第一预设范围可以有多个,例如,第一预设范围可以为颜色值在排序中位于后面90%、80%,等。以第一预设范围为颜色值在排序中位于后面80%为例进行说明。假设替换后的第二矩阵为矩阵C4,将矩阵C4中除第一行、第一列、最后一行和最后一列的元素之外的所有元素根据颜色值从大到小进行排序,将颜色值在排序中位于后面80%的元素赋值为零,将颜色值在排序中位于前面20%的元素的2个元素每个元素分别减去排序中的第三个元素14.11(矩阵C4中位于第4行第3列的元素),第三个元素与这两个元素中最小的元素之差最小。得到第三矩阵C5。第三矩阵所表示出的图像如图25所示。There may be multiple first preset ranges. For example, the first preset range may be that the color values are located 90%, 80%, etc. in the ranking. The first preset range is taken as an example in which the color value is located in the back 80%. Assuming that the replaced second matrix is a matrix C4, all elements of the matrix C4 except the elements of the first row, the first column, the last row, and the last column are sorted according to the color values from large to small, and the color values are The 80% of the elements in the sort are assigned zero, and the two elements of the 20% of the elements in the sort are subtracted from the third element in the sort by 14.11 (the fourth line in matrix C4) The element in column 3), the third element has the smallest difference from the smallest of the two elements. A third matrix C5 is obtained. The image represented by the third matrix is as shown in FIG.
Figure PCTCN2017092029-appb-000011
Figure PCTCN2017092029-appb-000011
将第三矩阵中颜色值最大的元素的坐标作为第一坐标点,如第三矩阵中的第3行第3列的元素2.45的坐标作为第一坐标点,显示出的图像如图26中的黑色点。The coordinates of the element having the largest color value in the third matrix are taken as the first coordinate point, and the coordinates of the element 2.45 in the third row and the third column in the third matrix are taken as the first coordinate point, and the displayed image is as shown in FIG. Black dots.
一般情况下,一个图像帧的像素点的个数是以千或者万为数量级的,图像帧的像素点的颜色值的集合如果用矩阵表示,则这个矩阵中包含几千甚至上万个元素,这个矩阵的行的数量或列的数量可能会超过100。但是本发明实施例中,使用如此高阶的矩阵举例子会非常不方便,所以只能以低阶矩阵为例对本发明实施例所提供的方法进行说明。需要注意的是,本发明实施例所提供的方法对高阶矩阵的情况是完全适用的。In general, the number of pixels of an image frame is on the order of thousands or tens of thousands. If the set of color values of the pixels of the image frame is represented by a matrix, the matrix contains thousands or even tens of thousands of elements. The number of rows or columns of this matrix may exceed 100. However, in the embodiment of the present invention, the use of such a high-order matrix example is very inconvenient, so the method provided by the embodiment of the present invention can only be described by taking a low-order matrix as an example. It should be noted that the method provided by the embodiments of the present invention is completely applicable to the case of a high-order matrix.
将第一坐标点作为中心作矩形框,并且对矩形框由小到大进行扩张(如图27所示),对矩形框的扩张可以有多种方式,例如,方式一:将第一坐标点作为中心作矩形框,对矩形框由小到大进行扩张,直至矩形框的边沿的元素的颜色值的平均值与矩形框的框内的元素的颜色值的平均值满足预设数值关系(例如,矩形框的边沿的元素的颜色值的平均值等于矩形框的框内的元素的颜色值的平均值与某个预设比例值的乘积),此时,停止对矩形框的扩张。方式二:将第一坐标点作为中心作矩形框,对矩形框由小到大进行扩张,在扩张过程中,只要发现颜色值大于0的元素,就将矩形框扩张直至矩形框包含该元素。扩张完成后,再对矩形框进行收缩(收缩后的图像如图28所示),直至矩形框的边沿的元素的颜色值的平均值与矩形框的框内的元素的颜色值的平均值满足预设数值关系。The first coordinate point is taken as the center for the rectangular frame, and the rectangular frame is expanded from small to large (as shown in FIG. 27), and the expansion of the rectangular frame can be performed in various ways, for example, the first one: the first coordinate point As a center for a rectangular frame, the rectangular frame is expanded from small to large until the average value of the color values of the elements of the edge of the rectangular frame and the average value of the color values of the elements in the frame of the rectangular frame satisfy a preset numerical relationship (for example, The average value of the color values of the elements of the edge of the rectangular frame is equal to the product of the average value of the color values of the elements in the frame of the rectangular frame and a certain preset ratio value. At this time, the expansion of the rectangular frame is stopped. Method 2: The first coordinate point is taken as the center as a rectangular frame, and the rectangular frame is expanded from small to large. During the expansion process, as long as an element whose color value is greater than 0 is found, the rectangular frame is expanded until the rectangular frame contains the element. After the expansion is completed, the rectangular frame is contracted (the contracted image is as shown in FIG. 28) until the average value of the color values of the elements of the edge of the rectangular frame and the average value of the color values of the elements in the frame of the rectangular frame satisfy. Preset numerical relationship.
当矩形框的扩张(或收缩)完成之后,保存矩形框的中心点、长度和高度等信息, 然后将矩形框清除,图29是本发明实施例中将矩形框清除之后的示意图。使用同样的方法继续找下一个矩形框。图30是本发明实施例中多个矩形框的示意图。假如一共找出多个矩形框,则求每个矩形框的框内的元素的颜色值的平均值,筛选出框内的元素的颜色值的平均值最大的矩形框Km,然后判断目标对象是否处于矩形框Km内。需要注意的是,根据任意相邻的两个图像帧(例如图像帧T1和图像帧T2),都能够根据本发明实施例所提供的方法根据图像帧T1和图像帧T2求得一个矩形框Km。不同的相邻图像帧确定出的矩形框Km也是不同的。也就是说,通过对不同的相邻图像帧的处理,能够得到多个不同的矩形框Km。After the expansion (or contraction) of the rectangular frame is completed, the information such as the center point, length, and height of the rectangular frame is saved. Then, the rectangular frame is cleared, and FIG. 29 is a schematic view after the rectangular frame is removed in the embodiment of the present invention. Use the same method to continue looking for the next rectangle. Figure 30 is a schematic illustration of a plurality of rectangular frames in an embodiment of the present invention. If a plurality of rectangular frames are found in total, the average value of the color values of the elements in the frame of each rectangular frame is determined, and the rectangular frame Km having the largest average value of the color values of the elements in the frame is filtered, and then the target object is judged whether In the rectangular box Km. It should be noted that, according to any two adjacent image frames (for example, the image frame T1 and the image frame T2), a rectangular frame Km can be obtained according to the image frame T1 and the image frame T2 according to the method provided by the embodiment of the present invention. . The rectangular frame Km determined by different adjacent image frames is also different. That is to say, a plurality of different rectangular frames Km can be obtained by processing different adjacent image frames.
可以通过判断矩形框Km是否满足预设条件来判断目标对象是否处于矩形框Km中,当目标对象处于矩形框Km中时,认为矩形框Km是有效矩形框,记录其位置、大小信息。预设条件可以为以下多个中的任意一个或者多个:(1)矩形框的框内的元素的颜色值的平均值大于某个预设值;(2)矩形框的面积在某个预设范围之内;(3)矩形框的长与高之比在某个预设范围之内;(4)矩形框的长或者高的数值大小在某个预设范围之内;(5)矩形框内的元素的颜色值的总值大于已有的10个有效矩形框内的元素的颜色值的总值的平均值的一定比例(例如85%);(6)矩形框内的出现次数最多的颜色所对应的颜色值与已有的10个有效矩形框内的出现次数最多的颜色所对应的颜色值的平均值的差在一定范围之内。It can be determined whether the target object is in the rectangular frame Km by determining whether the rectangular frame Km satisfies the preset condition. When the target object is in the rectangular frame Km, the rectangular frame Km is considered to be a valid rectangular frame, and the position and size information thereof are recorded. The preset condition may be any one or more of the following: (1) the average value of the color values of the elements in the frame of the rectangular frame is greater than a certain preset value; (2) the area of the rectangular frame is in a certain pre- Within the range; (3) the ratio of the length to the height of the rectangular frame is within a certain preset range; (4) the length or height of the rectangular frame is within a certain preset range; (5) the rectangle The total value of the color values of the elements in the box is greater than the average of the total value of the color values of the elements in the existing 10 valid rectangular boxes (for example, 85%); (6) The most frequently occurring occurrences in the rectangular frame The difference between the color value corresponding to the color and the average value of the color value corresponding to the most frequently occurring color in the existing 10 valid rectangular frames is within a certain range.
如果判断出目标对象处于矩形框Km中,将矩形框Km所在的区域作为第三区域。If it is determined that the target object is in the rectangular frame Km, the area in which the rectangular frame Km is located is taken as the third area.
当目标对象是人的拳头时,由于拳头的颜色比较平均,可以采用本发明实施例所提供的方法,利用类似目标对象为手掌的图像处理方法,来确定拳头的轮廓。具体地,获取目标图像帧(如图31所示)中目标对象的颜色参考值,其中,颜色参考值为目标对象的预设区域内出现次数最多的颜色的颜色值,例如,预设区域是以第二区域的中心点为中心的81个像素点组成的区域,从这81个像素点中查找出现次数最多的颜色所对应的颜色值,将出现次数最多的颜色所对应的颜色值作为颜色参考值。将第二区域内颜色值与颜色参考值的差不在预设范围的像素点的颜色值清零,清零后的结果如图32所示。获取目标图像帧中与颜色参考值的差值小于或者等于预设值的像素点的第一区域,将第一区域的边缘作为目标对象的轮廓(如图33所示)。When the target object is a human fist, since the color of the fist is relatively average, the method provided by the embodiment of the present invention can be used to determine the contour of the fist by using an image processing method similar to the target object as a palm. Specifically, the color reference value of the target object in the target image frame (as shown in FIG. 31) is acquired, where the color reference value is the color value of the color having the most occurrences in the preset area of the target object, for example, the preset area is An area consisting of 81 pixels centered on the center point of the second region, and the color value corresponding to the most frequently occurring color is searched from the 81 pixels, and the color value corresponding to the color having the most occurrence is used as the color. Reference. The color value of the pixel in which the difference between the color value and the color reference value in the second region is not in the preset range is cleared, and the result after the clearing is as shown in FIG. The first region of the pixel in the target image frame whose difference from the color reference value is less than or equal to the preset value is obtained, and the edge of the first region is used as the contour of the target object (as shown in FIG. 33).
根据本发明实施例,还提供了一种图像处理装置。该图像处理装置可以执行上述图像处理方法,上述图像处理方法也可以通过该图像处理装置实施。According to an embodiment of the present invention, an image processing apparatus is also provided. The image processing apparatus can execute the image processing method described above, and the image processing method can be implemented by the image processing apparatus.
图34是根据本发明实施例的图像处理装置的示意图。如图34所示,该图像处理装置包括:第一获取单元10、第二获取单元20和处理单元30。 Figure 34 is a schematic diagram of an image processing apparatus according to an embodiment of the present invention. As shown in FIG. 34, the image processing apparatus includes a first acquisition unit 10, a second acquisition unit 20, and a processing unit 30.
第一获取单元10,用于获取目标图像帧中目标对象的颜色参考值,其中,颜色参考值为目标对象在预设区域内出现次数最多的颜色的颜色值。The first obtaining unit 10 is configured to acquire a color reference value of the target object in the target image frame, where the color reference value is a color value of a color in which the target object appears most frequently in the preset area.
第二获取单元20,用于获取由目标图像帧中与颜色参考值的差值小于或者等于预设值的像素点形成的第一区域。The second obtaining unit 20 is configured to acquire a first region formed by a pixel point in the target image frame that has a difference from the color reference value that is less than or equal to a preset value.
处理单元30,用于将第一区域的边缘作为目标对象的轮廓。The processing unit 30 is configured to use an edge of the first area as a contour of the target object.
第一获取单元10将出现次数最多的颜色的颜色值作为颜色参考值,目标图像帧中颜色值与颜色参考值相等或者比较接近的像素点被认为是目标对象的像素点,第二获取单元20获取目标图像帧中颜色值与颜色参考值相等或者比较接近的像素点的集合所在的区域(第一区域),处理单元30对这个集合所在的区域进行处理,将第一区域的边缘作为目标对象的轮廓,解决了现有技术中无法准确确定出目标对象的轮廓的技术问题,达到了准确确定出目标对象的轮廓的技术效果。The first obtaining unit 10 uses the color value of the color having the most occurrence as the color reference value, and the pixel point in the target image frame that is equal to or close to the color reference value is regarded as the pixel point of the target object, and the second acquiring unit 20 Obtaining an area (first area) in which the set of pixel points whose color value is equal to or close to the color reference value in the target image frame, and the processing unit 30 processes the area where the set is located, and the edge of the first area is used as the target object. The contour solves the technical problem that the contour of the target object cannot be accurately determined in the prior art, and achieves the technical effect of accurately determining the contour of the target object.
可选地,第一获取单元10包括:选择子单元,用于从目标图像帧中选择目标对象所在的第二区域;第一获取子单元,用于获取以第二区域的中心点为原点的预设区域内的多个像素点;查找子单元,用于从多个像素点中查找出现次数最多的颜色所对应的颜色值;确定子单元,用于将出现次数最多的颜色所对应的颜色值作为颜色参考值。Optionally, the first obtaining unit 10 includes: a selecting subunit, configured to select a second area where the target object is located from the target image frame; and a first acquiring subunit, configured to acquire the center point of the second area as an origin a plurality of pixels in the preset area; a search subunit for finding a color value corresponding to the most frequently occurring color from the plurality of pixels; determining a subunit for using the color corresponding to the most frequently occurring color The value is used as a color reference.
可选地,处理单元30包括:第二获取子单元,用于获取第一区域中全部像素点的颜色值所构成的矩阵,其中,矩阵中每个元素表示一个像素点的颜色值;计算子单元,用于计算矩阵的梯度,并计算梯度的绝对值;处理子单元,用于将梯度的绝对值对应在目标图像帧中,得到目标对象的轮廓。Optionally, the processing unit 30 includes: a second acquiring subunit, configured to acquire a matrix formed by color values of all pixel points in the first region, where each element in the matrix represents a color value of one pixel point; a unit for calculating a gradient of the matrix and calculating an absolute value of the gradient; a processing subunit for matching the absolute value of the gradient in the target image frame to obtain an outline of the target object.
可选地,选择子单元包括:获取模块,用于获取目标对象在目标坐标系中的第三区域;映射模块,用于将第三区域对应的坐标映射到目标图像帧中,得到目标坐标;确定模块,用于将目标坐标所对应的目标图像帧中的区域作为第二区域。Optionally, the selecting subunit includes: an obtaining module, configured to acquire a third area of the target object in the target coordinate system; and a mapping module, configured to map the coordinate corresponding to the third area into the target image frame to obtain the target coordinate; And a determining module, configured to use an area in the target image frame corresponding to the target coordinate as the second area.
可选地,获取模块包括:获取子模块,用于获取目标对象的特征颜色值;确定子模块,用于将目标图像帧的颜色值和特征颜色值之差作为第一矩阵;计算子模块,用于根据第一矩阵计算第三区域。Optionally, the obtaining module includes: an obtaining submodule, configured to acquire a feature color value of the target object; and a determining submodule, configured to use a difference between a color value of the target image frame and a color value of the feature as the first matrix; For calculating a third region according to the first matrix.
可选地,计算子模块包括:第一确定大模块,用于根据第一矩阵的元素的颜色值确定第一坐标点,其中,第一坐标点的颜色值是第一矩阵的元素中最大的;处理大模块,用于以第一坐标点为中心作矩形框,其中,矩形框的边沿的元素的颜色值的平均值与矩形框的框内的元素的颜色值的平均值存在预设数值关系;判断大模块,用于判断目标对象是否处于矩形框内;第二确定大模块,用于当目标对象处于矩形框内时,将矩形框所在的区域作为第三区域。 Optionally, the calculating submodule includes: a first determining large module, configured to determine a first coordinate point according to a color value of an element of the first matrix, wherein a color value of the first coordinate point is the largest of the elements of the first matrix Processing a large module for making a rectangular frame centered on the first coordinate point, wherein the average value of the color values of the elements of the edge of the rectangular frame and the average value of the color values of the elements in the frame of the rectangular frame have a preset value The relationship is determined by determining a large module for determining whether the target object is in a rectangular frame. The second determining large module is configured to use the area where the rectangular frame is located as the third area when the target object is in the rectangular frame.
可选地,第一矩阵的每个元素具有红、绿、蓝三个维度,第一确定大模块包括:第一计算小模块,用于将第一矩阵中每个元素的红、绿、蓝三个维度的颜色值相加,得到第二矩阵,其中,第二矩阵的每个元素具有一个维度;第二计算小模块,用于将第二矩阵中每个元素的周边预设数量的元素的颜色值求平均值,将平均值作为第二矩阵中元素的颜色值;赋值小模块,用于将第二矩阵中颜色值在第一预设范围之内的元素的颜色值赋值为零,得到第三矩阵;确定小模块,用于将第三矩阵中颜色值最大的元素的坐标作为第一坐标点。Optionally, each element of the first matrix has three dimensions of red, green, and blue, and the first determining large module includes: a first computing small module, configured to red, green, and blue for each element in the first matrix The color values of the three dimensions are added to obtain a second matrix, wherein each element of the second matrix has one dimension; and a second calculation small module is used to preset a predetermined number of elements around each element in the second matrix The color values are averaged, and the average value is used as the color value of the elements in the second matrix; the small module is assigned to assign the color value of the element in the second matrix whose color value is within the first preset range to zero. Obtaining a third matrix; determining a small module for using the coordinates of the element having the largest color value in the third matrix as the first coordinate point.
可选地,第一计算小模块具体用于:将第一矩阵中第一元素的红、绿、蓝三个维度的颜色值相加得到的结果,与权重值更改矩阵中的第二元素相乘,得到第二矩阵,其中,第一元素为第一矩阵中的任意一个元素,第二元素在权重值更改矩阵中的坐标与第一元素在第一矩阵的坐标相同,权重值更改矩阵如下:
Figure PCTCN2017092029-appb-000012
其中,Rc为单轴方向下降比例,(N1c,N2c)为图像的中心点的坐标,x为图像的像素点的横坐标,y为图像的像素点的纵坐标。
Optionally, the first calculation small module is specifically configured to: add a result of adding color values of three dimensions of red, green, and blue of the first element in the first matrix, and the second element in the weight value change matrix Multiply, to obtain a second matrix, wherein the first element is any one of the elements in the first matrix, the coordinates of the second element in the weight value change matrix are the same as the coordinates of the first element in the first matrix, and the weight value change matrix is as follows :
Figure PCTCN2017092029-appb-000012
Where R c is the uniaxial direction decreasing ratio, (N1 c , N2 c ) is the coordinate of the center point of the image, x is the abscissa of the pixel of the image, and y is the ordinate of the pixel of the image.
根据本发明实施例,还提供了一种机器人。该机器人包括上述的图像处理装置。图像处理装置的第一获取单元10将出现次数最多的颜色的颜色值作为颜色参考值,目标图像帧中颜色值与颜色参考值相等或者比较接近的像素点被认为是目标对象的像素点,第二获取单元20获取目标图像帧中颜色值与颜色参考值相等或者比较接近的像素点的集合所在的区域(第一区域),处理单元30对这个集合所在的区域进行处理,将第一区域的边缘作为目标对象的轮廓,解决了现有技术中无法准确确定出目标对象的轮廓的技术问题,达到了准确确定出目标对象的轮廓的技术效果。According to an embodiment of the invention, a robot is also provided. The robot includes the image processing apparatus described above. The first acquiring unit 10 of the image processing apparatus uses the color value of the color having the most occurrence as the color reference value, and the pixel value in the target image frame that is equal to or close to the color reference value is regarded as the pixel point of the target object, The acquiring unit 20 acquires an area (first area) in which the set of pixel points whose color values and color reference values are equal or close to each other in the target image frame, and the processing unit 30 processes the area where the set is located, and the first area is processed. The edge as the contour of the target object solves the technical problem that the contour of the target object cannot be accurately determined in the prior art, and achieves the technical effect of accurately determining the contour of the target object.
在本申请的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above-mentioned embodiments of the present application, the descriptions of the various embodiments are different, and the parts that are not detailed in a certain embodiment can be referred to the related descriptions of other embodiments.
在本申请所提供的几个实施例中,应该理解到,所揭露的技术内容,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,可以为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided by the present application, it should be understood that the disclosed technical contents may be implemented in other manners. The device embodiments described above are only schematic. For example, the division of the unit may be a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or may be Integrate into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, unit or module, and may be electrical or otherwise.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显 示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The unit described as a separate component may or may not be physically separated as a unit display The components shown may or may not be physical units, ie may be located in one place or may be distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。The integrated unit, if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application, in essence or the contribution to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium. A number of instructions are included to cause a computer device (which may be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and the like. .
以上所述仅是本申请的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。 The above description is only a preferred embodiment of the present application, and it should be noted that those skilled in the art can also make several improvements and retouchings without departing from the principles of the present application. It should be considered as the scope of protection of this application.

Claims (17)

  1. 一种图像处理方法,其特征在于,包括:An image processing method, comprising:
    获取目标图像帧中目标对象的颜色参考值,其中,所述颜色参考值为所述目标对象在预设区域内出现次数最多的颜色的颜色值;Obtaining a color reference value of the target object in the target image frame, wherein the color reference value is a color value of a color of the target object having the most occurrences in the preset area;
    获取由所述目标图像帧中与所述颜色参考值的差值小于或者等于预设值的像素点形成的第一区域;Obtaining a first region formed by a pixel point in the target image frame that has a difference from the color reference value that is less than or equal to a preset value;
    将所述第一区域的边缘作为所述目标对象的轮廓。The edge of the first area is taken as the outline of the target object.
  2. 根据权利要求1所述的方法,其特征在于,获取目标图像帧中目标对象的颜色参考值包括:The method according to claim 1, wherein the obtaining a color reference value of the target object in the target image frame comprises:
    从所述目标图像帧中选择所述目标对象所在的第二区域;Selecting a second region in which the target object is located from the target image frame;
    获取以所述第二区域的中心点为原点的所述预设区域内的多个像素点;Acquiring a plurality of pixel points in the preset area with the center point of the second area as an origin;
    从所述多个像素点中查找出现次数最多的颜色所对应的颜色值;Finding a color value corresponding to the color having the most occurrences from the plurality of pixels;
    将出现次数最多的颜色所对应的颜色值作为所述颜色参考值。The color value corresponding to the most frequently occurring color is used as the color reference value.
  3. 根据权利要求2所述的方法,其特征在于,从所述目标图像帧中选择所述目标对象所在的第二区域包括:The method according to claim 2, wherein selecting the second region in which the target object is located from the target image frame comprises:
    获取所述目标对象在目标坐标系中的第三区域;Obtaining a third area of the target object in the target coordinate system;
    将所述第三区域对应的坐标映射到所述目标图像帧中,得到目标坐标;Mapping coordinates corresponding to the third region to the target image frame to obtain target coordinates;
    将所述目标坐标所对应的所述目标图像帧中的区域作为所述第二区域。An area in the target image frame corresponding to the target coordinate is used as the second area.
  4. 根据权利要求3所述的方法,其特征在于,获取所述目标对象在目标坐标系中的第三区域包括:The method according to claim 3, wherein acquiring the third region of the target object in the target coordinate system comprises:
    获取所述目标对象的特征颜色值;Obtaining a feature color value of the target object;
    将所述目标图像帧的颜色值和所述特征颜色值之差作为第一矩阵;Taking a difference between a color value of the target image frame and the feature color value as a first matrix;
    根据所述第一矩阵计算所述第三区域。Calculating the third region according to the first matrix.
  5. 根据权利要求4所述的方法,其特征在于,根据所述第一矩阵计算所述第三区域包括: The method according to claim 4, wherein calculating the third region according to the first matrix comprises:
    根据所述第一矩阵的元素的颜色值确定第一坐标点,其中,所述第一坐标点的颜色值是所述第一矩阵的元素中最大的;Determining a first coordinate point according to a color value of an element of the first matrix, wherein a color value of the first coordinate point is the largest of the elements of the first matrix;
    以所述第一坐标点为中心作矩形框,其中,所述矩形框的边沿的元素的颜色值的平均值与所述矩形框的框内的元素的颜色值的平均值存在预设数值关系;Forming a rectangular frame centering on the first coordinate point, wherein an average value of color values of elements of edges of the rectangular frame has a preset numerical relationship with an average value of color values of elements in the frame of the rectangular frame ;
    在所述目标对象处于所述矩形框内时,将所述矩形框所在的区域作为所述第三区域。When the target object is in the rectangular frame, the area where the rectangular frame is located is taken as the third area.
  6. 根据权利要求5所述的方法,其特征在于,所述第一矩阵的每个元素具有红、绿、蓝三个维度,根据所述第一矩阵的元素的颜色值确定第一坐标点包括:The method according to claim 5, wherein each element of the first matrix has three dimensions of red, green, and blue, and determining the first coordinate point according to the color value of the element of the first matrix includes:
    将所述第一矩阵中每个元素的红、绿、蓝三个维度的颜色值相加,得到第二矩阵,其中,所述第二矩阵的每个元素具有一个维度;Adding color values of three dimensions of red, green, and blue of each element in the first matrix to obtain a second matrix, wherein each element of the second matrix has one dimension;
    将所述第二矩阵中每个元素的周边预设数量的元素的颜色值求平均值,将所述平均值作为所述第二矩阵中元素的颜色值;And averaging color values of a predetermined number of elements of each of the elements in the second matrix, and using the average value as a color value of an element in the second matrix;
    将所述第二矩阵中颜色值在第一预设范围之内的元素的颜色值赋值为零,得到第三矩阵;And assigning a color value of an element of the second matrix whose color value is within a first preset range to zero, to obtain a third matrix;
    将所述第三矩阵中颜色值最大的元素的坐标作为所述第一坐标点。The coordinates of the element having the largest color value in the third matrix are taken as the first coordinate point.
  7. 根据权利要求6所述的方法,其特征在于,将所述第一矩阵中每个元素的红、绿、蓝三个维度的颜色值相加,得到第二矩阵包括:The method according to claim 6, wherein the color values of the three dimensions of red, green and blue of each element in the first matrix are added to obtain a second matrix comprising:
    将所述第一矩阵中第一元素的红、绿、蓝三个维度的颜色值相加得到的结果,与权重值更改矩阵中的第二元素相乘,得到所述第二矩阵,其中,所述第一元素为所述第一矩阵中的任意一个元素,所述第二元素在所述权重值更改矩阵中的坐标与所述第一元素在所述第一矩阵的坐标相同,所述权重值更改矩阵如下:And multiplying a result of adding the color values of the three dimensions of the red, green, and blue colors of the first element in the first matrix, and multiplying the second element in the weight value changing matrix to obtain the second matrix, where The first element is any one of the first matrices, and the coordinates of the second element in the weight value change matrix are the same as the coordinates of the first element in the first matrix, The weight value change matrix is as follows:
    Figure PCTCN2017092029-appb-100001
    其中,Rc为单轴方向下降比例,(N1c,N2c)为图像的中心点的坐标,x为图像的像素点的横坐标,y为图像的像素点的纵坐标。
    Figure PCTCN2017092029-appb-100001
    Where R c is the uniaxial direction decreasing ratio, (N1 c , N2 c ) is the coordinate of the center point of the image, x is the abscissa of the pixel of the image, and y is the ordinate of the pixel of the image.
  8. 根据权利要求1所述的方法,其特征在于,将所述第一区域的边缘作为所述目标对象的轮廓包括:The method according to claim 1, wherein the edge of the first area is used as an outline of the target object comprises:
    获取所述第一区域中全部像素点的颜色值所构成的矩阵,其中,所述矩阵中 每个元素表示一个像素点的颜色值;Obtaining a matrix formed by color values of all pixel points in the first region, wherein the matrix Each element represents the color value of a pixel;
    计算所述矩阵的梯度,并计算所述梯度的绝对值;Calculating a gradient of the matrix and calculating an absolute value of the gradient;
    将所述梯度的绝对值对应在所述目标图像帧中,得到所述目标对象的轮廓。An absolute value of the gradient is mapped in the target image frame to obtain an outline of the target object.
  9. 一种图像处理装置,其特征在于,包括:An image processing apparatus, comprising:
    第一获取单元,用于获取目标图像帧中目标对象的颜色参考值,其中,所述颜色参考值为所述目标对象在预设区域内出现次数最多的颜色的颜色值;a first acquiring unit, configured to acquire a color reference value of the target object in the target image frame, where the color reference value is a color value of a color of the target object having the most occurrences in the preset area;
    第二获取单元,用于获取由所述目标图像帧中与所述颜色参考值的差值小于或者等于预设值的像素点形成的第一区域;a second acquiring unit, configured to acquire a first region formed by a pixel point in the target image frame that is smaller than or equal to a preset value of the color reference value;
    处理单元,用于将所述第一区域的边缘作为所述目标对象的轮廓。And a processing unit, configured to use an edge of the first area as an outline of the target object.
  10. 根据权利要求9所述的装置,其特征在于,所述第一获取单元包括:The device according to claim 9, wherein the first obtaining unit comprises:
    选择子单元,用于从所述目标图像帧中选择所述目标对象所在的第二区域;Selecting a subunit, configured to select a second region in which the target object is located from the target image frame;
    第一获取子单元,用于获取以所述第二区域的中心点为原点的所述预设区域内的多个像素点;a first acquiring subunit, configured to acquire a plurality of pixel points in the preset area with the center point of the second area as an origin;
    查找子单元,用于从所述多个像素点中查找出现次数最多的颜色所对应的颜色值;Locating a subunit for finding a color value corresponding to a color having the most occurrences from the plurality of pixels;
    确定子单元,用于将出现次数最多的颜色所对应的颜色值作为所述颜色参考值。Determining a subunit for using a color value corresponding to the most frequently occurring color as the color reference value.
  11. 根据权利要求10所述的装置,其特征在于,所述选择子单元包括:The apparatus of claim 10 wherein said selecting subunit comprises:
    获取模块,用于获取所述目标对象在目标坐标系中的第三区域;An acquiring module, configured to acquire a third area of the target object in a target coordinate system;
    映射模块,用于将所述第三区域对应的坐标映射到所述目标图像帧中,得到目标坐标;a mapping module, configured to map coordinates corresponding to the third area into the target image frame to obtain target coordinates;
    确定模块,用于将所述目标坐标所对应的所述目标图像帧中的区域作为所述第二区域。And a determining module, configured to use an area in the target image frame corresponding to the target coordinate as the second area.
  12. 根据权利要求11所述的装置,其特征在于,所述获取模块包括:The device according to claim 11, wherein the obtaining module comprises:
    获取子模块,用于获取所述目标对象的特征颜色值;Obtaining a submodule, configured to acquire a feature color value of the target object;
    确定子模块,用于将所述目标图像帧的颜色值和所述特征颜色值之差作为第一矩阵; a determining submodule, configured to use a difference between a color value of the target image frame and the feature color value as a first matrix;
    计算子模块,用于根据所述第一矩阵计算所述第三区域。a calculation submodule for calculating the third region according to the first matrix.
  13. 根据权利要求12所述的装置,其特征在于,所述计算子模块包括:The device according to claim 12, wherein the calculation sub-module comprises:
    第一确定大模块,用于根据所述第一矩阵的元素的颜色值确定第一坐标点,其中,所述第一坐标点的颜色值是所述第一矩阵的元素中最大的;a first determining large module, configured to determine a first coordinate point according to a color value of an element of the first matrix, wherein a color value of the first coordinate point is the largest of the elements of the first matrix;
    处理大模块,用于以所述第一坐标点为中心作矩形框,其中,所述矩形框的边沿的元素的颜色值的平均值与所述矩形框的框内的元素的颜色值的平均值存在预设数值关系;Processing a large module for making a rectangular frame centering on the first coordinate point, wherein an average of color values of elements of edges of the rectangular frame and an average of color values of elements in the frame of the rectangular frame The value has a preset numerical relationship;
    判断大模块,用于判断所述目标对象是否处于所述矩形框内;Determining a large module, configured to determine whether the target object is in the rectangular frame;
    第二确定大模块,用于当所述目标对象处于所述矩形框内时,将所述矩形框所在的区域作为所述第三区域。And a second determining large module, configured to: when the target object is in the rectangular frame, use an area where the rectangular frame is located as the third area.
  14. 根据权利要求13所述的装置,其特征在于,所述第一矩阵的每个元素具有红、绿、蓝三个维度,所述第一确定大模块包括:The device according to claim 13, wherein each element of the first matrix has three dimensions of red, green and blue, and the first determining large module comprises:
    第一计算小模块,用于将所述第一矩阵中每个元素的红、绿、蓝三个维度的颜色值相加,得到第二矩阵,其中,所述第二矩阵的每个元素具有一个维度;a first calculation small module, configured to add color values of three dimensions of red, green, and blue of each element in the first matrix to obtain a second matrix, wherein each element of the second matrix has One dimension
    第二计算小模块,用于将所述第二矩阵中每个元素的周边预设数量的元素的颜色值求平均值,将所述平均值作为所述第二矩阵中元素的颜色值;a second calculation small module, configured to average a color value of a predetermined number of elements of each of the elements in the second matrix, and use the average value as a color value of an element in the second matrix;
    赋值小模块,用于将所述第二矩阵中颜色值在第一预设范围之内的元素的颜色值赋值为零,得到第三矩阵;An assignment small module, configured to assign a color value of an element of the second matrix whose color value is within a first preset range to zero, to obtain a third matrix;
    确定小模块,用于将所述第三矩阵中颜色值最大的元素的坐标作为所述第一坐标点。Determining a small module for using the coordinates of the element having the largest color value in the third matrix as the first coordinate point.
  15. 根据权利要求14所述的装置,其特征在于,所述第一计算小模块具体用于:The device according to claim 14, wherein the first computing module is specifically configured to:
    将所述第一矩阵中第一元素的红、绿、蓝三个维度的颜色值相加得到的结果,与权重值更改矩阵中的第二元素相乘,得到所述第二矩阵,其中,所述第一元素为所述第一矩阵中的任意一个元素,所述第二元素在所述权重值更改矩阵中的坐标与所述第一元素在所述第一矩阵的坐标相同,所述权重值更改矩阵如下:And multiplying a result of adding the color values of the three dimensions of the red, green, and blue colors of the first element in the first matrix, and multiplying the second element in the weight value changing matrix to obtain the second matrix, where The first element is any one of the first matrices, and the coordinates of the second element in the weight value change matrix are the same as the coordinates of the first element in the first matrix, The weight value change matrix is as follows:
    Figure PCTCN2017092029-appb-100002
    其中,Rc为单轴方向下降比例,(N1c,N2c)为图像的中心点的坐标,x为图像的像素点的横坐标,y为图像的像素 点的纵坐标。
    Figure PCTCN2017092029-appb-100002
    Where R c is the uniaxial direction decreasing ratio, (N1 c , N2 c ) is the coordinate of the center point of the image, x is the abscissa of the pixel of the image, and y is the ordinate of the pixel of the image.
  16. 根据权利要求9所述的装置,其特征在于,所述处理单元包括:The device according to claim 9, wherein the processing unit comprises:
    第二获取子单元,用于获取所述第一区域中全部像素点的颜色值所构成的矩阵,其中,所述矩阵中每个元素表示一个像素点的颜色值;a second acquiring subunit, configured to acquire a matrix formed by color values of all pixel points in the first region, where each element in the matrix represents a color value of one pixel point;
    计算子单元,用于计算所述矩阵的梯度,并计算所述梯度的绝对值;Calculating a subunit for calculating a gradient of the matrix and calculating an absolute value of the gradient;
    处理子单元,用于将所述梯度的绝对值对应在所述目标图像帧中,得到所述目标对象的轮廓。Processing subunits for mapping an absolute value of the gradient in the target image frame to obtain an outline of the target object.
  17. 一种机器人,其特征在于,包括:权利要求9至16任一项所述的图像处理装置。 A robot comprising the image processing apparatus according to any one of claims 9 to 16.
PCT/CN2017/092029 2016-11-07 2017-07-06 Image processing method and device, and robot WO2018082332A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610975741.0 2016-11-07
CN201610975741.0A CN108090924B (en) 2016-11-07 2016-11-07 Image processing method and device and robot

Publications (1)

Publication Number Publication Date
WO2018082332A1 true WO2018082332A1 (en) 2018-05-11

Family

ID=62075683

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/092029 WO2018082332A1 (en) 2016-11-07 2017-07-06 Image processing method and device, and robot

Country Status (2)

Country Link
CN (1) CN108090924B (en)
WO (1) WO2018082332A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110033500A (en) * 2018-12-29 2019-07-19 北京金山安全软件有限公司 Graph filling method and device and electronic equipment
CN111582290A (en) * 2020-05-13 2020-08-25 郑州轻工业大学 Computer image recognition method
CN111612857A (en) * 2020-05-28 2020-09-01 北京学之途网络科技有限公司 Color obtaining method and device, electronic equipment and readable storage medium
CN111860192A (en) * 2020-06-24 2020-10-30 国网宁夏电力有限公司检修公司 Moving object identification method and system
CN112862917A (en) * 2019-11-28 2021-05-28 西安四维图新信息技术有限公司 Map acquisition method and device
CN113190455A (en) * 2021-05-13 2021-07-30 统信软件技术有限公司 Element positioning method and computing equipment

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110774283A (en) * 2019-10-29 2020-02-11 龙岩学院 Robot walking control system and method based on computer vision
CN110889882B (en) * 2019-11-11 2023-05-30 北京皮尔布莱尼软件有限公司 Picture synthesis method and computing device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101699511A (en) * 2009-10-30 2010-04-28 深圳创维数字技术股份有限公司 Color image segmentation method and system
CN102136068A (en) * 2011-03-31 2011-07-27 中国科学院半导体研究所 Average grey-based method for extracting effective information region of range gating image
WO2012147844A1 (en) * 2011-04-27 2012-11-01 日本電気株式会社 Recognition/search method for object/form, system for same, and program for same
CN105205832A (en) * 2015-08-31 2015-12-30 清华大学深圳研究生院 Moving object detection method
CN105741230A (en) * 2016-01-29 2016-07-06 宇龙计算机通信科技(深圳)有限公司 Image processing method and mobile terminal

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101699511A (en) * 2009-10-30 2010-04-28 深圳创维数字技术股份有限公司 Color image segmentation method and system
CN102136068A (en) * 2011-03-31 2011-07-27 中国科学院半导体研究所 Average grey-based method for extracting effective information region of range gating image
WO2012147844A1 (en) * 2011-04-27 2012-11-01 日本電気株式会社 Recognition/search method for object/form, system for same, and program for same
CN105205832A (en) * 2015-08-31 2015-12-30 清华大学深圳研究生院 Moving object detection method
CN105741230A (en) * 2016-01-29 2016-07-06 宇龙计算机通信科技(深圳)有限公司 Image processing method and mobile terminal

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110033500A (en) * 2018-12-29 2019-07-19 北京金山安全软件有限公司 Graph filling method and device and electronic equipment
CN110033500B (en) * 2018-12-29 2023-09-22 北京金山安全软件有限公司 Graph filling method and device and electronic equipment
CN112862917A (en) * 2019-11-28 2021-05-28 西安四维图新信息技术有限公司 Map acquisition method and device
CN111582290A (en) * 2020-05-13 2020-08-25 郑州轻工业大学 Computer image recognition method
CN111582290B (en) * 2020-05-13 2023-04-07 郑州轻工业大学 Computer image recognition method
CN111612857A (en) * 2020-05-28 2020-09-01 北京学之途网络科技有限公司 Color obtaining method and device, electronic equipment and readable storage medium
CN111612857B (en) * 2020-05-28 2024-03-26 北京明略昭辉科技有限公司 Color acquisition method and device, electronic equipment and readable storage medium
CN111860192A (en) * 2020-06-24 2020-10-30 国网宁夏电力有限公司检修公司 Moving object identification method and system
CN113190455A (en) * 2021-05-13 2021-07-30 统信软件技术有限公司 Element positioning method and computing equipment
CN113190455B (en) * 2021-05-13 2024-06-07 统信软件技术有限公司 Element positioning method and computing equipment

Also Published As

Publication number Publication date
CN108090924B (en) 2020-03-10
CN108090924A (en) 2018-05-29

Similar Documents

Publication Publication Date Title
WO2018082332A1 (en) Image processing method and device, and robot
US10803554B2 (en) Image processing method and device
US7480419B2 (en) Image signal processing
US11445214B2 (en) Determining variance of a block of an image based on a motion vector for the block
US8818136B2 (en) Image interpolation method based on matrix and image processing system
EP2908287B1 (en) Image segmentation device, image segmentation method, and depth map generating method
US8594445B2 (en) Fast bilateral filtering using rectangular regions
US9275447B2 (en) Method and system for describing image region based on color histogram
CN108022244B (en) Hypergraph optimization method for significant target detection based on foreground and background seeds
KR20170109898A (en) Apparatus and method for extracting object
US20070070365A1 (en) Content-based image retrieval based on color difference and gradient information
JP6830712B1 (en) Random sampling Consistency-based effective area extraction method for fisheye images
KR100323364B1 (en) A method for extracting characterized vectors in color image and a retrieval method using the characterized vectors
Zheng et al. Study on image retrieval based on image texture and color statistical projection
WO2018082331A1 (en) Image processing method and device, and robot
You et al. The technique of color and shape-based multi-feature combination of trademark image retrieval
US8380006B2 (en) System and method for merging separated pixel blocks into an integral image of an object
JP2003216948A (en) Representative color extraction device and representative color extraction program
WO2019205527A1 (en) Method and apparatus for determining gray-scale values of display panel
CN109829361B (en) Image processing method, robot and device applying same
KR101546200B1 (en) Method and Device for Matching Correspondaence Point of Multi Spectral Images
CN108268533A (en) A kind of Image Feature Matching method for image retrieval
KR101981773B1 (en) Apparatus and method of edge localization based on adaptive weighting of gradients
Hsu et al. Low memory cost bilateral filtering using stripe-based sliding integral histogram
Zheng et al. Applied study on image retrievals based on statistics projection algorithm and Robert algorithm

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17868429

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 18.10.2019)

122 Ep: pct application non-entry in european phase

Ref document number: 17868429

Country of ref document: EP

Kind code of ref document: A1