CN110660029B - Image processing method, device, equipment and storage medium - Google Patents

Image processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN110660029B
CN110660029B CN201910863227.1A CN201910863227A CN110660029B CN 110660029 B CN110660029 B CN 110660029B CN 201910863227 A CN201910863227 A CN 201910863227A CN 110660029 B CN110660029 B CN 110660029B
Authority
CN
China
Prior art keywords
pixel
pixels
inquired
queried
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910863227.1A
Other languages
Chinese (zh)
Other versions
CN110660029A (en
Inventor
陈海波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Deep Blue Technology Shanghai Co Ltd
Original Assignee
Deep Blue Technology Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Deep Blue Technology Shanghai Co Ltd filed Critical Deep Blue Technology Shanghai Co Ltd
Priority to CN201910863227.1A priority Critical patent/CN110660029B/en
Publication of CN110660029A publication Critical patent/CN110660029A/en
Application granted granted Critical
Publication of CN110660029B publication Critical patent/CN110660029B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation

Landscapes

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

Abstract

The embodiment of the invention provides an image processing method, an image processing device, image processing equipment and a storage medium, which are used for solving the technical problem of low image processing efficiency in the prior art. The method comprises the following steps: selecting a pixel matrix corresponding to an M-N neighborhood in an image; determining a first pixel; comparing the pixel value of each pixel in the pixel matrix with the pixel value of the first pixel; dividing M x N pixels in the pixel matrix into at least two pixel sets according to the comparison result; determining a set where a pixel to be queried is located from at least two pixel sets; and determining the pixels to be inquired in the set where the pixels to be inquired are located, and processing the image based on the pixels to be inquired.

Description

Image processing method, device, equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an image processing method, an image processing apparatus, an image processing device, and a storage medium.
Background
Currently, when a user uses an electronic device such as a mobile phone, a tablet, or a camera to shoot an image, due to human factors (e.g., human jitter during shooting), environmental factors (e.g., poor light), and the like, the effect of the shot image is poor, and therefore, post-processing of the image, such as noise reduction processing of the image using a median filtering mode, is often required. In addition, the background blurring processing can be performed on the image to highlight the foreground in the image, so that a wonderful visual effect is provided for a user.
However, when performing noise reduction or blurring processing on an image, it is generally necessary to determine a specific pixel value by a bubble sorting or quick sorting method and then process the image according to the specific pixel value. However, the bubble sorting or quick sorting calculation mode is complex, and the data processing amount is large, so that the image processing efficiency is not high, and the power consumption of the electronic equipment is large.
Disclosure of Invention
The embodiment of the application provides an image processing method, an image processing device, image processing equipment and a storage medium, which are used for solving the technical problem of low image processing efficiency in the prior art.
In a first aspect, an embodiment of the present application provides an image processing method, including:
selecting a pixel matrix corresponding to an M-N neighborhood in the image; determining a first pixel, comparing the pixel value of each pixel in the pixel matrix with the pixel value of the first pixel, and dividing M × N pixels in the pixel matrix into at least two pixel sets according to the comparison result;
determining a set where a pixel to be queried is located from the at least two pixel sets; the pixel to be inquired is a pixel at the Q-th position after M x N pixels in the pixel matrix are sequenced from small to large according to the pixel values, and Q is a positive integer;
and determining the pixel to be inquired in the set where the pixel to be inquired is positioned, and processing the image based on the pixel to be inquired.
According to the embodiment of the invention, one pixel is randomly selected or self-defined from the pixel matrix, the pixel value of the pixel is compared with the pixel value of each pixel in the pixel matrix, all pixels in the pixel matrix are subjected to set division according to the comparison size, then the set where the pixel to be inquired is located is determined, and finally the pixel to be inquired is determined from the set where the pixel to be inquired is located. The method can find the pixels to be inquired without sequencing all the pixels from small to large, and can reduce the total times of comparing the sizes of the pixels compared with the method of sequencing all the pixel values in the pixel matrix from small to large by using bubble sequencing or quick sequencing in the prior art, so that the data processing amount is smaller, the pixel searching efficiency is higher, the image processing efficiency can be improved, and the power consumption of electronic equipment can be saved.
Optionally, determining the first pixel includes: the first pixel is any one selected from the pixel matrix or is a self-defined pixel.
By the embodiment of the invention, the first pixel can be determined.
Optionally, determining a set where the pixel to be queried is located from the at least two pixel sets includes: and determining the set where the pixel to be inquired is located according to the number of pixels contained in each of the at least two pixel sets and the value of Q.
By the embodiment of the invention, the set where the pixel to be inquired is located can be quickly determined.
Optionally, determining the pixel to be queried in the set where the pixel to be queried is located includes: sequencing all pixels in the set of the pixels to be queried according to the sequence of the pixel values of the pixels from small to large to obtain a first pixel sequence; and determining the position of the pixel to be inquired in the first pixel sequence according to the value of Q, and acquiring the pixel to be inquired from the position.
By the embodiment of the invention, the pixels to be inquired can be determined only by sequencing the pixels in the set where the pixels to be inquired are located, and all the pixels do not need to be sequenced, so that the pixel searching efficiency can be improved.
Optionally, determining the pixel to be queried in the set where the pixel to be queried is located includes: judging whether the set of the pixels to be inquired meets a preset condition or not; the preset condition is that the pixel values of all pixels in the set where the pixel to be inquired is located are all the same or the number of the pixels is 1; if yes, determining all pixels in the set where the pixels to be inquired are located as pixels to be inquired; otherwise, continuing to select a second pixel from the set where the pixel to be queried is located, wherein the second pixel is any one pixel in the set where the pixel to be queried is located; comparing the pixel value of each pixel except the second pixel in the set of the pixels to be inquired with the pixel value of the second pixel; according to the comparison result, further dividing the pixels in the set of the pixels to be inquired into at least two pixel sets; determining a pixel set where a pixel to be queried is located from the at least two newly divided pixel sets until the determined pixel set meets the preset condition; and determining all pixels in the pixel set meeting the preset condition as pixels to be inquired.
According to the embodiment of the invention, the pixel is subjected to set division, and the range of the pixel to be inquired is gradually reduced by adopting the preset condition, so that the searching efficiency of the pixel can be further improved.
Optionally, dividing M × N pixels in the pixel matrix into at least two pixel sets according to the comparison result, including: dividing pixels of the M x N pixels having pixel values smaller than the pixel value of the first pixel into a first set; dividing pixels of the M x N pixels having pixel values equal to pixel values of the first pixel into a second set; dividing pixels of the M x N pixels having pixel values greater than the pixel value of the first pixel into a third set.
According to the embodiment of the invention, the set in which the pixel to be inquired is located is divided into three sets with size relations by using the pixel value of any one pixel, and the searching range of the pixel to be inquired can be reduced by the three sets, so that the pixel searching efficiency is improved.
Optionally, after processing the image based on the pixel to be queried, the method further includes: replacing the pixel value of the pixel at the middle position on the pixel matrix corresponding to the M-N field by the pixel value of the pixel to be inquired; or replacing the pixel values of the pixels at all positions in the pixel matrix corresponding to the M-N field with the pixel values of the pixels to be inquired.
Optionally, Q ═ N + 1)/2.
Compared with the prior art that the noise reduction or blurring processing is realized by sequencing all pixel values in the pixel matrix from small to large by using bubble sequencing or quick sequencing, the embodiment of the invention can reduce the total times of comparing the pixel sizes, so that the data processing amount is smaller, the pixel searching efficiency is higher, the noise reduction or blurring processing efficiency of the image can be improved, and the power consumption of electronic equipment is saved.
In a second aspect, the present embodiment provides an image processing apparatus comprising: the selection module is used for selecting a pixel matrix corresponding to an M x N neighborhood in the image; determining a first pixel; a judging module, configured to compare a pixel value of each pixel in the pixel matrix with a pixel value of the first pixel; dividing M x N pixels in the pixel matrix into at least two pixel sets according to a comparison result; the determining module is used for determining a set where the pixel to be inquired is located from the at least two pixel sets; the pixel value of the pixel to be inquired is the pixel value of the Q-th pixel of M × N pixels in the pixel matrix, wherein the Q is a positive integer; determining the pixel to be queried in the set where the pixel to be queried is located; and the processing module is used for processing the image based on the pixel to be inquired.
Optionally, when determining the first pixel, the determining module is specifically configured to: any one pixel selected from the pixel matrix, or a custom one pixel.
Optionally, when the determining module determines the set in which the pixel to be queried is located from the at least two pixel sets, the determining module is specifically configured to: and determining the set where the pixel to be inquired is located according to the number of pixels contained in each of the at least two pixel sets and the value of Q.
Optionally, when the determining module determines the pixel to be queried in the set where the pixel to be queried is located, the determining module is specifically configured to: sequencing all pixels in the set of the pixels to be queried according to the sequence of the pixel values of the pixels from small to large to obtain a first pixel sequence; determining the position of the pixel to be queried in the first pixel sequence according to the value of Q, and acquiring the pixel to be queried from the position; or
Judging whether the set of the pixels to be inquired meets a preset condition or not; the preset condition is that the pixel values of all pixels in the set where the pixel to be inquired is located are all the same or the number of the pixels is 1; if so, determining all pixels in the set where the pixels to be queried are located as pixels to be queried; otherwise, continuing to select a second pixel from the set where the pixel to be queried is located, wherein the second pixel is any one pixel in the set where the pixel to be queried is located; comparing the pixel value of each pixel except the second pixel in the set of the pixels to be inquired with the pixel value of the second pixel; according to the comparison result, further dividing the pixels in the set of the pixels to be inquired into at least two pixel sets; determining a pixel set where a pixel to be inquired is located from the at least two newly divided pixel sets until the determined pixel set meets the preset condition; and determining all pixels in the pixel set meeting the preset condition as pixels to be inquired.
Optionally, when the determining module divides M × N pixels in the pixel matrix into at least two pixel sets according to the comparison result, the determining module is specifically configured to: dividing pixels of the M x N pixels having pixel values smaller than the pixel value of the first pixel into a first set; dividing pixels of the M x N pixels having pixel values equal to pixel values of the first pixel into a second set; dividing pixels of the M x N pixels having pixel values greater than the pixel value of the first pixel into a third set.
Optionally, the processing module is specifically configured to: replacing the pixel value of the pixel at the middle position on the pixel matrix corresponding to the M-N field by the pixel value of the pixel to be inquired; or, the method is used for replacing the pixel values of the pixels at all positions in the pixel matrix corresponding to the M × N field with the pixel values of the pixel to be queried.
Optionally, Q ═ N + 1)/2.
In a third aspect, an embodiment of the present invention provides an image processing apparatus, including: a processor, and a memory communicatively coupled to the processor; wherein the memory stores instructions executable by the at least one processor, and the at least one processor is configured to execute the instructions in the memory to perform the method according to the first aspect of the present invention when the instructions are executed.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions that, when executed on a computer, cause the computer to perform the method according to the first aspect or any one of the optional embodiments of the first aspect.
The invention has the following beneficial effects:
the method comprises the steps of randomly selecting a pixel from a pixel matrix or self-defining a pixel, comparing the pixel value of the pixel with the pixel value of each pixel in the pixel matrix, carrying out set division on all pixels in the pixel matrix according to the comparison size, then determining a set where the pixel to be inquired is located, and finally determining the pixel to be inquired from the set where the pixel to be inquired is located. The method can find the pixels to be inquired without sequencing all the pixels from small to large, and can reduce the total times of comparing the sizes of the pixels compared with the method of sequencing all the pixel values in the pixel matrix from small to large by using bubble sequencing or quick sequencing in the prior art, so that the data processing amount is smaller, the pixel searching efficiency is higher, the image processing efficiency can be improved, and the power consumption of electronic equipment can be saved.
Drawings
FIG. 1 is a flowchart of an image processing method according to an embodiment of the present invention;
fig. 2 is an exemplary diagram of a 3 x 3 pixel matrix in an embodiment of the invention;
fig. 3A is an exemplary diagram of the 3 × 3 pixel matrix shown in fig. 2 after median filtering processing according to an embodiment of the present invention;
fig. 3B is an exemplary diagram of the 3 × 3 pixel matrix shown in fig. 2 after performing the blurring process according to the embodiment of the present invention;
FIG. 4 is a schematic diagram of an image processing apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention are described in detail below with reference to the drawings and specific embodiments, and it should be understood that the specific features in the embodiments and examples of the present invention are not intended to limit the technical solutions of the present invention, but may be combined with each other without conflict.
It should be understood that the terms first, second, etc. in the description of the embodiments of the present application are used for distinguishing between the descriptions and not for indicating or implying relative importance or order. In the description of the embodiments of the present application, "a plurality" means two or more.
The term "and/or" in the embodiment of the present application is only one kind of association relationship describing an associated object, and means that three kinds of relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
The embodiment of the invention provides an image processing method, which is used for solving the technical problem of low image processing efficiency in the prior art. Fig. 1 is a flowchart of the image processing method, please refer to fig. 1, the method includes:
s101, selecting a pixel matrix corresponding to an M-N neighborhood in the image.
Wherein M N is an odd number and is a positive integer greater than or equal to 3.
For example, fig. 2 is an exemplary diagram of pixels of an image, where the image includes 6 × 6 — 36 pixels, and the size of the selected pixel matrix is 3 × 3, i.e., M — 3, and N — 3, the image may be divided into 4 pixel matrices with sizes of 3 × 3. Fig. 2 shows one of the 3 × 3 pixel matrices, which is marked by black bold rectangle boxes, and the pixel values of the pixels in the pixel matrix are 10, 5, 3, 8, 2, 7, 5, 7, 9, respectively.
S102, determining a first pixel.
Wherein the first pixel may be any one selected from the pixel matrix. Taking the pixel matrix shown in fig. 2 as an example, if the pixel values of the pixels included in the pixel matrix are 10, 5, 3, 8, 2, 7, 5, 7, and 9, respectively, one pixel, for example, a pixel having a pixel value of 3, is arbitrarily selected from the pixel matrix.
Of course, in practical implementation, the pixel value of the first pixel may not be selected from the pixel matrix, but the value of one pixel may be customized for comparison with the pixel value in the pixel matrix. E.g., set to 6, then the pixel values in the pixel matrix shown in fig. 2 are divided into a sixth set of 6 or less, i.e., {5, 3, 2, 5}, and a seventh set of 6 or more, {10, 8, 7, 9 }.
S103, comparing the pixel value of each pixel in the pixel matrix with the pixel value of the first pixel, and dividing the M x N pixels in the pixel matrix into at least two pixel sets according to the comparison result.
Example 1, take the way of dividing three sets as an example: the method comprises the steps of dividing pixels of the M x N pixels, the pixel values of which are smaller than the pixel value of the first pixel, into a first set, dividing pixels, the pixel values of which are equal to the pixel value of the first pixel, into a second set (the second set comprises the first pixel itself), and dividing pixels, the pixel values of which are larger than the pixel value of the first pixel, into a third set.
With the example in step S102, the pixel values of the pixels included in the selected pixel matrix are sequentially 10, 5, 3, 8, 2, 7, 5, 7, and 9, and if the first pixel selected from the pixel matrix is a pixel with a pixel value of 3, the pixel value of 3 is compared with the values of all the pixels in the pixel matrix, and the pixels with a pixel value smaller than 3 in the pixel matrix are classified into a first set, and the first set is {2 }; -sorting the pixels of the pixel matrix having a pixel value equal to 3 into a second set, the second set comprising only the first pixels themselves, i.e. {3 }; pixels in the pixel matrix having a pixel value greater than 3 are sorted into a third set, and the third set is {10, 5, 8, 7, 5, 7, 9 }.
Of course, in the implementation, the two sets may be divided.
Example 2, take the way of dividing two sets as an example: dividing pixels of the M x N pixels, the pixel values of which are less than or equal to the pixel value of the first pixel, into a first set, and dividing pixels, the pixel values of which are greater than the first pixel, into a second set.
Continuing with the example in step S102, the pixel values of the pixels included in the selected pixel matrix are sequentially 10, 5, 3, 8, 2, 7, 5, 7, and 9, a pixel value of one pixel, for example, 3, is arbitrarily selected from the pixel matrix, then the size of 3 is compared with the number of pixel values of all pixels in the pixel matrix, and the pixels with the pixel values less than or equal to 3 are classified into a fourth set, and then the fourth set is {2, 3 }; pixels with pixel values greater than 3 are sorted into a fifth set, and the fifth set is 10, 5, 8, 7, 5, 7, 9.
S104, determining a set where the pixel to be inquired is located from the at least two pixel sets; the pixel to be inquired is a pixel at the Q-th position after M x N pixels in the pixel matrix are sequenced from small to large according to the pixel values.
Wherein Q is a positive integer less than or equal to M N.
Specifically, the set where the pixel to be queried is located may be determined according to the number of pixels included in each of the at least two pixel sets and the value of Q.
For example, following the above example of dividing the pixel matrix into the first set {2}, the second set {3}, and the third set {10, 5, 8, 7, 5, 7, 9}, it is assumed that the pixel value of the pixel to be queried is the pixel value of the 4 th-bit pixel in the pixel matrix, which is ordered from small to large. According to the determined size relationship among the pixel values in the first set, the second set and the third set and the number of the pixels in each set, the pixel to be queried is in the third set. Because the number of the pixels in the first set and the second set is only 2 in total, that is, the pixel in the first set is the pixel with the smallest pixel value, the pixel in the second set is the pixel with the second smallest pixel value, and the pixel value of the pixel to be queried is the pixel value of the 4 th-bit pixel of all the pixels of the pixel matrix, which is ordered from small to large, the pixel to be queried must be in the third set.
S105, determining the pixel to be inquired in the set where the pixel to be inquired is located, and processing the image based on the pixel to be inquired.
In this application, the pixel to be queried may be determined from the set of the pixels to be queried in at least the following two ways.
The first mode is as follows: and sequencing all pixels in the set where the pixels to be queried are located according to the sequence of the pixel values of the pixels from small to large to obtain a first pixel sequence, determining the position of the pixels to be queried in the first pixel sequence according to the value of Q, and acquiring the pixels to be queried from the position.
With the example in steps S103 and S104, after determining that the pixel to be queried is in the third set, all the pixel values in the third set may be sorted in the order from small to large (if there is the same pixel value, the same pixel value is sorted randomly in sequence), and then the pixel values of the sorted pixels in the third set are sequentially 5, 7, 8, 9, and 10. Since the pixel value of the pixel to be queried is the pixel value of the 4 th-bit pixel of all pixels in the pixel matrix sorted from small to large, and the first set and the second set have two pixels arranged to the first two bits, according to the number of the pixel values of the first set and the second set, it can be determined that the pixel value of the pixel to be queried is the pixel value of the 4-1-2 th-bit pixel of all pixels in the third set sorted from small to large, and therefore, the pixel value of the pixel to be queried can be determined to be 5, and the pixel to be queried is the pixel with the pixel value of 5 in the pixel matrix.
The second mode is as follows: judging whether the set of the pixels to be inquired meets a preset condition or not; the preset condition may be that the pixel values of all the pixels in the set where the pixel to be queried is located are all the same or the number of the pixels is 1.
If so, determining all pixels in the set where the pixels to be queried are located as the pixels to be queried.
Otherwise, the set where the pixel to be queried is located is continuously processed according to the manner of the S102-S104. Specifically, a second pixel is selected from the set where the pixel to be queried is located, where the second pixel is any one pixel in the set where the pixel to be queried is located; comparing the pixel value of each pixel except the second pixel in the set of the pixels to be inquired with the pixel value of the second pixel; according to the comparison result, further dividing the pixels in the set of the pixels to be inquired into at least two pixel sets; and determining a pixel set where a pixel to be inquired is located from the at least two newly divided pixel sets, and judging whether the determined pixel set meets the preset condition or not until a set meeting the preset condition is found.
For example, following the example in steps S103 and S104, it is determined that the pixel to be queried is in the third set, and it may be determined that the pixel value of the pixel to be queried is the pixel value of the 2 nd-bit pixel of all pixels in the third set, since the third set includes 10, 5, 8, 7, 5, 7, 9, and therefore the third set does not satisfy the preset condition, then arbitrarily selecting a pixel in the third set as the second pixel, assuming that the second pixel is 7, comparing the pixel value of the second pixel with the pixel values of other pixels in the pixel matrix except the second pixel in size, and classifying the pixels with pixel values smaller than 7 in the third set into the first set-I, where the first set-I is {5, 5 }; pixels in the third set with pixel values equal to 7 are classified into a second set-II, and the second set-II is {7, 7 }; and dividing the pixels with the pixel value larger than 7 in the third set into a third set-III, wherein the third set-III is 10, 8 and 9.
According to the size relationship among the first set-I, the second set-II and the third set-III and the number of the pixels contained in each set, the pixel to be inquired is in the first set-I. Because the first set-I has two pixels in total, that is, the pixels in the first set-I include the pixel with the smallest pixel value and the second smallest pixel, and because the pixel to be queried is the 2 nd-bit pixel in the pixel matrix, which is sorted from the smallest pixel value to the largest pixel value, the pixel to be queried must be in the first set-I. Further, since the pixel value of the first set-I is two same pixel values 5 and 5, that is, the condition that the pixel values of all the pixels in the set where the pixel to be queried is located in the preset condition are all the same is satisfied, it may be determined that the pixel value of the pixel to be queried is 5, and the pixel in the first set-I is the pixel to be queried.
In the scheme, one pixel is randomly selected from a pixel matrix or is self-defined, the pixel value of the pixel is compared with the pixel value of each pixel in the pixel matrix, all pixels in the pixel matrix are subjected to set division according to the comparison size, then a set where the pixel to be inquired is located is determined, and finally the pixel to be inquired is determined from the set where the pixel to be inquired is located. The method can find the pixels to be inquired without sequencing all the pixels from small to large, and can reduce the total times of comparing the sizes of the pixels compared with the method of sequencing all the pixel values in the pixel matrix from small to large by using bubble sequencing or quick sequencing in the prior art, so that the data processing amount is smaller, the pixel searching efficiency is higher, the image processing efficiency can be improved, and the power consumption of electronic equipment can be saved.
Optionally, based on the method of the pixel to be queried determined in the steps S101 to S105, the noise reduction processing of the image may be implemented.
A noise reduction processing method comprises the following steps: and replacing the pixel value of the pixel at the middle position on the pixel matrix corresponding to the M x N field with the determined pixel value of the pixel to be inquired, thereby realizing the noise reduction processing of the image.
For example, the image may be subjected to a median filtering process. Accordingly, the pixel to be queried is a pixel in the pixel matrix whose pixel value pattern is arranged at the (M × N +1)/2 th bit from small to large, that is, the pixel value of the pixel is the median of the pixel values of all the pixels in the pixel matrix. Specifically, the median value (the pixel value of the pixel of (M × N +1)/2 th bit) is used to replace the pixel value of the pixel at the middle position on the pixel matrix corresponding to the M × N domain. For example, after determining the median 5 in the pixel matrix shown in fig. 2 by using the method in steps S101-S105, the pixel value 2 of the pixel at the middle position on the pixel matrix corresponding to the M × N domain is replaced by 5, as shown in fig. 3A.
Through the embodiment, the image can be subjected to median filtering, and compared with the prior art in which all pixel values in the pixel matrix are sorted from small to large by using bubble sorting or quick sorting, the embodiment can reduce the total times of comparing the sizes of the pixels, so that the data processing amount is smaller, the pixel searching efficiency is higher, and further, the image can be subjected to faster image blurring processing, the image processing efficiency is improved, and the power consumption of electronic equipment is saved. For the salt and pepper noise on the image, a better processing effect can be obtained through the median filtering processing, and therefore the salt and pepper noise can be processed more efficiently by the embodiment.
Optionally, based on the method of the pixel to be queried determined in the above steps S101 to S105, blurring/blurring processing of the image may also be implemented.
A blurring processing method comprises the following steps: and replacing the pixel values of the pixels at all positions in the pixel matrix corresponding to the M-N field by the determined pixel values of the pixels to be inquired.
Still taking the pixel matrix of 3 × 3 shown in fig. 2 as an example, all the pixel values on the pixel matrix are replaced by the pixel values 5 of the pixel to be queried obtained based on the above steps S101-S105, and the pixel matrix after replacement is shown in fig. 3B. By the method, similar processing is carried out on other pixel matrixes in the image, so that the image blurring processing effect can be realized.
Compared with the prior art in which bubble sorting or quick sorting is used to sort all pixel values in the pixel matrix from small to large, the embodiment can reduce the total times of comparing the sizes of the pixels, so that the data processing amount is smaller, the pixel searching efficiency is higher, and further the image can be subjected to faster image blurring processing, the image processing efficiency is improved, the power consumption of electronic equipment is saved, and the image with the blurring processing effect desired by people can be obtained quickly.
Based on the same technical concept, an embodiment of the present invention further provides an apparatus 400 for image processing, referring to fig. 4, including:
a selecting module 401, configured to select a pixel matrix corresponding to an M × N neighborhood in an image; determining a first pixel;
a determining module 402, configured to compare a pixel value of each pixel in the pixel matrix with a pixel value of the first pixel; dividing M x N pixels in the pixel matrix into at least two pixel sets according to a comparison result;
a determining module 403, configured to determine, from the at least two pixel sets, a set where a pixel to be queried is located; the pixel value of the pixel to be inquired is the pixel value of the Q-th pixel of M × N pixels in the pixel matrix, wherein the Q is a positive integer; determining the pixel to be queried in the set where the pixel to be queried is located;
a processing module 404, configured to process the image based on the pixel to be queried.
Optionally, when determining the first pixel, the determining module 403 is specifically configured to: any one pixel selected from the pixel matrix, or a custom one pixel. Optionally, when the determining module 403 determines the set where the pixel to be queried is located from the at least two pixel sets, it is specifically configured to: and determining the set where the pixel to be inquired is located according to the number of pixels contained in each of the at least two pixel sets and the value of Q.
Optionally, when the determining module 403 determines the pixel to be queried in the set where the pixel to be queried is located, the determining module is specifically configured to:
sequencing all pixels in the set of the pixels to be queried according to the sequence of the pixel values of the pixels from small to large to obtain a first pixel sequence; determining the position of the pixel to be queried in the first pixel sequence according to the value of Q, and acquiring the pixel to be queried from the position; or judging whether the set of the pixels to be inquired meets a preset condition or not; the preset condition is that the pixel values of all pixels in the set where the pixel to be inquired is located are all the same or the number of the pixels is 1; if so, determining all pixels in the set where the pixels to be queried are located as pixels to be queried; if not, continuously selecting a second pixel from the set of the pixels to be inquired, wherein the second pixel is any one pixel in the set of the pixels to be inquired; comparing the pixel value of each pixel except the second pixel in the set of the pixels to be inquired with the pixel value of the second pixel; according to the comparison result, further dividing the pixels in the set of the pixels to be inquired into at least two pixel sets; determining a pixel set where a pixel to be inquired is located from the at least two newly divided pixel sets until the determined pixel set meets the preset condition; and determining all pixels in the pixel set meeting the preset condition as pixels to be inquired.
Optionally, when the determining module 402 divides M × N pixels in the pixel matrix into at least two pixel sets according to the comparison result, specifically configured to:
dividing pixels of the M x N pixels having pixel values smaller than the pixel value of the first pixel into a first set; dividing pixels of the M x N pixels having pixel values equal to pixel values of the first pixel into a second set; dividing pixels of the M x N pixels having pixel values greater than the pixel value of the first pixel into a third set.
Optionally, the processing module 404 is specifically configured to: replacing the pixel value of the pixel at the middle position on the pixel matrix corresponding to the M-N field by the pixel value of the pixel to be inquired; or, the method is used for replacing the pixel values of the pixels at all positions in the pixel matrix corresponding to the M × N field with the pixel values of the pixel to be queried.
Based on the same inventive concept, an embodiment of the present invention provides an image processing apparatus 500, referring to fig. 5, including: a processor, and a memory communicatively coupled to the processor; the memory 502 stores instructions executable by the at least one processor 501, and the at least one processor 501 executes the instructions stored in the memory 502 to cause the apparatus 500 to perform the image processing method according to the embodiment of the present invention.
For a specific implementation manner of executing the method steps by each module of the device, reference is made to the specific implementation manner of the method steps corresponding to the above method embodiment, and detailed description is not given in this embodiment.
Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium, where computer instructions are stored, and when the computer instructions are executed on a computer, the computer is caused to execute the image processing method according to the embodiment of the present invention.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (10)

