The present disclosure relates to image processing, more particularly to a method and electronic apparatus of processing image data.
Upsampling interpolation is a general method of increasing or recovering the resolution of an image. It increases the size of pixels in the image, and based on the colors, uses an algorithm to calculate the color of lost pixel. The common interpolation includes, for example, nearest pixel neighbor interpolation, bilinear interpolation, bicubic interpolation, Lagrange interpolating polynomial, Newton interpolating polynomial. However, these interpolations are basically based on mathematical formulas, and they do not take patterns and features of the image into account. Thus, after the resolution of the image is increased or recovered by these interpolations, the patterns and the features of the image are looks stiff and unnatural.
One embodiment of the present disclosure provides a method and electronic apparatus for processing image data, for solving the problem in the traditional technique that the patterns and features of the image are looks unnatural after the resolution of the image is increased or recovered.
One embodiment of the present disclosure provides a method of processing image data, the method includes:
taking an inserted pixel as a center point, and determining neighbor pixels of the center point;
calculating and obtaining gradient magnitudes and directions of each neighbor pixel;
calculating correlations between each neighbor pixel and the center point according to the directions of each neighbor pixel;
considering the gradient magnitudes of each neighbor pixel and the correlations between the gradient magnitudes and the center point to obtain gray scale of the center point (i.e. the gray scale of the inserted pixel);
taking the other inserted pixels each as a center point to obtain gray scale thereof, and determining color of each inserted pixel according to all the gray scales of the inserted pixels; and
obtaining an image with increased resolution according to each inserted pixel and the color thereof and original pixels and the color thereof;
wherein, the correlation is determined by whether the direction of the neighbor pixel passes through the center point and the position in which the direction of the neighbor pixel passes through the center point.
One embodiment of the present disclosure provides a non-volatile computer storage medium capable of storing computer-executable instruction. The said computer-executable instruction is used for performing any one of the steps in above.
One embodiment of the present disclosure provides an electronic apparatus, includes: at least one processor and memory; wherein the memory stores at least one process which can be performed by the processor. The computer-executable instruction is performed by the at least one processor so that the at least one processor can perform any one of the step as discussed in above.
One or more embodiments are illustrated by way of example, and not by limitation, in the figures of the accompanying drawings, wherein elements having the same reference numeral designations represent like elements throughout. The drawings are not to scale, unless otherwise disclosed.
For more clearly illustrating the purpose, technology and advantages of the present disclosure, the following paragraphs and related drawings are provided for thoroughly describing the features of the embodiments of the present disclosure. It is evident that these embodiments are merely illustrative and not exhaustive embodiments of the present disclosure. Based on the embodiments in the present disclosure, the other embodiments conceived by the people skilled in the art without putting inventive effort fall within the scope of the present disclosure.
One embodiment of the present disclosure provides a method and electronic apparatus of processing image data for processing image resolution. Upsampling Interpolation is a general method used to increase or recover the image resolution of an image. By computing color references of neighbor pixels around inserted pixel through formula to obtain gray scale of the inserted pixel. The related computing method includes nearest pixel neighbor interpolation, Bilinear Interpolation, or Bicubic Interpolation. etc, but these methods only take the color references of the neighbor pixels, e.g. gray scale, into account, but do not take patterns and features of the whole image into account. Therefore, the color of the inserted pixels generated by the aforementioned methods can not be fitted into the original image very well, which makes the patterns and the features of the image with increased image resolution looks weird and unnatural.
One embodiment of the present disclosure provides a method and electronic apparatus of processing image data in order to overcome the aforementioned problems. The method includes: obtaining gradient magnitudes and directions of neighbor pixels around the inserted pixel to predict patterns and features of the whole image around the inserted pixel; and then calculating gray scale of the inserted pixel by fully considering the patterns and features of the image. Therefore, color of the inserted pixel can be well fitted into the color of the original image, so the image with increased or recovered image resolution has the patterns and features of the original one, and the image looks more natural when it is at a close look.
In addition, the method and electronic apparatus of the present disclosure can be adapted to video processing or other image processing related fields, but the present disclosure is not limited thereto.
Please refer to
S101: taking an inserted pixel as a center point to determine neighbor pixels of the center point;
S102: calculating and obtaining gradient magnitudes and directions of each neighbor pixel;
S103: calculating correlations between each neighbor pixel and the center point according to the directions of each neighbor pixel;
S104: considering the gradient magnitudes of each neighbor pixel and the correlations between the gradient magnitudes and the center point to obtain gray scale of the center point (i.e. the gray scale of the inserted pixel);
S105: taking the other inserted pixels each as a center point to obtain gray scale thereof, and determining color of each inserted pixel according to all the gray scales of the inserted pixels; and
S106: obtaining an image with increased resolution according to each inserted pixel and the color thereof and original pixels and the color thereof;
wherein, the correlation is determined by whether the direction of the neighbor pixel passes through the center point and the position where the direction of the neighbor pixel passes through the center point.
In the step S101, an inserted pixel needed to be determined its gray scale is taken as a center point. Original pixels around the center point are taken as neighbor pixels, or the original pixels around the center point and the inserted pixels which have been calculated their gray scales are taken as neighbor pixels. For example, for an inserted pixel p0 in
In step S102, according to the neighbor pixels determined in the step 101, gradient magnitudes and directions of each neighbor pixel are calculated. For example, as shown in
In step S103, whether the neighbor pixel passes through the center point and the position in which the neighbor pixel passes through the center point are determined according to the directions of the neighbor pixel. For example, correlation between the neighbor pixel and the center point is determined by taking whether the direction of the neighbor pixel passes through the center point or the periphery of the center point into account.
In step S104, gray scale of the center point is determined according to the gradient magnitudes of the neighbor pixels provided by the step S102 and the correlations between neighbor pixels and the center point provided by the step S103, that is, the gray scale of the currently inserted pixel is determined.
In step S105, gray scales of the other inserted pixels are determined by following the steps S101-104, and color of each inserted pixel is determined by the gray scale of each inserted pixel. Finally, in step S106, the image with increased or recovered image resolution is obtained.
The following is an embodiment for explaining the step S102.
In step S102, the gradient magnitudes of the neighbor pixels can be obtained by calculating gradients of the neighbor pixel in x-direction and y-direction, and there are many ways to calculate gradients of the neighbor pixel in x-direction and y-direction, e.g. Sobel operator, Scharr operator, Laplace operator, Prewitt operator. etc. The present embodiment takes the Sobel operator as an example for explaining gradients calculating:
For satisfying the order of the four quadrants in common mathematical functions, it is determined that positive number is on the right side of the x-direction operator, negative number is on the left side of the x-direction operator, that positive number is on the top side of the y-direction operator, negative number is on the bottom side of the y-direction operator. Neighbor pixel p1 in
gradient dxp
gradient dyp
then, gradient magnitude dp
then, a direction θp
The following is an embodiment for explaining step S103.
For each neighbor pixel, whether its direction or an extending direction of its opposite direction passes through the center point can be used to determine whether the pattern of the image on the neighbor pixel should be taken as a reference of determining gray scale of the center point. For example, in
In this embodiment, each neighbor pixel is defined as a 1×1 square, if a direction θp
Please refer to
When a direction or an extending direction of the neighbor pixel p1 is within the aforementioned range, the neighbor pixel p1 and the center point p0 are determined to be related, and the neighbor pixel p1 is marked with respective correlation symbol. The correlation symbol is used to represent that the direction or the extending direction of the neighbor pixel passes through the center point.
As discussed in above, the correlation between the neighbor pixel and the center point is further related to the position in which the neighbor pixel passes through the center point. For example, in
The correlation levels cp
In this embodiment, correlation between each neighbor pixel and the center point is confirmed by analyzing the correlation symbol and the correlation level between the neighbor pixels and the center point, for providing references to the later process of calculating gray scale of the center point.
The present embodiment provides an exemplary calculation in related to correlation symbol and correlation lever between the neighbor pixels and the center point, but the present disclosure is not limited thereto, other calculations in related to determining correlation symbol and correlation level fall within the scope of the present disclosure.
The following is an embodiment for explaining the step S104.
In this embodiment, the step S104 further includes: calculating gray scale of the center point according to
wherein p0 represents the gray scale of the center point, n represents number of the neighbor pixel, dp
In this embodiment, according to the gradient magnitudes of each neighbor pixel and the correlations between the neighbor pixels and the center point provided by the steps S102-103, gray scale of the center point is obtained, in this embodiment, correlations between the neighbor pixels and the center point is confirmed by both the correlations and the correlation level, but this is exemplary, the present disclosure is not limited thereto, other ways to confirm the correlation between the neighbor pixels and the center point fall within the scope of the present disclosure.
When neighbor pixel of the neighbor pixels provided by the step S101 is confirmed to have correlations with the center point, gray scale of the center point can be determined by gradient magnitudes and directions of each neighbor pixel having correlations with the center point. In addition, there is an extreme situation, that is, when the neighbor pixel provided by the step S101 and the center point do not have correlation therebetween, the way of confirming the gray scale of the center point provided in this embodiment is not applicable.
The following are more embodiments for explaining the way to confirm the gray scale of the center point when the neighbor pixels and the center point provided by the step S101 do not have correlation therebetween.
In one embodiment, if all the neighbor pixels provided by step S101 and the center points do not have correlation, average gray scale of each neighbor pixel is calculated, and the average gray scale is taken as the gray scale of the center point. For example, if all the gray scales of the neighbor pixels are the same, the gray scale of the inserted pixel can be obtained by the way mentioned in the present embodiment.
In another embodiment, if all the neighbor pixels provided by step S101 and the center points do not have correlation, the number of the neighbor pixels can be increased, so gray scale of the center point can be calculated according to the correlations between the gradient magnitude of the added neighbor pixels and the center point. For example, the number of the neighbor pixels around the center point can be increased from 6 to 14, the number can still be increased if the neighbor pixels and the center point have no correlation therebetween.
When the neighbor pixels and the center point have correlations therebetween, gray scale of the center point is determined according to the gradient magnitudes and directions of the neighbor pixels having correlations with the center point.
An example of enlarging a 5×4 image to a 7×7 image is described in below for detail explaining embodiments of the present disclosure.
As shown in
of p1 are calculated to determine the relationship between p1 and p0 so as to mark correlation symbol sp
Correlation level of p1 is calculated, and correlation between p1 and p0 are determined according to correlation symbol and correlation level of p1. Then, correlations between gradient magnitudes of p2-p6 and p0 can be obtained by following the same way, and thereby obtaining gray scale of p0.
Then, gray scale of each horizontal inserted pixel and gray scale of each vertical inserted pixel can be determined by following the aforementioned methods, and then color of each inserted pixel can be determined according to the setting of the gray scale of each inserted pixel, so the enlarged image (7×7 image) is composed by the original pixel and the inserted pixels which are fitted into color of the original pixel. Therefore, the patterns and features of the enlarged image are looks natural.
Please refer to
a setting module 11 used to take an inserted pixel as a center point and determine neighbor pixels of the center point;
a gradient-direction calculation module 12 used to obtain directions and gradient magnitudes of each neighbor pixel;
a correlation calculation module 13 used to calculate correlations between each neighbor pixel and the center point according to the directions of each neighbor pixel;
a gray scale calculation module 14 used to consider the gradient magnitudes of each neighbor pixel and the correlations between the gradient magnitudes and the center point to obtain gray scale of the center point (i.e. the gray scale of the inserted pixel);
a dispatch module 15 used to take the other inserted pixels each as a center point to obtain gray scale thereof, and determine color of each inserted pixel according to all the gray scales of the inserted pixels;
an interpolation module 16 used to obtain an image with increased image resolution according to each inserted pixel and the color thereof and original pixels and the color thereof;
wherein, the correlation is determined by whether the direction of the neighbor pixel passes through the center point and the position in which the direction of the neighbor pixel passes through the center point;
wherein, in the setting module 11, the inserted pixel needed to be determined it's gray scale is taken as a center point, according to the position of the center point, pixels around the original pixel are taken as neighbor pixels, or the neighborhood original pixel and the inserted pixels with determined gray scales can be taken as neighbor pixels. For an example in
In the gradient-direction calculation module 12, directions and gradient magnitudes of each neighbor pixel is determined according to the neighbor pixels provided by the step S101, for example, gradient magnitudes and directions of neighbor pixels p1, p2, p3, p4, p5, p6 in
In the correlation calculation module 13, whether the neighbor pixel passes through the center point and the position of the neighbor pixel where the neighbor pixel passes through the center point are determined according to the directions of the neighbor pixel. For example, the correlation between the neighbor pixel and the center point is determined by whether the direction of the neighbor pixel passes through the center point or the periphery of the center point.
In the gray scale calculation module 14, gray scale of the center point is determined according to the gradient magnitudes of each neighbor pixel provided by the gradient-direction calculation module 12 and the correlations between each neighbor pixel and the center point provided by the correlation calculation module 13. That is, the gray scale of the currently inserted pixel is determined.
In the dispatch module 15, gray scales of the other inserted pixels are determined by the gradient-direction calculation module 12, the correlation calculation module 13, and the gray scale calculation module 14, and color of each inserted pixel is determined by the gray scale of each inserted pixel. Finally, the interpolation module 16 obtains a new image with increased or recovered image resolution is obtained.
There is an embodiment for explaining the gradient-direction calculation module in detail.
In the gradient-direction calculation module 12, the gradient magnitudes of the neighbor pixel can be obtained according to gradients of the neighbor pixel in x-direction and y-direction. There are many methods of calculating gradients of the neighbor pixel in x-direction and y-direction, e.g. Sobel operator, Scharr operator, Laplace operator, Prewitt operator. etc. In this embodiment, the Sobel operator is taken as an example:
The gradient-direction calculation module 12 is further used to:
calculate gradient dxp
calculate gradient dyp
calculate gradient magnitude dp
calculate direction θp
There is an embodiment for explaining the correlation calculation module 13.
For each neighbor pixel, whether its direction or an extending direction of its opposite direction passes through the center point can be used to determine whether the pattern of the image on the neighbor pixel should be taken as a reference of determining gray scale of the center point, for example, in
In this embodiment, the correlation calculation module 13 is further used to: define each neighbor pixel as a 1×1 square, wherein if the direction θp
Please refer to
When the direction or the extending direction of the neighbor pixel p1 is within the aforementioned range, the neighbor pixel p1 and the center point p0 determined to be correlated, and the neighbor pixel p1 is marked with a respective correlation symbol. The correlation symbol is used to represent that the direction or the extending direction of the neighbor pixel passes the center point.
As discussed in above, the correlation between the neighbor pixel and the center point is further related to the position in which the neighbor pixel passes through the center point. For example, in
calculate the correlation levels cp
In this embodiment, the correlation levels cp
In this embodiment, correlation between each neighbor pixel and the center point is determined by analyzing the correlation symbol and the correlation level between the neighbor pixels and the center point, for providing references to the later process of calculating gray scale of the center point.
The present embodiment only provides exemplary calculation in related to correlation symbols of the neighbor pixels and correlation levels between neighbor pixels and the center point, but the present disclosure is not limited thereto, other calculations in related to determine correlation symbol and correlation level fall within the scope of the present disclosure.
The following is an embodiment for explaining the gray scale calculation module 14.
In this embodiment, the gray scale calculation module 14 is further used to:
calculate gray scale of the center point according to
wherein p0 represents the gray scale of the center point, n represents the number of the neighbor pixels, dp
In this embodiment, according to the gradient magnitudes of each neighbor pixel and correlations between the neighbor pixels and the center point provided by the gradient-direction calculation module 12 and the correlation calculation module 13, gray scale of the center point is obtained, In this embodiment, the correlation between the neighbor pixel and the center point is confirmed by both the correlations and the correlation level, but this is exemplary, the present disclosure is not limited thereto, other ways to confirm the correlations between the neighbor pixels and the center point fall within the scope of the present disclosure.
When the neighbor pixels provided by the setting module 11 include any pixel has correlations with the center point, gray scale of the center point can be determined by gradient magnitudes and directions of each neighbor pixel having correlations with the center point. In addition, for an extreme case where the neighbor pixels provided by the setting module 11 and the center point do not have correlation therebetween, the way of confirming the gray scale of the center point provided in this embodiment is not applicable.
There are more embodiments for explaining how to confirm the gray scale of the center point when the neighbor pixel provided by the setting module 11 and the center point do not have correlation.
In one embodiment, the gray scale calculation module 14 is further used to: if all the neighbor pixels and the center point do not have correlation, an average gray scale of the neighbor pixels is calculated to be taken as the gray scale of the center point. For example, if all the gray scales of the neighbor pixels are the same value, the gray scale of the inserted pixel can be obtained by the way mentioned in the present embodiment.
In another embodiment, the gray scale calculation module 14 is further used to:
if all the neighbor pixels and the center point do not have correlation, the number of the neighbor pixels can be increased, so gray scale of the center point can be calculated according to the gradient magnitudes of the neighbor pixels and the correlations between the neighbor pixels and the center point.
For example, the number of the neighbor pixels around the center point can be increased from 6 to 14, the number can still be increased if the neighbor pixels and the center point have no correlation therebetween. When the neighbor pixels and the center point have correlations therebetween, gray scale of the center point is determined according to the gradient magnitudes and directions of the neighbor pixels having correlations with the center point.
One embodiment of the present disclosure provides a non-volatile computer storage medium capable of storing computer-executable instruction. The said computer-executable instruction is used for performing any one of the steps in above.
The electronic apparatus includes: an input device 53 and an output device 54.
The processor 51, the memory 52, the input device 53 and the output device 54 can be connected to each other via a bus or other members for electrical connection. In
Wherein, the memory 52 stores process which is executable by the processor, the computer-executable instruction is used for the processor 51 to perform so that the at least one processor 51 can execute any one of the steps provided by the image processing methods.
The memory 52 is one kind of non-volatile computer-readable storage mediums applicable to store non-volatile software programs, non-volatile computer-executable programs and modules; for example, the program instructions and the function modules (the setting module 11, the gradient-direction calculation module 12, the correlation calculation module 13, the gray scale calculation module 14, the dispatch module 15 and the interpolation module 16 in
The memory 52 can include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application program required for a function; the data storage area can store the data created according to the usage of the device for intelligent recommendation. Furthermore, the memory 52 can include a high speed random-access memory, and further include a non-volatile memory such as at least one disk storage member, at least one flash memory member and other non-volatile solid state storage member. In some embodiments, the memory 52 can have a remote connection with the processor 51, and such memory can be connected to the device of the present disclosure by a network. The aforementioned network includes, but not limited to, internet, intranet, local area network, mobile communication network and combination thereof.
The input device 53 can receive digital or character information, and generate a key signal input corresponding to the user setting and the function control of the device for intelligent recommendation. The output device 54 can include a displaying unit such as screen.
The one or more modules are stored in the memory 52. When the one or more modules are executed by one or more processor 51, the methods disclosed in any one of the embodiments is performed.
The aforementioned product can perform the method of the present disclosure, and has function module for performing it. The details not thoroughly illustrated in this embodiment can be referenced via the methods in the present disclosure.
The electronic apparatus in the embodiments of the present application is presence in many forms, and the electronic apparatus includes, but not limited to:
(1) Mobile communication apparatus: characteristics of this type of device are having the mobile communication function, and providing the voice and the data communications as the main target. This type of terminals include: smart phones (e.g. iPhone), multimedia phones, feature phones, and low-end mobile phones, etc.
(2) Ultra-mobile personal computer apparatus: this type of apparatus belongs to the category of personal computers, there are computing and processing capabilities, generally includes mobile Internet characteristic. This type of terminals include: PDA, MID and UMPC equipment, etc., such as iPad.
(3) Portable entertainment apparatus: this type of apparatus can display and play multimedia contents. This type of apparatus includes: audio, video player (e.g. iPod), handheld game console, e-books, as well as smart toys and portable vehicle-mounted navigation apparatus.
(4) Server: an apparatus provide computing service, the composition of the server includes processor, hard drive, memory, system bus, etc, the structure of the server is similar to the conventional computer, but providing a highly reliable service is required, therefore, the requirements on the processing power, stability, reliability, security, scalability, manageability, etc. are higher.
(5) Other electronic apparatus having a data exchange function.
The aforementioned embodiments are exemplary, the description of separated units can be physically connected, and the unit capable of displaying image can not be a physical unit, that is, it can be located on a place or distributed to plural internet units. It is selectively to select a part or all of the modules for achieving the purpose of the present disclosure.
By the aforementioned embodiments, the people skilled in the art can thoroughly understand that the embodiments can be implemented by software and hardware platform. Accordingly, the technique, features or the part having contribution can be embodied through software product, the software product can be stored in computer readable medium, such as ROM/RAM, hard disk, optical disc, including one or more instructions so that a computing apparatus (e.g. personal computer, server, or internet apparatus can execute each embodiment or some methods discussed the embodiments.
It is further noted that: the embodiments in above are only used to explain the features of the present application, but not used to limit the present application; although the present application is explained by the embodiments, the people skilled in the art would know that the features in the aforementioned embodiments can be modified, or a part of the features can be replaced, and the features relating to these modification or replacement are still in the scope and spirit of the present application.
Number | Date | Country | Kind |
---|---|---|---|
201510892175.2 | Dec 2015 | CN | national |
This application is a continuation of International Application No. PCT/CN2016/088652, filed on 5 Jul. 16, which is based upon and claims priority to Chinese Patent Application No. 201510892175.2, filed on 7 Dec. 15, the entire contents of which are incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2016/088652 | Jul 2016 | US |
Child | 15247213 | US |