CN111833276A - Image median filtering processing method and device - Google Patents

Image median filtering processing method and device Download PDF

Info

Publication number
CN111833276A
CN111833276A CN202010700116.1A CN202010700116A CN111833276A CN 111833276 A CN111833276 A CN 111833276A CN 202010700116 A CN202010700116 A CN 202010700116A CN 111833276 A CN111833276 A CN 111833276A
Authority
CN
China
Prior art keywords
subset
data set
values
value
matrix
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.)
Pending
Application number
CN202010700116.1A
Other languages
Chinese (zh)
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.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202010700116.1A priority Critical patent/CN111833276A/en
Publication of CN111833276A publication Critical patent/CN111833276A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • G06T5/70
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/20Image enhancement or restoration by the use of local operators
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20024Filtering details
    • G06T2207/20032Median filtering

Abstract

The invention provides a median filtering processing method and a median filtering processing device for an image, wherein the method comprises the following steps: reading the gray value of the pixel corresponding to the target image in the filtering template, and forming a data set by the gray value; judging whether the size of the data set is larger than 9; under the condition that the judgment result is yes, carrying out segmentation elimination on the gray value in the data set to obtain a target set with the size smaller than or equal to 9; the target image is traversed through the filtering template, median filtering is carried out on the target image based on the target set, the problems that data sets in a whole sub-window are sorted and values of middle positions after sorting are output in the related technology can be solved, time complexity of median filtering is large, and the median filtering is only applicable to filtering scenes with fixed sizes, data dependence between adjacent sets is avoided, the median filtering can be applied to parallel computing, time complexity of median filtering is greatly reduced, and the median filtering method can be applied to filtering scenes with different sizes.

Description