1. An image processing method, characterized in that the method comprises:
selecting a pixel matrix corresponding to an M-N neighborhood in an image;
determining a first pixel, comparing the pixel value of each pixel in the pixel matrix with the pixel value of the first pixel, and dividing M × N pixels in the pixel matrix into at least two pixel sets according to the comparison result;
determining a set where a pixel to be queried is located from the at least two pixel sets; the pixel to be inquired is a pixel at the Q-th position after M x N pixels in the pixel matrix are sequenced from small to large according to the pixel values, and Q is a positive integer;
determining the pixel to be inquired in the set where the pixel to be inquired is located, and processing the image based on the pixel to be inquired;
wherein, determining the set of the pixels to be inquired from the at least two pixel sets comprises:
determining a set where the pixel to be queried is located according to the number of pixels contained in each of the at least two pixel sets and the value of Q;
determining the pixel to be queried in the set where the pixel to be queried is located, including:
sequencing all pixels in the set of the pixels to be queried according to the sequence of the pixel values of the pixels from small to large to obtain a first pixel sequence;
and determining the position of the pixel to be inquired in the first pixel sequence according to the value of Q, and acquiring the pixel to be inquired from the position.
2. The method of claim 1, wherein determining the first pixel comprises:
the first pixel is any one selected from the pixel matrix or is a self-defined pixel.
3. The method of claim 1, wherein determining the pixel to be queried in the set of pixels to be queried comprises:
judging whether the set of the pixels to be inquired meets a preset condition or not; the preset condition is that the pixel values of all pixels in the set where the pixel to be inquired is located are all the same or the number of the pixels is 1;
if so, determining all pixels in the set where the pixels to be queried are located as pixels to be queried;
otherwise, continuing to select a second pixel from the set where the pixel to be queried is located, wherein the second pixel is any one pixel in the set where the pixel to be queried is located; comparing the pixel value of each pixel except the second pixel in the set of the pixels to be inquired with the pixel value of the second pixel; according to the comparison result, further dividing the pixels in the set of the pixels to be inquired into at least two pixel sets; determining a pixel set where a pixel to be inquired is located from the at least two newly divided pixel sets until the determined pixel set meets the preset condition; and determining all pixels in the pixel set meeting the preset condition as pixels to be inquired.
4. The method of claim 1, wherein dividing M x N pixels in the pixel matrix into at least two pixel sets according to the comparison comprises:
dividing pixels of the M x N pixels having pixel values smaller than the pixel value of the first pixel into a first set;
dividing pixels of the M x N pixels having pixel values equal to pixel values of the first pixel into a second set;
dividing pixels of the M x N pixels having pixel values greater than the pixel value of the first pixel into a third set.
5. The method of any one of claims 1-4, wherein processing the image based on the pixel to be queried comprises:
replacing the pixel value of the pixel at the middle position on the pixel matrix corresponding to the M-N field by the pixel value of the pixel to be inquired; or replacing the pixel values of the pixels at all positions in the pixel matrix corresponding to the M-N field by the pixel values of the pixels to be inquired.
6. An image processing apparatus characterized by comprising:
the selection module is used for selecting a pixel matrix corresponding to an M x N neighborhood in the image; determining a first pixel;
the judging module is used for comparing the pixel value of each pixel in the pixel matrix with the pixel value of the first pixel and dividing M x N pixels in the pixel matrix into at least two pixel sets according to the comparison result;
the determining module is used for determining a set where the pixels to be inquired are located from the at least two pixel sets; the pixel value of the pixel to be inquired is the pixel value of the Q-th pixel of M × N pixels in the pixel matrix, wherein the Q is a positive integer; determining the pixel to be queried in the set where the pixel to be queried is located;
the processing module is used for processing the image based on the pixel to be inquired;
wherein, when the determining module determines the pixel to be queried in the set where the pixel to be queried is located, the determining module is specifically configured to: determining a set where the pixel to be queried is located according to the number of pixels contained in each of the at least two pixel sets and the value of Q; sequencing all pixels in the set of the pixels to be queried according to the sequence of the pixel values of the pixels from small to large to obtain a first pixel sequence; and determining the position of the pixel to be inquired in the first pixel sequence according to the value of Q, and acquiring the pixel to be inquired from the position.
7. The apparatus according to claim 6, wherein the determining module, when determining the pixel to be queried in the set in which the pixel to be queried is located, is specifically configured to:
sequencing all pixels in the set of the pixels to be queried according to the sequence of the pixel values of the pixels from small to large to obtain a first pixel sequence; determining the position of the pixel to be queried in the first pixel sequence according to the value of Q, and acquiring the pixel to be queried from the position; or
Judging whether the set of the pixels to be inquired meets a preset condition or not; the preset condition is that the pixel values of all pixels in the set where the pixel to be inquired is located are all the same or the number of the pixels is 1; if so, determining all pixels in the set where the pixels to be queried are located as pixels to be queried; otherwise, continuing to select a second pixel from the set where the pixel to be queried is located, wherein the second pixel is any one pixel in the set where the pixel to be queried is located; comparing the pixel value of each pixel except the second pixel in the set of the pixels to be inquired with the pixel value of the second pixel; according to the comparison result, further dividing the pixels in the set of the pixels to be inquired into at least two pixel sets; determining a pixel set where a pixel to be inquired is located from the at least two newly divided pixel sets until the determined pixel set meets the preset condition; and determining all pixels in the pixel set meeting the preset condition as pixels to be inquired.
8. The apparatus of claim 6 or 7, wherein the processing module is specifically configured to:
replacing the pixel value of the pixel at the middle position on the pixel matrix corresponding to the M-N field by the pixel value of the pixel to be inquired; or replacing the pixel values of the pixels at all positions in the pixel matrix corresponding to the M-N field by the pixel values of the pixels to be inquired.
9. An image processing apparatus characterized by comprising:
a processor, and a memory communicatively coupled to the processor;
wherein the memory stores instructions executable by the at least one processor, the at least one processor performing the method of any one of claims 1-5 by executing the instructions stored by the memory.
10. A computer-readable storage medium having stored thereon computer instructions which, when executed on a computer, cause the computer to perform the method of any one of claims 1-5.
CN201910863227.1A 2019-09-12 2019-09-12 Image processing method, device, equipment and storage medium Active CN110660029B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910863227.1A CN110660029B (en) 2019-09-12 2019-09-12 Image processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910863227.1A CN110660029B (en) 2019-09-12 2019-09-12 Image processing method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110660029A CN110660029A (en) 2020-01-07
CN110660029B true CN110660029B (en) 2022-05-06

