Invention content
In view of this, this application provides a kind of image filtering method and device, the efficiency of image filtering is improved.
To achieve the above object, the application provides the following technical solutions:
A kind of image filtering method, including:
The pixel value of each pixel in described image in the default neighborhood of pending pixel is compared;
It calculates more than the pixel value number of each pixel value and the pixel value number less than each pixel value
Number difference, to obtain the corresponding number difference of each pixel value;
Using in the corresponding number difference of each pixel value, the corresponding pixel value of number difference of numerical value minimum, more
The pixel value of the new pending pixel.
Preferably, in the corresponding number difference using each pixel value, the number difference of numerical value minimum corresponds to
Pixel value, the pixel value for updating the pending pixel includes:
In the corresponding number difference of each pixel value, when the number difference of numerical value minimum corresponds to multiple pixel values,
Using the average value of the multiple pixel value, the pixel value of the pending pixel is replaced;
In the corresponding number difference of each pixel value, when the number difference of numerical value minimum corresponds to a pixel value,
The pixel value of the pending pixel is replaced using one pixel value.
Preferably, the pixel value of each pixel in described image in the default neighborhood of pending pixel is compared
Relatively include:
Using the pixel value chosen successively in each pixel value as target pixel value, and compared with other pixel values
Compared with;Wherein, other pixel values are the pixel value for not including the target pixel value in each pixel value;
It is described to calculate more than the pixel value number of each pixel value and the pixel value less than each pixel value
Several number differences includes to obtain the corresponding number difference of each pixel value:
First number of the pixel value in each pixel value more than the target pixel value is calculated, and is less than the target
Second number of the pixel value of pixel value;
The number absolute value of the difference for calculating first number and second number, as the target pixel value
Number difference, to obtain the corresponding number difference of each pixel value.
Preferably, the number difference is specially subtracted more than the pixel value number of each pixel value each less than described
The absolute value for the difference that the number of the pixel value of a pixel value obtains;
Or subtract the pixel value number more than each pixel value less than the pixel value number of each pixel value
The absolute value of obtained difference.
A kind of image filtering device, including:
Comparing unit is used for the pixel value of each pixel in described image in the default neighborhood of pending pixel
It is compared;
Computing unit, for calculating the pixel value number more than each pixel value and each pixel value less than described in
The number difference of pixel value number obtains the corresponding number difference of each pixel value;
Filter unit, for utilizing in the corresponding number difference of each pixel value, the number difference pair of numerical value minimum
The pixel value answered updates the pixel value of the pending pixel.
Preferably, the filter unit includes:
First filter unit, for working as in the corresponding number difference of each pixel value, the number difference of numerical value minimum
When corresponding multiple pixel values, using the average value of the multiple pixel value, the pixel value of the pending pixel is replaced;
Second filter unit, for working as in the corresponding number difference of each pixel value, the number difference of numerical value minimum
When a corresponding pixel value, the pixel value of the pending pixel is replaced using one pixel value.
Preferably, the comparing unit is specifically used for using the pixel value chosen successively from each pixel value as mesh
Pixel value is marked, and the target pixel value is compared with other pixel values;Wherein, other pixel values are each pixel
Do not include the pixel value of the target pixel value in value;
The computing unit includes:
Counting unit, first number for calculating the pixel value in each pixel value more than the target pixel value, with
And second number of the pixel value less than the target pixel value;
Difference computational unit, for calculating first number and second number absolute value of the difference, as the mesh
The number difference for marking pixel value, to obtain the corresponding number difference of each pixel value.
A kind of image filtering equipment, including:
First comparator is used for the pixel of each pixel in the pending pixel default neighborhood in described image
Value is compared;
Calculator, for calculating more than the pixel value number of each pixel value and the picture less than each pixel value
The number difference of element value number, obtains the corresponding number difference of each pixel value;
Second comparator is used for the corresponding number difference of more each pixel value, determines the number number of numerical value minimum
It is worth corresponding pixel value;
Filter, the pixel value for being determined using second comparator update the pixel of the pending pixel
Value.
Preferably, the filter includes:
First filter, for working as in the corresponding number difference of each pixel value, the number difference pair of numerical value minimum
When answering multiple pixel values, using the average value of the multiple pixel value, the pixel value of the pending pixel is replaced;
Second filter, for working as in the corresponding number difference of each pixel value, the number difference pair of numerical value minimum
When answering a pixel value, the pixel value of the pending pixel is replaced using one pixel value.
Preferably, the first comparator is specifically used for using the pixel value chosen successively in each pixel value as mesh
Pixel value is marked, and is compared with other pixel values;Wherein, it does not include the mesh that other pixel values, which are in each pixel value,
Mark the pixel value of pixel value;
Then the calculator includes:
Counter, for calculating first number of pixel value for being more than the target pixel value in each pixel value, Yi Jiyu
Less than second number of pixel value of the target pixel value;
Subtracter, for calculating first number and second number absolute value of the difference, as the object pixel
The number difference of value, to obtain the corresponding number difference of each pixel value.
It can be seen via above technical scheme that compared with prior art, this application provides a kind of image filtering method and
Device, when being filtered to the pending pixel in image, by each pixel in the default neighborhood of pending pixel
The pixel value of point is compared;It calculates more than the pixel value number of each pixel value and the picture less than each pixel value
The number difference of element value number, obtains the corresponding number difference of each pixel value;The number difference of numerical value minimum is corresponding
Pixel value is the intermediate value of each pixel value, is that the pixel value of the pending pixel may be updated using the intermediate value, being not necessarily to will
Each rank-ordered pixels and the step by step complex operations such as grouping, you can quickly to determine the intermediate value in each pixel value, reduce
Workload, to improve the efficiency of image filtering.
Specific implementation mode
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete
Site preparation describes, it is clear that described embodiments are only a part of embodiments of the present application, instead of all the embodiments.It is based on
Embodiment in the application, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall in the protection scope of this application.
In the embodiment of the present application, by the pixel value of each pixel in image in the default neighborhood of pending pixel
It is compared;It calculates more than the pixel value number of each pixel value and the pixel value number less than each pixel value
Number difference, to obtain the corresponding number difference of each pixel value;It is poor from the corresponding number of each pixel value of utilization
In value, the corresponding pixel value of number difference of numerical value minimum, you can the pixel value of the update pending pixel.The numerical value is most
The small corresponding pixel value of number difference is the intermediate value of each pixel value, and the determination of intermediate value is not necessarily to sort and be grouped step by step etc. multiple
Miscellaneous operation so that reduce workload when medium filtering, improve the efficiency of image filtering.
Fig. 1 is a kind of flow chart of image filtering method one embodiment provided by the embodiments of the present application, and this method can be with
Including following steps:
101:The pixel value of each pixel in described image in the default neighborhood of pending pixel is compared.
102:It calculates more than the pixel value number of each pixel value and the pixel value less than each pixel value
Several number difference, to obtain the corresponding number difference of each pixel value.
103:Using in the corresponding number difference of each pixel value, the corresponding pixel of number difference of numerical value minimum
Value updates the pixel value of the pending pixel.
Wherein, which refers to the maximum pixel in the pixel that its pixel value is more than in its default neighborhood
Value, and pixel value difference is less than the minimum pixel value in the pixel in its default neighborhood more than first threshold or its pixel value,
And pixel value difference is more than the pixel namely noise spot of second threshold.
When carrying out image filtering, it is first determined pending pixel can be sentenced for each pixel in image
Whether the difference that its disconnected pixel value subtracts the max pixel value in the pixel in its default neighborhood is more than first threshold, Huo Zheqi
Whether the difference that the minimum pixel value of the pixel in default neighborhood subtracts its pixel value is less than second threshold, if it is, can
To determine the pixel as pending pixel, need to carry out noise reduction, it can be according to the noise reduction process of pending pixel
Image filtering scheme provided by the embodiments of the present application executes.The first threshold and second threshold can be according to right in practical application
The requirement of picture quality determines, for fixed value or can be set by the user.
Default field refers to the nearby sphere of pending pixel, such as the 5*5 put centered on pending pixel
The region of region, i.e. 5 every trade pixels and 5 row row pixels composition, pending pixel are the central point in the region.
The predeterminable area can be determined according to practical situations.
It includes the pending pixel that pending pixel, which presets each pixel in field not,.Each pixel is equal
With pixel value, pixel value can select the pixels list of feature values such as brightness value, gray value according to different practical situations
Show.
After the pixel value for determining each pixel, you can be compared to each pixel value, for any one picture
Element value, can calculate more than its pixel value number and less than its pixel value number, so as to obtain being more than its picture
The number difference of element value number and the pixel value number less than it.
Wherein, which is specially positive integer.
The pixel value number that the number difference may be greater than each pixel value is subtracted less than each described pixel value
Pixel value number obtain the absolute value of difference;Or it is subtracted more than each less than the pixel value number of each pixel value
The pixel value number of a pixel value obtains the absolute value of difference.
After calculating the corresponding number difference of each pixel value, each number difference can be compared, can be obtained
The corresponding pixel value of number difference of numerical value minimum.The corresponding pixel value of number difference of numerical value minimum is each pixel value
Intermediate value, to utilize the intermediate value, the pixel value of pending pixel can be updated.
For example, being for one group of pixel value:1, for 2,3,4,5,6,7, wherein be more than the pixel value number of pixel value 1
It is 6, the pixel value number for being less than pixel value 1 is 0, and the number difference to which the pixel value 1 be calculated is 6;More than pixel value 2
Pixel value number be 5, be less than pixel value 2 pixel value number be 1, be calculated the pixel value 2 number difference be 4;Greatly
It is 4 in the pixel value number of pixel value 3, the pixel value number for being less than pixel value 3 is 2, and the number that the pixel value 3 is calculated is poor
Value is 2;Pixel value number more than pixel value 4 is 3, and the pixel value number for being less than pixel value 4 is 3, and the pixel value 4 is calculated
Number difference be 0;Pixel value number more than pixel value 5 is 2, and the pixel value number for being less than pixel value 5 is 4, is calculated
The number difference of the pixel value 4 is 2;Pixel value number more than pixel value 6 is 1, and the pixel value number for being less than pixel value 6 is 5,
The number difference that the pixel value 6 is calculated is 4;Pixel value number more than pixel value 7 is 0, is less than the pixel value of pixel value 7
Number is 6, and the number difference that the pixel value 7 is calculated is 6.By comparing can numerical value minimum number difference be 0, from
And 0 corresponding pixel value 4 of number difference is the intermediate value of this group of pixel value, you can to update pending pixel using pixel value 4
The pixel value of point.
The embodiment of the present application is based on medium filtering principle, each pixel out of default field of the pending pixel
Intermediate value is determined in pixel value, using the corresponding pixel value of the intermediate value, the pixel value of pending pixel is updated, to realize image
Filtering, it is multiple without each pixel value being ranked up and being grouped step by step etc. when determining the intermediate value of the pixel value of each pixel
Miscellaneous operation, you can quickly to determine intermediate value, so as to improve the efficiency of image filtering.
Wherein, the number of the pixel value for each pixel being calculated is looked into difference, and the number difference of numerical value minimum can
Multiple pixel values can be corresponded to, therefore the step 103 utilizes in the corresponding number difference of each pixel value, minimum of numerical value
The corresponding pixel value of number difference, the pixel value for updating the pending pixel may include:
In the corresponding number difference of each pixel value, when the number difference of numerical value minimum corresponds to multiple pixel values,
Using the average value of the multiple pixel value, the pixel value of the pending pixel is replaced;
In the corresponding number difference of each pixel value, when the number difference of numerical value minimum corresponds to a pixel value,
The pixel value of the pending pixel is replaced using one pixel value.
When i.e. the number difference of numerical value minimum corresponds to a pixel value, which is in each pixel value
Value;And the number difference of numerical value minimum is when corresponding to multiple pixel values, then using the average value of multiple pixel value as each pixel
The intermediate value of value, to recycle the intermediate value determined to replace the pixel value of pending pixel, to reduce pending pixel
Noise realizes image filtering.
Fig. 2 shows a kind of flow chart of another embodiment of image filtering method provided by the embodiments of the present application, the party
Method may include following steps:
201:Using the pixel value chosen successively in each pixel value as target pixel value, and with other pixel values into
Row compares.
It is that calculate separately its number to each pixel value successively poor when determining the corresponding number difference of each pixel value
It is worth, it, can be using a pixel value of selection as target pixel value in the present embodiment.By target pixel value and other pixel values into
Row compares one by one.
Wherein, other pixel values are the pixel value for not including the target pixel value in each pixel value;
202:First number of the pixel value in each pixel value more than the target pixel value is calculated, and less than described
Second number of the pixel value of target pixel value.
203:The number absolute value of the difference for calculating first number and second number, as the target pixel value
Number difference, to obtain the corresponding number difference of each pixel value.
Target pixel value is compared with other pixel values, it may be determined that go out the pixel value more than target pixel value
Number, i.e. first number;And the pixel value number less than target pixel value, i.e. second number.
Calculate the absolute value of the difference of first number and second number, as the number difference of target pixel value.To i.e.
Corresponding number difference when can obtain each pixel value as target pixel value.
204:Using in the corresponding number difference of each pixel value, the corresponding pixel of number difference of numerical value minimum
Value updates the pixel value of the pending pixel.
The corresponding pixel value of number difference of numerical value minimum is the intermediate value in each pixel value combination.
Using the intermediate value, median filter process is utilized, you can be updated with the pixel value to pending pixel value.
May include specifically:
In the corresponding number difference of each pixel value, when the number difference of numerical value minimum corresponds to multiple pixel values,
Using the average value of the multiple pixel value, the pixel value of the pending pixel is replaced;
In the corresponding number difference of each pixel value, when the number difference of numerical value minimum corresponds to a pixel value,
The pixel value of the pending pixel is replaced using one pixel value.
In the present embodiment, when being filtered to the pending pixel in image, it is first determined go out pending pixel
The pixel value of each pixel in default neighborhood, and in each pixel value, calculate the pixel more than each pixel value
It is worth the number difference of number and the pixel value number less than each pixel value, obtains corresponding of each pixel value
Number difference, so that it is determined that the corresponding pixel value of number difference for going out numerical value minimum is the intermediate value of each pixel value, according to intermediate value
The filtering to pending pixel can be realized using the intermediate value in filtering principle.Due to each pixel value of determination intermediate value when, nothing
Each pixel value need to be ranked up, and be grouped step by step so that reduced workload, improve computational efficiency, to improve
The efficiency of image filtering.
For each method embodiment above-mentioned, for simple description, therefore it is all expressed as a series of combination of actions, but
Be those skilled in the art should understand that, the application is not limited by the described action sequence because according to the application, certain
A little steps can be performed in other orders or simultaneously.Secondly, it those skilled in the art should also know that, is retouched in specification
The embodiment stated belongs to preferred embodiment, necessary to involved action and module not necessarily the application.
Fig. 3 is a kind of structural schematic diagram of image filtering method one embodiment provided by the embodiments of the present application, the device
May include:
Comparing unit 301 is used for the picture of each pixel in described image in the default neighborhood of pending pixel
Plain value is compared.
Computing unit 302, for calculating the pixel value number more than each pixel value and each pixel less than described in
The number difference of the pixel value number of value obtains the corresponding number difference of each pixel value.
Filter unit 303, for utilizing in the corresponding number difference of each pixel value, the number difference of numerical value minimum
Corresponding pixel value updates the pixel value of the pending pixel.
Default field refers to the nearby sphere of pending pixel, such as the 5*5 put centered on pending pixel
The region of region, i.e. 5 every trade pixels and 5 row row pixels composition, pending pixel are the central point in the region.
The predeterminable area can be determined according to practical situations.
It includes the pending pixel that pending pixel, which presets each pixel in field not,.
The pixel value number that the number difference may be greater than each pixel value is subtracted less than each described pixel value
Pixel value number obtain the absolute value of difference;Or it is subtracted more than each less than the pixel value number of each pixel value
The pixel value number of a pixel value obtains the absolute value of difference.
The corresponding pixel value of number difference of numerical value minimum is the intermediate value of each pixel value, to utilize the intermediate value,
The pixel value of pending pixel can be updated.
In embodiment, it is based on medium filtering principle, the picture of each pixel out of default field of the pending pixel
Intermediate value is determined in plain value, using the corresponding pixel value of the intermediate value, updates the pixel value of pending pixel, to realize that image is filtered
Wave, when determining the intermediate value of the pixel value of each pixel, without the complexity such as each pixel value being ranked up and being grouped step by step
Operation, you can quickly to determine intermediate value, so as to improve the efficiency of image filtering.
Wherein, the number of the pixel value for each pixel being calculated is looked into difference, and the number difference of numerical value minimum can
Multiple pixel values can be corresponded to, therefore, which may include:
First filter unit, for working as in the corresponding number difference of each pixel value, the number difference of numerical value minimum
When corresponding multiple pixel values, using the average value of the multiple pixel value, the pixel value of the pending pixel is replaced.
Second filter unit, for working as in the corresponding number difference of each pixel value, the number difference of numerical value minimum
When a corresponding pixel value, the pixel value of the pending pixel is replaced using one pixel value.
When i.e. the number difference of numerical value minimum corresponds to a pixel value, which is in each pixel value
Value;And the number difference of numerical value minimum is when corresponding to multiple pixel values, then using the average value of multiple pixel value as each pixel
The intermediate value of value, to recycle the intermediate value determined to replace the pixel value of pending pixel, to reduce pending pixel
Noise realizes image filtering.
In yet another embodiment, as shown in figure 4, the comparing unit 301 in the image filtering device can be specifically used for
Using the pixel value chosen successively from each pixel value as target pixel value, and by the target pixel value and other pictures
Plain value is compared;Wherein, other pixel values are the pixel value for not including the target pixel value in each pixel value.
Computing unit 302 may include:
Counting unit 401, first number for calculating the pixel value in each pixel value more than the target pixel value,
And second number of the pixel value less than the target pixel value;
Difference computational unit 402, for calculating first number and second number absolute value of the difference, as described
The number difference of target pixel value, to obtain the corresponding number difference of each pixel value.
Wherein, filter unit 303 may include:
First filter unit 403, in the corresponding number difference of each pixel value, the number of numerical value minimum to be poor
When value corresponds to multiple pixel values, the average value of the multiple pixel value is utilized, replaces the pixel value of the pending pixel;
Second filter unit 404, in the corresponding number difference of each pixel value, the number of numerical value minimum to be poor
When value corresponds to a pixel value, the pixel value of the pending pixel is replaced using one pixel value.
In the present embodiment, when being filtered to the pending pixel in image, it is first determined go out pending pixel
The pixel value of each pixel in default neighborhood, and in each pixel value, calculate the pixel more than each pixel value
It is worth the number difference of number and the pixel value number less than each pixel value, obtains corresponding of each pixel value
Number difference, so that it is determined that the corresponding pixel value of number difference for going out numerical value minimum is the intermediate value of each pixel value, according to intermediate value
The filtering to pending pixel can be realized using the intermediate value in filtering principle.Due to each pixel value of determination intermediate value when, nothing
Each pixel value need to be ranked up, and be grouped step by step so that reduced workload, improve computational efficiency, to improve
The efficiency of image filtering.
Software form reality may be used in practical applications in each unit of above-described embodiment described image filter
The existing, form of software plus hardware or example, in hardware are realized, therefore, as shown in figure 5, the embodiment of the present application also provides a kind of figures
As the structural schematic diagram of filter apparatus one embodiment, which may include:
First comparator 501 is used for each pixel in the pending pixel default neighborhood in described image
Pixel value is compared.
Calculator 502, for calculating the pixel value number more than each pixel value and each pixel value less than described in
Pixel value number number difference, obtain the corresponding number difference of each pixel value;
Second comparator 503 is used for the corresponding number difference of more each pixel value, determines the number of numerical value minimum
The corresponding pixel value of numerical value.
Filter 504, the pixel value for being determined using second comparator update the picture of the pending pixel
Element value.
As another embodiment, as shown in fig. 6, the first comparator 501 of the image filtering equipment can be specifically used for
The pixel value chosen successively in each pixel value is compared as target pixel value, and with other pixel values;Wherein,
Other pixel values are the pixel value for not including the target pixel value in each pixel value.
The calculator 502 may include:
Counter 601, for calculate in each pixel value be more than the target pixel value first number of pixel value, and
With second number of pixel value less than the target pixel value;
Subtracter 602, for calculating first number and second number absolute value of the difference, as the target picture
The number difference of element value, to obtain the corresponding number difference of each pixel value.
Filter 504 can be formed due to first filter 603 and second filter 604;
First filter 603, for working as in the corresponding number difference of each pixel value, the number difference of numerical value minimum
When corresponding multiple pixel values, using the average value of the multiple pixel value, the pixel value of the pending pixel is replaced;
Second filter 604, for working as in the corresponding number difference of each pixel value, the number difference of numerical value minimum
When a corresponding pixel value, the pixel value of the pending pixel is replaced using one pixel value.
The image filtering equipment of the embodiment of the present application, when being filtered to the pending pixel in image, it is first determined
Go out the pixel value of each pixel in pending pixel default neighborhood, and in each pixel value, calculates more than each
The number difference of the pixel value number of a pixel value and the pixel value number less than each pixel value, obtains each pixel
It is worth corresponding number difference, so that it is determined that the corresponding pixel value of number difference for going out numerical value minimum is each pixel value
The filtering to pending pixel can be realized using the intermediate value according to medium filtering principle in intermediate value.Due to each pixel of determination
It when the intermediate value of value, without being ranked up to each pixel value, and is grouped step by step so that reduce workload, improve calculating effect
Rate, to improve the efficiency of image filtering.
Each embodiment is described by the way of progressive in this specification, the highlights of each of the examples are with other
The difference of embodiment, just to refer each other for identical similar portion between each embodiment.For device disclosed in embodiment
For, since it is corresponded to the methods disclosed in the examples, so description is fairly simple, related place is said referring to method part
It is bright.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by
One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation
Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning
Covering non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only that
A little elements, but also include other elements that are not explicitly listed, or further include for this process, method, article or
The intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arranged
Except there is also other identical elements in the process, method, article or apparatus that includes the element.
For convenience of description, it is divided into various units when description apparatus above with function to describe respectively.Certainly, implementing this
The function of each unit is realized can in the same or multiple software and or hardware when application.
As seen through the above description of the embodiments, those skilled in the art can be understood that the application can
It is realized by the mode of software plus required general hardware platform.Based on this understanding, the technical solution essence of the application
On in other words the part that contributes to existing technology can be expressed in the form of software products, the computer software product
It can be stored in a storage medium, such as ROM/RAM, magnetic disc, CD, including some instructions are used so that a computer equipment
(can be personal computer, server either network equipment etc.) executes the certain of each embodiment of the application or embodiment
Method described in part.
The foregoing description of the disclosed embodiments enables professional and technical personnel in the field to realize or use the application.
Various modifications to these embodiments will be apparent to those skilled in the art, as defined herein
General Principle can in other embodiments be realized in the case where not departing from spirit herein or range.Therefore, the application
It is not intended to be limited to the embodiments shown herein, and is to fit to and the principles and novel features disclosed herein phase one
The widest range caused.