Image median filtering processing method and device
Technical Field
The invention relates to the field of image processing, in particular to a median filtering processing method and device for an image.
Background
Digital images are often affected by electronic circuits, electromagnetism and the like during collection and transmission, collected images often carry a large amount of interference noise, and the accuracy of image processing in the later period is seriously affected.
The median filtering is a nonlinear filtering method, and its basic principle is to set the pixel value of a certain point as the middle value of its neighborhood pixel value set, and this middle value is the median of its neighborhood pixel value set. In a traditional filtering algorithm, pixels in a window are sequentially sorted by using a two-dimensional sub-window, and the number of the sorted middle positions is a median. The traditional method is independent in each sub-window calculation, and a certain improvement space exists in the traditional median filtering considering that a plurality of common elements exist between adjacent sub-windows.
The calculation process of the median filtering is mainly sorting, the time complexity of the algorithm is in an o (n3) relation with the length of the sub window, and the traditional method is difficult to be suitable for a large-size median filtering scene.
A5 x5 two-dimensional median filtering rapid algorithm is provided in the related art, based on three-direction sorting, the time complexity of the algorithm is greatly shortened, the method is only suitable for 5x5 median filtering, a certain error is introduced by taking the average value of diagonal median values as a final median value, and the calculation of the average values of three numbers relates to integer division, so that the calculation efficiency is low; a3 x3 two-dimensional median filtering algorithm and a circuit are also provided, the median is obtained by sequencing rows, columns and diagonal lines in turn, and the method is only suitable for median filtering of 3x 3.
The method aims at the problems that in the related technology, data sets in the whole sub-window are sorted, and values of middle positions after sorting are output, so that the time complexity of median filtering is high, and the median filtering is only suitable for filtering scenes with fixed sizes, and a solution is not provided.
Disclosure of Invention
The embodiment of the invention provides a median filtering processing method and device for an image, which are used for at least solving the problems that in the related art, data sets in a whole sub-window are sorted and the value of a middle position after sorting is output, so that the time complexity of median filtering is high, and the median filtering is only suitable for a filtering scene with a fixed size.
According to an embodiment of the present invention, there is provided a median filtering processing method for an image, including:
reading a gray value of a pixel corresponding to a target image in a filtering template, and forming a data set by the read gray value in the filtering template, wherein the filtering template is overlapped with one pixel position in the target image;
judging whether the size of the data set is larger than 9;
under the condition that the judgment result is yes, carrying out segmentation elimination on the gray value in the data set to obtain a target set with the size smaller than or equal to 9;
and traversing the target image through the filtering template, and performing median filtering on the target image based on the target set.
Optionally, the step of removing gray values in the data set in a segmented manner to obtain a target set with a size less than or equal to 9 includes:
carrying out segmentation processing on the data set to obtain a maximum value subset, a middle value subset and a minimum value subset of the data set;
and removing part of large values in the maximum value subset and part of small values in the minimum value subset to obtain a target set with the size less than or equal to 9.
Optionally, the step of removing part of the larger values in the maximum value subset and part of the smaller values in the minimum value subset to obtain a target set with a size less than or equal to 9 includes:
repeating the following operations on the data set until at least M values are removed from the maximum value subset and the minimum value subset to obtain the target set:
aligning the data sets to obtain a 3N matrix, wherein N is an odd number,
Figure BDA0002592706620000031
sequencing each row of the 3x N matrix from small to large or from large to small;
dividing the sorted 3 × N matrices into the maximum subset, the intermediate subset, and the minimum subset, wherein each column of the 3 × N matrices is a subset;
rejecting M values in the maximum subset and M values in the minimum subset;
and combining the eliminated maximum value sub-set, the intermediate value sub-set and the eliminated minimum value sub-set to obtain the eliminated data set.
Optionally, rejecting M values in the maximum subset and M values in the minimum subset comprises:
if the size of the maximum value subset and the minimum value subset is equal to 9, aligning the maximum value subset to obtain a maximum value matrix with 3 columns, and aligning the minimum value subset to obtain a minimum value matrix with 3 columns;
sequencing each row of the maximum matrix and the minimum matrix from large to small or from small to large;
removing M values in a first column and a second column in the maximum matrix, and removing M values in a third column and a second column in the minimum matrix; or eliminating M values in a third column and a second column in the maximum value matrix, and eliminating M values in a first column and a second column in the minimum value matrix.
Optionally, rejecting M values in the maximum subset and M values in the minimum subset comprises:
if the data set does not have a parent subset, rejecting the maximum M values in the maximum value subset and the minimum M values in the minimum value subset;
if a parent subset exists in the data set and the parent subset is the maximum value subset, rejecting the maximum M values in the maximum value subset;
and if the data set has a parent subset and the parent subset is the minimum value subset, rejecting the minimum M values in the minimum value subset.
Optionally, aligning the data set to obtain a 3 × N matrix includes:
if the size of the data set is a multiple of 3, directly aligning the data set to obtain a 3 × N matrix;
if the size of the data set is not multiple of 3, supplementing the data set to multiple of 3 by adding 0 and the maximum value in the data set in pairs, and aligning the supplemented data set to obtain a 3N matrix.
Optionally, median filtering the target image based on the target set comprises:
determining a median value of the target set;
and replacing the gray value corresponding to the pixel at the central position of the filtering template with the median.
Optionally, determining the median value of the set of targets comprises:
converting the target set into a 3x3 data matrix;
arranging each row of the data matrix in a descending or ascending order to obtain a target matrix;
determining a maximum value of a first column, a middle value of a second column and a minimum value of a third column in the target matrix;
determining a median of the maximum value of the first column, the median of the second column, and the minimum value of the third column.
According to another embodiment of the present invention, there is also provided an image median filtering processing apparatus including:
the device comprises a forming module, a processing module and a processing module, wherein the forming module is used for reading the gray value of a pixel corresponding to a target image in a filtering template and forming the read gray value in the filtering template into a data set, and the filtering template is overlapped with one pixel in the target image;
the judging module is used for judging whether the size of the data set is larger than 9;
the removing module is used for removing the gray values in the data set in a segmented mode under the condition that the judgment result is yes, and obtaining a target set with the size smaller than or equal to 9;
and the median filtering module is used for traversing the target image through the filtering template and carrying out median filtering on the target image based on the target set.
Optionally, the culling module comprises:
the segmentation processing sub-module is used for carrying out segmentation processing on the data set to obtain a maximum value sub-set, a middle value sub-set and a minimum value sub-set of the data set;
and the eliminating sub-module is used for eliminating part of larger values in the maximum value sub-set and part of smaller values in the minimum value sub-set to obtain a target set with the size smaller than or equal to 9.
Optionally, the culling sub-module comprises:
a repeating unit, configured to repeatedly perform the following operations on the data set until the maximum value subset and the minimum value subset both eliminate at least M values, so as to obtain the target set:
an alignment subunit, configured to perform alignment processing on the data set to obtain a 3 × N matrix, where N is an odd number,
Figure BDA0002592706620000051
the sorting subunit is used for sorting each row of the 3 × N matrix from small to large or from large to small;
a dividing subunit, configured to divide the sorted 3 × N matrix into the maximum value subset, the intermediate value subset, and the minimum value subset, where each column of the 3 × N matrix is a subset;
a rejecting subunit, configured to reject M values in the maximum value subset and M values in the minimum value subset;
and the combination subunit is used for combining the eliminated maximum value subset, the intermediate value subset and the eliminated minimum value subset to obtain the eliminated data set.
Optionally, the rejecting subunit is further configured to
If the size of the maximum value subset and the minimum value subset is equal to 9, aligning the maximum value subset to obtain a maximum value matrix with 3 columns, and aligning the minimum value subset to obtain a minimum value matrix with 3 columns;
sequencing each row of the maximum matrix and the minimum matrix from large to small or from small to large;
removing M values in a first column and a second column in the maximum matrix, and removing M values in a third column and a second column in the minimum matrix; or eliminating M values in a third column and a second column in the maximum value matrix, and eliminating M values in a first column and a second column in the minimum value matrix.
Optionally, the rejecting subunit is further configured to
If the data set does not have a parent subset, rejecting the maximum M values in the maximum value subset and the minimum M values in the minimum value subset;
if a parent subset exists in the data set and the parent subset is the maximum value subset, rejecting the maximum M values in the maximum value subset;
and if the data set has a parent subset and the parent subset is the minimum value subset, rejecting the minimum M values in the minimum value subset.
Optionally, the alignment subunit is further for
If the size of the data set is a multiple of 3, directly aligning the data set to obtain a 3 × N matrix;
if the size of the data set is not multiple of 3, supplementing the data set to multiple of 3 by adding 0 and the maximum value in the data set in pairs, and aligning the supplemented data set to obtain a 3N matrix.
Optionally, the median filtering module comprises:
a determination submodule for determining a median of the set of targets;
and the replacement submodule is used for replacing the gray value corresponding to the pixel at the central position of the filtering template with the median value.
Optionally, the determining sub-module includes:
a conversion unit for converting the target set into a 3x3 data matrix;
the sorting unit is used for performing descending or ascending sorting on each row of the data matrix to obtain a target matrix;
a first determining unit, configured to determine a maximum value of a first column, a middle value of a second column, and a minimum value of a third column in the target matrix;
a second determining unit, configured to determine a median of the maximum value of the first column, the median of the second column, and the median of the minimum value of the third column.
According to a further embodiment of the present invention, a computer-readable storage medium is also provided, in which a computer program is stored, wherein the computer program is configured to perform the steps of any of the above-described method embodiments when executed.
According to yet another embodiment of the present invention, there is also provided an electronic device, including a memory in which a computer program is stored and a processor configured to execute the computer program to perform the steps in any of the above method embodiments.
According to the method and the device, the gray value of the pixel corresponding to the target image in the filtering template is read, and the read gray value in the filtering template is combined into a data set, wherein the filtering template is overlapped with one pixel position in the target image; judging whether the size of the data set is larger than 9; under the condition that the judgment result is yes, carrying out segmentation elimination on the gray value in the data set to obtain a target set with the size smaller than or equal to 9; the target image is traversed through the filtering template, median filtering is carried out on the target image based on the target set, the problems that data sets in a whole sub-window are sorted in the related technology, values of middle positions after sorting are output, time complexity of median filtering is large, and the median filtering is only applicable to filtering scenes with fixed sizes can be solved, the data sets are smaller than or equal to 9 in a sectional rejection mode, calculated amount of element comparison in sorting is reduced, data dependence between adjacent sets is avoided, the median filtering can be applied to parallel calculation, time complexity of median filtering is greatly reduced, and the median filtering can be applicable to filtering scenes with different sizes.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a block diagram of a hardware configuration of a mobile terminal of a median filtering processing method of an image according to an embodiment of the present invention;
fig. 2 is a flowchart of a median filtering processing method of an image according to an embodiment of the present invention;
FIG. 3 is a flow chart of a fast median filtering method that can be performed in parallel according to an embodiment of the present invention;
FIG. 4 is a first flowchart of a culling operation according to an embodiment of the invention;
FIG. 5 is a schematic diagram of recursive culling according to an embodiment of the invention;
FIG. 6 is a flow chart of a median calculation according to an embodiment of the present invention;
FIG. 7 is a flow chart two of a culling operation according to an embodiment of the invention;
fig. 8 is a block diagram of a median filtering processing apparatus of an image according to an embodiment of the present invention.
Detailed Description
The invention will be described in detail hereinafter with reference to the accompanying drawings in conjunction with embodiments. It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
Example 1
The method provided by the first embodiment of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Taking a mobile terminal as an example, fig. 1 is a hardware structure block diagram of the mobile terminal of the median filtering processing method for an image according to an embodiment of the present invention, and as shown in fig. 1, the mobile terminal may include one or more processors 102 (only one is shown in fig. 1) (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 104 for storing data, and optionally, the mobile terminal may further include a transmission device 106 for a communication function and an input/output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration, and does not limit the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store a computer program, for example, a software program and a module of an application software, such as a computer program corresponding to the median filtering processing method of the image in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, so as to implement the method described above. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the mobile terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
In this embodiment, a method for median filtering processing of an image running on the mobile terminal or the network architecture is provided, and fig. 2 is a flowchart of a method for median filtering processing of an image according to an embodiment of the present invention, as shown in fig. 2, the flowchart includes the following steps:
step S202, reading a gray value of a pixel corresponding to a target image in a filtering template, and forming a data set by the gray value read in the filtering template, wherein the filtering template is overlapped with one pixel position in the target image;
step S204, judging whether the size of the data set is larger than 9;
step S206, under the condition that the judgment result is yes, the gray values in the data set are removed in a segmented mode, and a target set with the size smaller than or equal to 9 is obtained;
and step S208, traversing the target image through the filtering template, and performing median filtering on the target image based on the target set.
Further, the step S208 may specifically include:
s2081, determining a median value of the target set, and further converting the target set into a 3x3 data matrix; arranging each row of the data matrix in a descending or ascending order to obtain a target matrix; determining a maximum value of a first column, a middle value of a second column and a minimum value of a third column in the target matrix; determining a median of the maximum value of the first column, the median of the second column, and the minimum value of the third column;
s2082, replacing the median value with the gray value corresponding to the pixel at the center position of the filtering template.
Through the steps S202 to S208, the gray value of the pixel corresponding to the target image in the filter template is read, and the read gray value in the filter template is combined into a data set, wherein the filter template is overlapped with one pixel position in the target image; judging whether the size of the data set is larger than 9; under the condition that the judgment result is yes, carrying out segmentation elimination on the gray value in the data set to obtain a target set with the size smaller than or equal to 9; the target image is traversed through the filtering template, median filtering is carried out on the target image based on the target set, the problems that data sets in a whole sub-window are sorted in the related technology, values of middle positions after sorting are output, time complexity of median filtering is large, and the median filtering is only applicable to filtering scenes with fixed sizes can be solved, the data sets are smaller than or equal to 9 in a sectional rejection mode, calculated amount of element comparison in sorting is reduced, data dependence between adjacent sets is avoided, the median filtering can be applied to parallel calculation, time complexity of median filtering is greatly reduced, and the median filtering can be applicable to filtering scenes with different sizes.
Further, the step S206 may specifically include:
carrying out segmentation processing on the data set to obtain a maximum value subset, a middle value subset and a minimum value subset of the data set;
and removing part of large values in the maximum value subset and part of small values in the minimum value subset to obtain a target set with the size less than or equal to 9.
Specifically, the following operations may be repeatedly performed on the data set until the maximum value subset and the minimum value subset both eliminate at least M values, so as to obtain the target set:
aligning the data set to obtain a 3x N matrix, wherein N is an odd number; sequencing each row of the 3x N matrix from small to large or from large to small; further, if the size of the data set is a multiple of 3, directly aligning the data set to obtain a 3 × N matrix; if the size of the data set is not a multiple of 3, supplementing the data set to be a multiple of 3 by adding 0 and the maximum value in the data set in pairs, and aligning the supplemented data set to obtain a 3N matrix;
dividing the sorted 3 × N matrices into the maximum subset, the intermediate subset, and the minimum subset, wherein each column of the 3 × N matrices is a subset;
removing M values in the maximum value subset and M values in the minimum value subset, further, if the maximum value subset and the minimum value subset are not more than 9, aligning the maximum value subset to obtain a maximum value matrix with 3 columns, and aligning the minimum value subset to obtain a minimum value matrix with 3 columns; sequencing each row of the maximum matrix and the minimum matrix from large to small or from small to large; removing M values in a first column and a second column in the maximum matrix, and removing M values in a third column and a second column in the minimum matrix; or eliminating M values in a third column and a second column in the maximum matrix, and eliminating M values in a first column and a second column in the minimum matrix;
combining the eliminated maximum value subset, the intermediate value subset and the eliminated minimum value subset to obtain the eliminated data set, wherein,
Figure BDA0002592706620000111
in an optional embodiment, the rejecting M values in the maximum value subset and M values in the minimum value subset may specifically include:
if the data set does not have a parent subset, rejecting the maximum M values in the maximum value subset and the minimum M values in the minimum value subset, wherein the parent subset does not exist when the data set is rejected for the first time;
if a parent subset exists in the data set and the parent subset is the maximum value subset, rejecting the maximum M values in the maximum value subset;
and if the data set has a parent subset and the parent subset is the minimum value subset, rejecting the minimum M values in the minimum value subset.
The embodiment of the present invention is based on segmentation elimination, and mainly includes median calculation and elimination operations, and fig. 3 is a flowchart of a parallel fast median filtering method according to the embodiment of the present invention, as shown in fig. 3, including:
step S301, acquiring a data set, wherein the data set is composed of gray values of pixels corresponding to a target image in a filtering template;
step S302, judging whether the size of the data set is larger than 9, if so, executing step S303, otherwise, executing step S304;
step S303, removing operation, namely performing segmentation sorting on the sets, and removing the larger value and the smaller value in the sets in one step. When the set size is not greater than 9, then the N9 culling operation is performed directly. FIG. 4 is a first flowchart of a culling operation according to an embodiment of the invention, as shown in FIG. 4, including:
step S401, judging whether the size of the data set is larger than 9, if so, executing step S402, otherwise, executing step S410;
step S402, aligning the data set to 3 × N according to the size, wherein N is an odd number;
step S403, segmenting the data set into subsets { x0, x1, x2, …, xm } with the size of 3;
step S404, sequencing each subset, and respectively loading the maximum value, the middle value and the minimum value in the sequenced subsets into Xmax, Xmid and Xmin;
step S405, judging whether the data set has a father subset, if so, executing step S406, otherwise, executing step S407;
step S406, eliminating the largest ceil (N/2) items in Xmax, eliminating the smallest ceil (N/2) items in Xmin, and forming the rest items into a new set;
step S407, judging whether the father subset is the maximum subset, if so, executing step S408, otherwise, executing step S409;
step S408, removing the largest ceil (N/2) items in Xmax, forming the rest items into a new set, and then executing step S411;
step S409, removing the smallest ceil (N/2) items in Xmin, forming the rest items into a new set, and then executing step S411;
and S410, carrying out N9 eliminating operation, and finally carrying out N9 eliminating operation after the collection passes the eliminating operation, and sequencing each row of the data collection in a descending or ascending manner to obtain a new collection Y. Taking the descending order as an example, if the culling direction is max, that is, the larger item is culled, then the maximum value and the middle value in the first and second columns are culled. If the culling direction is min, i.e., culling smaller items, then culling the minimum and median values in the third and second columns.
And step S411, outputting the rejected data set.
FIG. 5 is a schematic diagram of recursive culling according to an embodiment of the invention, where the recursive operation of culling is to break up the set and perform culling operations continuously, as shown in FIG. 5. When the set size is larger than 9, the flow is a recursive operation flow. Firstly, aligning the sets, dividing the sets into small sets with the size of 3, sequencing each small set, then respectively forming three sets by the maximum value, the middle value and the minimum value in the sequencing result, then recursively calling a rejection operation to reject the larger value in the maximum value set and the smaller value in the minimum value set, and finally combining the three rejected sets into a new set.
Step S304, calculating the median value, and calculating only the data set with the set size not greater than 9, because the calculation process of the small-scale set is simple and has low complexity. When the aggregate size is not more than 3, the median value can be obtained by direct comparison without a special algorithm. When the set size is larger than 3, to simplify the process, the length may be aligned to 9, and then N9 median calculation is performed, fig. 6 is a flowchart of median calculation according to an embodiment of the present invention, as shown in fig. 6, including:
step S601, judging whether the size of the data set is larger than 3, if so, executing step S602, otherwise, executing step S604;
step S602, aligning the size of the data set to 9;
and step S603, carrying out N9 median calculation for a rapid median algorithm with the data set size of 9, carrying out local sequencing on the sets, and reducing the solving range of the median. The set with the length of 9 can be regarded as a matrix of 3x3, each row of the set is sorted in descending order or ascending order to obtain a new set Y, taking the descending order as an example, then the maximum value a of the first column, the middle value b of the second column and the minimum value c of the third column are solved respectively, and finally the median of a, b and c is calculated to be the median of the set.
Step S604, directly calculating the median of the data set;
in step S605, a median value of the data set is output.
The algorithm of the embodiment of the invention has low time complexity, and by introducing the thought of sectional elimination, larger items and smaller items in the set are eliminated recursively, and the solving range of the median is gradually reduced until the size of the set is reduced to be within 9. Since the computational complexity of the small-set median filtering is much lower than that of the large set, the computational complexity can be reduced by an order of magnitude according to this idea. The method can be suitable for parallel computing, and the throughput of the algorithm is further improved. The invention has no data dependency relationship in the calculation of each set, so that more efficient parallel calculation can be realized by a SIMD processor, an FPGA, a customized circuit or the like.
FIG. 7 is a second flowchart of a culling operation according to an embodiment of the invention, as shown in FIG. 7, including:
step S701, inputting a data set;
step S702, deleting operation;
step S703, deleting the deleted data set;
step S704, judging whether the data set has a father subset, if so, executing step S705, otherwise, executing step S706;
step S705, judging whether the rejection quantity is larger than ceil (N/2), if not, executing step S707, otherwise, executing step S708;
step S706, judging whether the size of the data set is not larger than 9, if not, executing step S707, otherwise executing step S708;
step S707, updating the data set;
in step S708, the data set is output.
A maximum (small) value subset of the original data, or a recursive subset of the maximum (small) value subset, when the parent subset exists. When no parent subset exists, the elimination target is that the set size is not larger than 9; when the parent set exists, the elimination target is that the elimination quantity reaches
Figure BDA0002592706620000151
And if the elimination target is not reached, forming the residual elements into a new set, and repeating the elimination operation.
Example 2
According to another embodiment of the present invention, there is also provided a median filter processing apparatus for an image, and fig. 8 is a block diagram of the median filter processing apparatus for an image according to the embodiment of the present invention, as shown in fig. 8, including:
the composition module 82 is configured to read a gray value of a pixel corresponding to a target image in a filter template, and compose the read gray value in the filter template into a data set, where the filter template coincides with a pixel position in the target image;
a determining module 84, configured to determine whether the size of the data set is greater than 9;
a removing module 86, configured to remove the gray values in the data set in a segmented manner to obtain a target set with a size smaller than or equal to 9 if the determination result is yes;
a median filtering module 88, configured to traverse the target image through the filtering template, and perform median filtering on the target image based on the target set.
Optionally, the culling module 86 includes:
the segmentation processing sub-module is used for carrying out segmentation processing on the data set to obtain a maximum value sub-set, a middle value sub-set and a minimum value sub-set of the data set;
and the eliminating sub-module is used for eliminating part of larger values in the maximum value sub-set and part of smaller values in the minimum value sub-set to obtain a target set with the size smaller than or equal to 9.
Optionally, the culling sub-module comprises:
a repeating unit, configured to repeatedly perform the following operations on the data set until the maximum value subset and the minimum value subset both eliminate at least M values, so as to obtain the target set:
an alignment subunit, configured to perform alignment processing on the data set to obtain a 3 × N matrix, where N is an odd number,
Figure BDA0002592706620000161
the sorting subunit is used for sorting each row of the 3 × N matrix from small to large or from large to small;
a dividing subunit, configured to divide the sorted 3 × N matrix into the maximum value subset, the intermediate value subset, and the minimum value subset, where each column of the 3 × N matrix is a subset;
a rejecting subunit, configured to reject M values in the maximum value subset and M values in the minimum value subset;
and the combination subunit is used for combining the eliminated maximum value subset, the intermediate value subset and the eliminated minimum value subset to obtain the eliminated data set.
Optionally, the rejecting subunit is further configured to
If the size of the maximum value subset and the minimum value subset is equal to 9, aligning the maximum value subset to obtain a maximum value matrix with 3 columns, and aligning the minimum value subset to obtain a minimum value matrix with 3 columns;
sequencing each row of the maximum matrix and the minimum matrix from large to small or from small to large;
removing M values in a first column and a second column in the maximum matrix, and removing M values in a third column and a second column in the minimum matrix; or eliminating M values in a third column and a second column in the maximum value matrix, and eliminating M values in a first column and a second column in the minimum value matrix.
Optionally, the rejecting subunit is further configured to
If the data set does not have a parent subset, rejecting the maximum M values in the maximum value subset and the minimum M values in the minimum value subset;
if a parent subset exists in the data set and the parent subset is the maximum value subset, rejecting the maximum M values in the maximum value subset;
and if the data set has a parent subset and the parent subset is the minimum value subset, rejecting the minimum M values in the minimum value subset.
Optionally, the alignment subunit is further for
If the size of the data set is a multiple of 3, directly aligning the data set to obtain a 3 × N matrix;
if the size of the data set is not a multiple of 3, supplementing the data set to be a multiple of 3 by adding the maximum value in 0 data sets, and aligning the supplemented data sets to obtain a 3N matrix.
Optionally, the median filtering module 88 comprises:
a determination submodule for determining a median of the set of targets;
and the replacement submodule is used for replacing the gray value corresponding to the pixel at the central position of the filtering template with the median value.
Optionally, the determining sub-module includes:
a conversion unit for converting the target set into a 3x3 data matrix;
the sorting unit is used for performing descending or ascending sorting on each row of the data matrix to obtain a target matrix;
a first determining unit, configured to determine a maximum value of a first column, a middle value of a second column, and a minimum value of a third column in the target matrix;
a second determining unit, configured to determine a median of the maximum value of the first column, the median of the second column, and the median of the minimum value of the third column.
It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.
Example 3
Embodiments of the present invention also provide a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to perform the steps of any of the above method embodiments when executed.
Alternatively, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
s1, reading the gray value of the pixel corresponding to the target image in the filtering template, and forming a data set by the gray value read in the filtering template, wherein the filtering template is overlapped with one pixel position in the target image;
s2, judging whether the size of the data set is larger than 9;
s3, under the condition that the judgment result is yes, carrying out segmentation elimination on the gray value in the data set to obtain a target set with the size less than or equal to 9;
and S4, traversing the target image through the filtering template, and performing median filtering on the target image based on the target set.
Optionally, in this embodiment, the storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Example 4
Embodiments of the present invention also provide an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps of any of the above method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, reading the gray value of the pixel corresponding to the target image in the filtering template, and forming a data set by the gray value read in the filtering template, wherein the filtering template is overlapped with one pixel position in the target image;
s2, judging whether the size of the data set is larger than 9;
s3, under the condition that the judgment result is yes, carrying out segmentation elimination on the gray value in the data set to obtain a target set with the size less than or equal to 9;
and S4, traversing the target image through the filtering template, and performing median filtering on the target image based on the target set.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
It will be apparent to those skilled in the art that the modules or steps of the present invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

Claims (11)

1. A method for median filtering processing of an image, comprising:
reading a gray value of a pixel corresponding to a target image in a filtering template, and forming a data set by the read gray value in the filtering template, wherein the filtering template is overlapped with one pixel position in the target image;
judging whether the size of the data set is larger than 9;
under the condition that the judgment result is yes, carrying out segmentation elimination on the gray value in the data set to obtain a target set with the size smaller than or equal to 9;
and traversing the target image through the filtering template, and performing median filtering on the target image based on the target set.
2. The method of claim 1, wherein the step of removing gray values in the data set in a segmented manner to obtain a target set with a size less than or equal to 9 comprises:
carrying out segmentation processing on the data set to obtain a maximum value subset, a middle value subset and a minimum value subset of the data set;
and removing part of large values in the maximum value subset and part of small values in the minimum value subset to obtain a target set with the size less than or equal to 9.
3. The method of claim 2, wherein culling the partial larger values in the maximum subset and the partial smaller values in the minimum subset to obtain a target set with a size less than or equal to 9 comprises:
repeating the following operations on the data set until the maximum value subset and the minimum value subset both eliminate at least M values, so as to obtain the target set:
aligning the data sets to obtain a 3N matrix, wherein N is an odd number,
Figure FDA0002592706610000011
sequencing each row of the 3x N matrix from small to large or from large to small;
dividing the sorted 3 × N matrices into the maximum subset, the intermediate subset, and the minimum subset, wherein each column of the 3 × N matrices is a subset;
rejecting M values in the maximum subset and M values in the minimum subset;
and combining the eliminated maximum value sub-set, the intermediate value sub-set and the eliminated minimum value sub-set to obtain the eliminated data set.
4. The method of claim 3, wherein culling M values in the maximum subset and M values in the minimum subset comprises:
if the size of the maximum value subset and the minimum value subset is not larger than 9, aligning the maximum value subset to obtain a maximum value matrix with 3 columns, and aligning the minimum value subset to obtain a minimum value matrix with 3 columns;
sequencing each row of the maximum matrix and the minimum matrix from large to small or from small to large;
removing M values in a first column and a second column in the maximum matrix, and removing M values in a third column and a second column in the minimum matrix; or eliminating M values in a third column and a second column in the maximum value matrix, and eliminating M values in a first column and a second column in the minimum value matrix.
5. The method of claim 3, wherein culling M values in the maximum subset and M values in the minimum subset comprises:
if the data set does not have a parent subset, rejecting the maximum M values in the maximum value subset and the minimum M values in the minimum value subset;
if a parent subset exists in the data set and the parent subset is the maximum value subset, rejecting the maximum M values in the maximum value subset;
and if the data set has a parent subset and the parent subset is the minimum value subset, rejecting the minimum M values in the minimum value subset.
6. The method of claim 3, wherein aligning the data sets to obtain a 3x N matrix comprises:
if the size of the data set is a multiple of 3, directly aligning the data set to obtain a 3 × N matrix;
if the size of the data set is not multiple of 3, supplementing the data set to multiple of 3 by adding 0 and the maximum value in the data set in pairs, and aligning the supplemented data set to obtain a 3N matrix.
7. The method of any one of claims 1 to 6, wherein median filtering the target image based on the target set comprises:
determining a median value of the target set;
and replacing the gray value corresponding to the pixel at the central position of the filtering template with the median.
8. The method of claim 7, wherein determining the median value of the set of targets comprises:
converting the target set into a 3x3 data matrix;
arranging each row of the data matrix in a descending or ascending order to obtain a target matrix;
determining a maximum value of a first column, a middle value of a second column and a minimum value of a third column in the target matrix;
determining a median of the maximum value of the first column, the median of the second column, and the minimum value of the third column.
9. An apparatus for median filtering processing of an image, comprising:
the device comprises a forming module, a processing module and a processing module, wherein the forming module is used for reading the gray value of a pixel corresponding to a target image in a filtering template and forming the read gray value in the filtering template into a data set, and the filtering template is overlapped with one pixel in the target image;
the judging module is used for judging whether the size of the data set is larger than 9;
the removing module is used for removing the gray values in the data set in a segmented mode under the condition that the judgment result is yes, and obtaining a target set with the size smaller than or equal to 9;
and the median filtering module is used for traversing the target image through the filtering template and carrying out median filtering on the target image based on the target set.
10. A computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to carry out the method of any one of claims 1 to 8 when executed.
11. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, and wherein the processor is arranged to execute the computer program to perform the method of any of claims 1 to 8.
CN202010700116.1A 2020-07-20 2020-07-20 Image median filtering processing method and device Pending CN111833276A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010700116.1A CN111833276A (en) 2020-07-20 2020-07-20 Image median filtering processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010700116.1A CN111833276A (en) 2020-07-20 2020-07-20 Image median filtering processing method and device

Publications (1)

Publication Number Publication Date
CN111833276A true CN111833276A (en) 2020-10-27

Family

ID=72923085

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010700116.1A Pending CN111833276A (en) 2020-07-20 2020-07-20 Image median filtering processing method and device

Country Status (1)

Country Link
CN (1) CN111833276A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112967331A (en) * 2021-03-25 2021-06-15 北京的卢深视科技有限公司 Image processing method, electronic equipment and storage medium
CN117314730A (en) * 2023-11-28 2023-12-29 进迭时空(杭州)科技有限公司 Median filtering computing device and method for accelerating digital image processing

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102819827A (en) * 2012-07-10 2012-12-12 武汉大学 Self-adaption moment matching stripe noise removing method based on gray-level segmentation
CN104077746A (en) * 2013-03-29 2014-10-01 富士通株式会社 Gray level image processing method and device
CN106127713A (en) * 2016-06-30 2016-11-16 山东中安科创光电科技有限公司 Small and weak gas leakage target strengthens and Fast implementation
CN108846802A (en) * 2018-01-25 2018-11-20 湖南省自兴人工智能研究院 A kind of removal chromosomal G-banding mid-term gray level image Noise Method
CN109785347A (en) * 2018-04-27 2019-05-21 京东方科技集团股份有限公司 Image processing method, image processing system and storage medium
CN109859133A (en) * 2019-01-30 2019-06-07 南京邮电大学 A kind of median filtering image de-noising method
CN110111343A (en) * 2019-05-07 2019-08-09 齐鲁工业大学 A kind of middle intelligence image partition method and device based on improvement fuzzy C-mean algorithm
CN110956598A (en) * 2019-12-05 2020-04-03 开放智能机器(上海)有限公司 Sorting system and sorting method suitable for image median filtering

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102819827A (en) * 2012-07-10 2012-12-12 武汉大学 Self-adaption moment matching stripe noise removing method based on gray-level segmentation
CN104077746A (en) * 2013-03-29 2014-10-01 富士通株式会社 Gray level image processing method and device
CN106127713A (en) * 2016-06-30 2016-11-16 山东中安科创光电科技有限公司 Small and weak gas leakage target strengthens and Fast implementation
CN108846802A (en) * 2018-01-25 2018-11-20 湖南省自兴人工智能研究院 A kind of removal chromosomal G-banding mid-term gray level image Noise Method
CN109785347A (en) * 2018-04-27 2019-05-21 京东方科技集团股份有限公司 Image processing method, image processing system and storage medium
CN109859133A (en) * 2019-01-30 2019-06-07 南京邮电大学 A kind of median filtering image de-noising method
CN110111343A (en) * 2019-05-07 2019-08-09 齐鲁工业大学 A kind of middle intelligence image partition method and device based on improvement fuzzy C-mean algorithm
CN110956598A (en) * 2019-12-05 2020-04-03 开放智能机器(上海)有限公司 Sorting system and sorting method suitable for image median filtering

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
李腾飞等: "基于窗口滤波与均值滤波的深度图像实时修复算法", 软件工程, vol. 21, no. 11, 30 November 2018 (2018-11-30), pages 17 - 20 *
鲍华;樊瑜波;饶长辉;张雨东;戴云;: "基于均值查找的快速中值滤波算法", 四川大学学报(工程科学版), no. 02, 31 March 2011 (2011-03-31), pages 76 - 79 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112967331A (en) * 2021-03-25 2021-06-15 北京的卢深视科技有限公司 Image processing method, electronic equipment and storage medium
CN112967331B (en) * 2021-03-25 2021-12-17 北京的卢深视科技有限公司 Image processing method, electronic equipment and storage medium
CN117314730A (en) * 2023-11-28 2023-12-29 进迭时空(杭州)科技有限公司 Median filtering computing device and method for accelerating digital image processing
CN117314730B (en) * 2023-11-28 2024-03-15 进迭时空(杭州)科技有限公司 Median filtering computing device and method for accelerating digital image processing

Similar Documents

Publication Publication Date Title
CN111833276A (en) Image median filtering processing method and device
US20230305802A1 (en) Median Value Determination in a Data Processing System
JP2020170495A (en) Single pixel attack sample generating method, device, facility, and storage medium
JP2014011800A (en) Noise rejection device, system and method
CN106296576A (en) Image processing method and image processing apparatus
CN111598176B (en) Image matching processing method and device
CN111091106A (en) Image clustering method and device, storage medium and electronic device
CN112653928A (en) Video filtering method, system and equipment based on same content
CN108736861B (en) Reduced area median filter using scheduling circuitry
CN112199407B (en) Data packet ordering method, device, equipment and storage medium
CN113377998A (en) Data loading method and device, electronic equipment and storage medium
CN111127480B (en) Image processing method and device, electronic equipment and storage medium
CN115830342A (en) Method and device for determining detection frame, storage medium and electronic device
CN115984742A (en) Training method of video frame selection model, video processing method and device
CN113204706B (en) Data screening and extracting method and system based on MapReduce
CN110826694B (en) Image processing method and device based on convolutional neural network
CN111712833B (en) Method and device for screening local feature points
CN110287943A (en) Object identifying method, device, electronic equipment and the storage medium of image
CN111860239A (en) Key identification method and device, terminal equipment and computer readable storage medium
CN111224674A (en) Decoding method, device and decoder of multi-system LDPC code
CN112925937B (en) Image screening method, image screening device, storage medium and electronic device
CN114048839A (en) Acceleration method and device for convolution calculation and terminal equipment
CN111506607A (en) Data processing method and device
Prokin et al. Morphological and median adaptive filters based on LCBP rank filter
CN111914858A (en) Method and apparatus for determining characteristic value, storage medium, and electronic apparatus

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