Family

ID=69037057

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910863227.1A Active CN110660029B (en) 2019-09-12 2019-09-12 Image processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110660029B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101184158A (en) * 2007-12-18 2008-05-21 四川长虹电器股份有限公司 Method of searching mid value of pixel
CN103761707A (en) * 2013-12-20 2014-04-30 浙江大学 Average filtering method eliminating image impulse noise fast and efficiently
CN106204588A (en) * 2016-07-08 2016-12-07 腾讯科技(深圳)有限公司 A kind of image processing method and device
CN107705270A (en) * 2017-10-27 2018-02-16 智车优行科技(北京)有限公司 The treating method and apparatus of medium filtering, electronic equipment, computer-readable storage medium
CN108604436A (en) * 2016-01-13 2018-09-28 深圳云英谷科技有限公司 Device and method for pixel data rearrangement

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5949409A (en) * 1994-12-02 1999-09-07 Sony Corporation Image processing in which the image is divided into image areas with specific color lookup tables for enhanced color resolution
JP3456425B2 (en) * 1998-10-23 2003-10-14 日本電気株式会社 Image forming circuit and image forming method
CN104572755B (en) * 2013-10-24 2018-01-30 高德软件有限公司 A kind of method for establishing data directory, data query method and relevant apparatus
CN104700366B (en) * 2015-03-03 2017-08-22 上海联影医疗科技有限公司 A kind of method of transistor pixel look-up table generation
US10025988B2 (en) * 2015-05-22 2018-07-17 Tektronix, Inc. Anomalous pixel detection

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101184158A (en) * 2007-12-18 2008-05-21 四川长虹电器股份有限公司 Method of searching mid value of pixel
CN103761707A (en) * 2013-12-20 2014-04-30 浙江大学 Average filtering method eliminating image impulse noise fast and efficiently
CN108604436A (en) * 2016-01-13 2018-09-28 深圳云英谷科技有限公司 Device and method for pixel data rearrangement
CN106204588A (en) * 2016-07-08 2016-12-07 腾讯科技(深圳)有限公司 A kind of image processing method and device
CN107705270A (en) * 2017-10-27 2018-02-16 智车优行科技(北京)有限公司 The treating method and apparatus of medium filtering, electronic equipment, computer-readable storage medium

Also Published As

Publication number Publication date
CN110660029A (en) 2020-01-07

Similar Documents

Publication Publication Date Title
CN104899853B (en) Image area dividing method and device
CN108829610B (en) Memory management method and device in neural network forward computing process
US20150109290A1 (en) Device and method for removing noise points in point clouds
US9563938B2 (en) System and method for removing image noise
CN110246095B (en) Image restoration method and device, storage medium and terminal equipment
KR101537295B1 (en) Component filtering for low-light noise reduction
CN107705270B (en) Median filtering processing method and device, electronic equipment and computer storage medium
EP3855362A1 (en) Convolution processing method, apparatus, and storage medium of convolutional neural network
CN104268904A (en) Method and device for extracting main color of image
RU2017144798A (en) METHOD FOR DETERMINING A DEPTH MAP FOR IMAGE AND A DEVICE FOR ITS IMPLEMENTATION
CN111383191B (en) Image processing method and device for vascular fracture repair
US10303950B1 (en) Automated video correction
CN110660029B (en) Image processing method, device, equipment and storage medium
CN107832852B (en) Data processing learning method and system and electronic equipment
KR102239588B1 (en) Image processing method and apparatus
CN105893578B (en) A kind of method and device of photo selection
US20210042550A1 (en) Information processing device, information processing method, and computer-readable recording medium recording information processing program
CN105096263A (en) Image filtering method and device
CN109325432B (en) Three-dimensional object identification method and equipment and computer readable storage medium
CN107330866B (en) Method and device for eliminating highlight area and terminal
CN111626916A (en) Information processing method, device and equipment
CN111143589A (en) Image processing method and device and storage medium
CN105303508A (en) Picture processing method and apparatus
CN116432676B (en) Method and device for decoding bar code and electronic equipment
CN110647234B (en) Instruction processing method and electronic equipment

Legal Events

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