Image processing method and device, electronic equipment and storage medium

By obtaining the categories in the neighborhood of the pixel before scaling in the image processing and redetermining the pixel category after scaling, the processing inaccuracy caused by category changes after scaling is solved, and the accuracy and output quality of the image processing are improved.

CN119445225AActive Publication Date: 2025-02-14ZHUHAI PANTUM ELECTRONICS CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411514256.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-02-14
Estimated Expiration
2044-10-28

AI Technical Summary

Technical Problem

In image processing, the category of pixels may change after the scaling operation, resulting in inaccurate subsequent processing, especially in cases where multiple categories are included.

Method used

By obtaining the categories of pixels in the neighborhood of the pixel before scaling, using bilinear difference calculation or other methods to redetermine the scaled pixel category to ensure accurate identification of category changes.

Benefits of technology

It effectively reduces the processing inaccuracy caused by category changes after scaling, and improves the accuracy and output quality of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119445225A_ABST
    Figure CN119445225A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an image processing method and device, electronic equipment and a storage medium. The method comprises the steps that the category of each to-be-processed pixel in image data is determined; performing first optimization processing on the image data according to the category of each to-be-processed pixel to obtain first image data; performing zooming-out or zooming-in processing on the first image data to obtain second image data; the method is characterized by further comprising the following steps: taking any pixel to be processed in the first image data as a target pixel, and acquiring the category of each pixel in the neighborhood of the target pixel; and according to the category of each pixel in the neighborhood of the target pixel, determining a mode of acquiring the category of the corresponding to-be-processed pixel in the second image data. According to the embodiment of the invention, category determination can be carried out on the zoomed pixels again in different modes, and the problem of inaccurate subsequent processing caused by category change after zooming is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image forming technology, and in particular to an image processing method, device, electronic device and storage medium. Background Art

[0002] In the field of image formation, there is a technology called pipeline processing, which is a technology that associates image processing modules such as data compression, data decompression, color space conversion and halftoning in a certain order so as to perform image processing on input image data in sequence.

[0003] In traditional pipeline processing technology, the content feature recognition module can identify the category (hereinafter referred to as tag) of each pixel based on the input RGB data, such as whether it is an edge pixel, text, or image, etc. After identifying the category, the subsequent pipeline module can perform different processing based on different tags. For example, the pixels after the tag is identified can be rotated, scaled, filtered, and other processing in sequence.

[0004] However, after scaling, the pixel tags may change. For example, in an N×N image, the N×N region contains text tags and image tags, that is, the tags in the region are not uniform. At this time, if the N×N image is reduced to 1×1, the reduced tag value cannot be confirmed whether it is an image or text; similarly, enlarging 1×1 to N×N may also cause the tag to change. Summary of the invention

[0005] In view of this, the present application provides an image processing method, apparatus, electronic device and storage medium for redetermining the category of pixels after scaling is performed.

[0006] In a first aspect, an embodiment of the present application provides an image processing method, comprising:

[0007] Determining the category of each pixel to be processed in the image data;

[0008] Performing a first optimization process on the image data according to the category of each pixel to be processed to obtain first image data;

[0009] Performing reduction or enlargement processing on the first image data to obtain second image data;

[0010] Wherein, the method further comprises:

[0011] Taking any pixel to be processed in the first image data as a target pixel, obtaining the category of each pixel in the neighborhood of the target pixel;

[0012] A method for obtaining the category of the corresponding pixel to be processed in the second image data is determined according to the category of each pixel in the neighborhood of the target pixel.

[0013] In a possible implementation manner, the method of determining, according to the category of each pixel in the neighborhood of the target pixel, to obtain the category of the corresponding pixel to be processed in the second image data includes:

[0014] Determining the number of pixels of the first category and the number of pixels of the second category in the neighborhood of the target pixel according to the category of each pixel in the neighborhood of the target pixel;

[0015] If the number of pixels of the first category or the number of pixels of the second category in the neighborhood of the target pixel is greater than a preset threshold, the category of the corresponding pixel to be processed in the second image data is obtained according to a first method, wherein the first method is a bilinear difference calculation method.

[0016] In a possible implementation, the method further includes:

[0017] If the number of pixels of the first category and the number of pixels of the second category in the neighborhood of the target pixel are both less than or equal to the preset threshold, the category of the corresponding pixel to be processed in the second image data is obtained according to a second method.

[0018] In a possible implementation manner, the acquiring, according to the second manner, the category of the corresponding pixel to be processed in the second image data includes:

[0019] Determine a first attribute of a category of a corresponding pixel to be processed in the second image data according to a first attribute of a category of pixels in a neighborhood of the target pixel, wherein the first attribute includes a grayscale attribute and a normal attribute;

[0020] Determining a second attribute of a category of a corresponding pixel to be processed in the second image data according to a gradient value of the corresponding pixel to be processed in the second image data, wherein the second attribute includes text, line array, image and / or background;

[0021] The category of the corresponding pixel to be processed in the second image data is determined according to the first attribute and the second attribute of the category of the corresponding pixel to be processed in the second image data.

[0022] In a possible implementation, determining the first attribute of the category of the corresponding pixel to be processed in the second image data according to the first attribute of the category of the pixel in the neighborhood of the target pixel, wherein the first attribute includes a grayscale attribute and a normal attribute, includes:

[0023] Determine the number of pixels whose first attribute of the category is a grayscale attribute and the number of pixels whose first attribute of the category is a normal attribute in the neighborhood of the target pixel;

[0024] When the number of pixels of the grayscale attribute is greater than the number of pixels of the normal attribute, the first attribute of the category of the corresponding pixel to be processed in the second image data is adjusted to the grayscale attribute; when the number of pixels of the grayscale attribute is less than or equal to the number of pixels of the normal attribute, the first attribute of the category of the corresponding pixel to be processed in the second image data is adjusted to the normal attribute.

[0025] In a possible implementation manner, determining the second attribute of the category of the corresponding pixel to be processed in the second image data according to the gradient value of the corresponding pixel to be processed in the second image data includes:

[0026] Obtaining a gradient value of a corresponding pixel to be processed in the second image data;

[0027] A second attribute of the category of the corresponding pixel to be processed is determined according to the gradient value.

[0028] In a possible implementation, performing reduction or enlargement processing on the first image data to obtain the second image data further includes:

[0029] The first image data is subjected to reduction and / or rotation processing, or enlargement and / or rotation processing, to obtain the second image data, wherein when the first image data is subjected to rotation processing, the category of each pixel to be processed in the first image data is rotated synchronously with the corresponding pixel to be processed in the first image data.

[0030] In a possible implementation manner, determining the category of each to-be-processed pixel in the image data includes:

[0031] Taking any pixel in the image data whose RGB value is greater than the RGB value of the background pixel as a first pixel, and assigning a value to the first pixel;

[0032] Performing edge detection on the first pixel after the assignment to obtain a gradient value of the first pixel;

[0033] determining an initial second attribute of the category of the first pixel based on the gradient value;

[0034] adjusting the initial second attribute of the category of the first pixel based on the initial second attribute of the category of the pixels in the connected domain of the first pixel to obtain the second attribute of the category of the first pixel;

[0035] Determine a first attribute of the category of the first pixel according to the RGB mean value of pixels in the neighborhood of the first pixel;

[0036] The category of each to-be-processed pixel in the image data is determined according to a first attribute of the category of each first pixel and a second attribute of the category of each first pixel.

[0037] In a possible implementation manner, determining the initial second attribute of the category of the first pixel based on the gradient value includes:

[0038] Determining whether the first pixel is a line queue by using a preset fixed template;

[0039] determining an initial second attribute of the category of the first pixel being a line team as a line team;

[0040] Determine the gradient value range of the first pixel that is not a line team;

[0041] An initial second attribute of the category of the first pixel is determined to be text, image or background according to the gradient value range of the first pixel.

[0042] In a possible implementation manner, adjusting the initial second attribute of the category of the first pixel based on the initial second attribute of the category of pixels in the connected domain of the first pixel includes:

[0043] Obtaining the number of pixels whose initial second attribute of a category in a connected domain of the first pixel is a line queue;

[0044] The initial second attribute of the category of the first pixel whose number of pixels is greater than the first preset value and whose initial second attribute is text is adjusted to a line queue.

[0045] In a possible implementation manner, adjusting the initial second attribute of the category of the first pixel based on the initial second attribute of the category of pixels in the connected domain of the first pixel includes:

[0046] Acquire an initial second attribute of a category in a connected domain of the first pixel, which is the number of pixels in the image;

[0047] The initial second attribute of the category of the first pixels whose number of pixels is greater than the second preset value and whose initial second attribute is text is adjusted to image.

[0048] In a possible implementation manner, after obtaining the second image data, the method further includes:

[0049] Adaptive filtering is performed on the second image data based on the category of each pixel to be processed in the second image data, wherein the adaptive filtering includes descreening, text sharpening, and line contrast enhancement and sharpening.

[0050] In a possible implementation manner, after obtaining the second image data, the method further includes:

[0051] The black text area of ​​the second image data is subjected to ink saving processing based on the category of each to-be-processed pixel in the second image data.

[0052] In a possible implementation manner, after obtaining the second image data, the method further includes:

[0053] The second image data is subjected to color trapping processing based on the category of each to-be-processed pixel in the second image data.

[0054] In a possible implementation manner, after obtaining the second image data, the method further includes:

[0055] A brightening process is performed on a portrait area of ​​the second image data based on a category of each to-be-processed pixel in the second image data.

[0056] In a possible implementation manner, after obtaining the second image data, the method further includes:

[0057] For pixels whose first attribute of the category is a grayscale attribute, only black toner is used for the image forming operation.

[0058] In a second aspect, an embodiment of the present application provides an image processing device, including:

[0059] A first determining unit, used to determine the category of each pixel to be processed in the image data;

[0060] A first optimization processing unit, configured to perform a first optimization process on the image data according to the category of each pixel to be processed, so as to obtain first image data;

[0061] A reduction or enlargement processing unit, configured to perform reduction or enlargement processing on the first image data to obtain second image data;

[0062] Wherein, the device further comprises:

[0063] An acquisition unit, configured to take any pixel to be processed in the first image data as a target pixel and acquire the category of each pixel in a neighborhood of the target pixel;

[0064] The second determining unit is used to determine a method for obtaining the category of the corresponding pixel to be processed in the second image data according to the category of each pixel in the neighborhood of the target pixel.

[0065] In a third aspect, an embodiment of the present application provides an electronic device, including:

[0066] processor;

[0067] Memory;

[0068] A computer program is stored in the memory, and when the computer program is executed, the electronic device executes any one of the methods described in the first aspect.

[0069] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute any method described in the first aspect.

[0070] Compared with the prior art, the embodiments of the present application can use different methods to re-determine the categories of pixels after scaling, thereby reducing the problem of inaccurate subsequent processing due to category changes after scaling. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0072] Figure 1 It is a schematic diagram of an image pipeline processing flow in the related technology;

[0073] Figure 2 A flowchart of an image processing method provided in an embodiment of the present application;

[0074] Figure 3 A schematic diagram of a process for determining the category of a pixel to be processed provided in an embodiment of the present application;

[0075] Figure 4 A schematic diagram of a process for determining an initial second attribute of a category of a first pixel provided in an embodiment of the present application;

[0076] Figure 5 A schematic diagram of a line team provided in an embodiment of the present application;

[0077] Figure 6 A schematic diagram of the structure of an image processing device provided in an embodiment of the present application;

[0078] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0079] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0080] It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0081] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0082] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0083] In the field of image formation, there is a technology called pipeline processing, which is a technology that links image processing modules such as data compression, data decompression, color space conversion, and halftoning in a certain order so that image processing can be performed sequentially on input image data. Figure 1 , is a schematic diagram of an image pipeline processing flow in the related technology. Figure 1 As shown, the image pipeline processing flow includes a scanning data input interface, a printing data input interface, a printing output interface, and a content feature recognition module, a rotation and scaling module, a filtering module, a scanning module, a sharpening module, etc. arranged between the interfaces. The image data can be transferred between the modules in the direction indicated by the arrows in the figure to realize scanning, printing, copying and other functions.

[0084] like Figure 1As shown, in the traditional pipeline processing technology, the content feature recognition module can identify the category (hereinafter referred to as tag) to which each pixel belongs based on the input RGB data, for example: whether it is an edge pixel, whether it is text, whether it is a picture, etc. Specifically, the pixel can be judged by the pixel features of the other 8 pixels around the pixel in the 3×3 range. After identifying the category, the subsequent pipeline module can perform different processing according to different tags. For example, the pixels after the tag is identified can be rotated, scaled, filtered, and processed in turn.

[0085] However, after scaling, the pixel tags may change. For example, in an N×N image, the N×N region contains text tags and image tags, that is, the tags in the region are not uniform. At this time, if the N×N image is reduced to 1×1, the reduced tag value cannot be confirmed whether it is an image or text; similarly, enlarging 1×1 to N×N may also cause the tag to change.

[0086] It should be noted that Figure 1 The specific principles and functions of each module can be referred to the content description in the relevant technology. For the sake of brevity, the embodiments of the present application will not be repeated here.

[0087] In view of the above problems, the present application proposes an image processing method, device, electronic device and storage medium. The embodiments of the present application can re-classify the scaled pixels according to the categories of the pixels in the neighborhood of the pixels before scaling, thereby reducing the problem of inaccurate subsequent processing due to the change of pixel categories after scaling. The following is a detailed description with reference to the accompanying drawings.

[0088] See also Figure 2 , is a flow chart of an image processing method provided in an embodiment of the present application. The image processing method can be used Figure 1 The modules shown in Figure 2 As shown, it mainly includes the following steps.

[0089] S201: Determine the category of each pixel to be processed in the image data.

[0090] In an embodiment of the present application, after acquiring the image data, the category of each pixel to be processed in the image data can be determined by the content feature recognition module, wherein the pixel categories include eight categories: text, gray text, line array, gray line array, image, gray image, background and gray background.

[0091] In a specific implementation, the attributes of the pixel category can be divided into a first attribute and a second attribute according to the category of the pixel, wherein the first attribute includes a gray attribute and a non-gray attribute, and the non-gray attribute is also called a normal attribute, such as the first attribute of the text, line array, image and background categories is a normal attribute, and the first attribute of the gray text, gray line array, gray image and gray background categories is a gray attribute, and the second attribute includes text, line array, image and background, such as the second attribute of the text and gray text categories is text, the second attribute of the line array and gray line array categories is line array, the second attribute of the image and gray image is image, and the second attribute of the background and gray background is background. Therefore, after the image data is acquired, the category of each pixel to be processed in the image data can be obtained by determining the first attribute and the second attribute of the category of each pixel to be processed.

[0092] See also Figure 3 , is a schematic diagram of a flow chart of determining the category of a pixel to be processed provided by an embodiment of the present application. Figure 3 As shown, the specific steps of the process include:

[0093] S301: any pixel in the image data whose RGB value is greater than the RGB value of the background pixel is taken as the first pixel, and a value is assigned to the first pixel.

[0094] In an embodiment of the present application, the RGB value of the background pixel of the image data can be first detected by a histogram, and then any pixel in the image data whose RGB value is greater than the RGB value of the background pixel is taken as the first pixel, and the first pixel is assigned a value. Exemplarily, taking scanned data as an example, the scanned image is generally darker, and the RGB value of the background pixel detected by the histogram is generally around 190. At this time, any pixel in the image data whose RGB value is greater than 190 can be taken as the first pixel, and the RGB value of the first pixel is assigned to 255 (white). By brightening the darker background value to white, the gradient of the text can be improved, which is convenient for subsequent detection.

[0095] S302: Perform edge detection on the first pixel after the value is assigned to obtain a gradient value of the first pixel.

[0096] In an embodiment of the present application, edge detection is performed on the RGB three channels of the first pixel after assignment to obtain the gradient value of the first pixel. The specific content of the edge detection can be referred to the relevant technology. For the sake of brevity, the embodiment of the present application will not be repeated here.

[0097] S303: Determine an initial second attribute of the category of the first pixel based on the gradient value.

[0098] In the embodiment of the present application, based on the gradient value of the first pixel, it can be determined whether the first pixel is text, line queue, image or background, that is, the initial second attribute of the category of the first pixel can be determined based on the gradient value. Specifically, a preset fixed template can be obtained first, and the preset fixed template can be used to determine whether the first pixel is a line queue. If the first pixel is a line queue, the initial second attribute of the category of the first pixel is determined to be a line queue. If the first pixel is not a line queue, the gradient value range of the first pixel is determined, and the initial second attribute of the category of the first pixel is determined to be text, image or background based on the gradient value range of the first pixel, wherein the preset fixed template is a template set according to common line queue situations.

[0099] Specifically, Figure 4 As shown, the step of determining the initial second attribute of the category of the first pixel based on the gradient value specifically includes:

[0100] S3031: judging whether the first pixel is a line queue by using a preset fixed template, if the first pixel is a line queue, proceeding to S3032, if the first pixel is not a line queue, proceeding to S3033;

[0101] The preset fixed template of the embodiment of the present application can be a 9*9 neighborhood fixed template. If the result of the preset fixed template judgment is a line team, the initial second attribute of the category of the first pixel is determined to be a line team, and the process goes to S3032. If the result of the preset fixed template judgment is not a line team, the initial second attribute of the category of the first pixel is not a line team, and the process goes to S3033 for further judgment.

[0102] S3032: assigning the tag of the first pixel to a line tag;

[0103] For the first pixel whose initial second attribute of the category is the line team, the tag of the first pixel is assigned the line team label.

[0104] S3033: Determine whether the gradient value of the first pixel is within the text range. If the gradient value is within the text range, proceed to S3034; if the gradient value is not within the text range, proceed to S3035;

[0105] For the first pixel whose initial second attribute of the category is not a line, determine whether the gradient value of the first pixel is within the text range. If the gradient value of the first pixel is within the text range, confirm that the initial second attribute of the category of the first pixel is text, and enter S3034. If the gradient value of the first pixel is not within the text range, confirm that the initial second attribute of the category of the first pixel is not text, and need to enter S3035 for further judgment.

[0106] S3034: assigning the tag of the first pixel to a text label;

[0107] For the first pixel whose initial second attribute of the category is text, the tag of the first pixel is assigned as a text label.

[0108] S3035: Determine whether the gradient value of the first pixel is within the image range. If the gradient value is within the image range, proceed to S3036; if the gradient value is not within the image range, proceed to S3037;

[0109] For the first pixel whose initial second attribute of the category is not text, it is determined whether the gradient value of the first pixel is within the image range. If the gradient value of the first pixel is within the image range, it is confirmed that the initial second attribute of the category of the first pixel is image, and the process goes to S3036. If the gradient value of the first pixel is not within the image range, it is confirmed that the initial second attribute of the category of the first pixel is background, and the process goes to S3035.

[0110] S3036: Assign the tag of the first pixel as an image label.

[0111] For a category whose initial second attribute is the first pixel of the image, the tag of the first pixel is assigned as the image label.

[0112] S3037: Assign the tag of the first pixel to the background tag.

[0113] For the first pixel whose initial second attribute of the category is background, the tag of the first pixel is assigned as the background tag.

[0114] The embodiment of the present application can make a preliminary judgment on the second attribute of the category of each pixel to be processed in the image data, and obtain the initial second attribute of the category of each pixel to be processed.

[0115] It should be noted that in the embodiment of the present application, S3031 can also be executed before S302, that is, the pixels of the line queue are first distinguished, and then the gradient value of the first pixel is obtained, and the pixels classified as text, image and background are distinguished based on the gradient value. The embodiment of the present application does not make specific requirements for this.

[0116] S304: adjusting the initial second attribute of the category of the first pixel based on the initial second attribute of the category of the pixels in the connected domain of the first pixel to obtain the second attribute of the category of the first pixel.

[0117] In an embodiment of the present application, after the initial second attribute of the category of the first pixel is determined, the initial second attribute of the category of the first pixel can be judged again based on the initial second attributes of the categories of pixels in a connected domain of the first pixel, so as to adjust the initial second attribute of the first pixel whose initial second attribute of the category is erroneous.

[0118] Specifically, for the first pixel whose initial second attribute of the category is text, the number of pixels whose initial second attribute of the category is a line team in the connected domain of the first pixel is obtained, and the first pixel in which the number of pixels whose initial second attribute of the category is a line team in the connected domain is greater than a first preset value is determined, and the initial second attributes of the categories of these first pixels are adjusted to line teams, thereby obtaining the second attribute of the category of the first pixel.

[0119] Specifically, for the first pixel whose initial second attribute of the category is text, the number of pixels whose initial second attribute of the category is an image in the connected domain of the first pixel is obtained, and the first pixel whose number of pixels whose initial second attribute of the category in the connected domain is a line array image is determined to be greater than a second preset value, and the initial second attributes of the categories of these first pixels are adjusted to images, thereby obtaining the second attribute of the category of the first pixel.

[0120] The embodiment of the present application can re-judge the initial second attribute of the category of the first pixel, thereby ensuring the accuracy of identifying pixel category changes and facilitating improving the output quality of the image.

[0121] It can be seen that in the embodiment of the present application, S304 is for the first pixel whose initial second attribute of the category is text. Therefore, in actual applications, for the first pixel whose initial second attribute of the category is other, it is also possible to directly enter S305 without going through S304.

[0122] S305: Determine a first attribute of the category of the first pixel according to the RGB mean value of pixels in the neighborhood of the first pixel;

[0123] In the embodiment of the present application, the first attribute of the category of the first pixel can be determined by the RGB mean of the pixels in the 5*5 neighborhood of the first pixel. Specifically, the RGB mean of each pixel in the 5*5 neighborhood of the first pixel is obtained, and the difference of each RGB mean is calculated to determine whether the difference of the RGB mean is less than a set value, such as less than 10. If the difference of the RGB mean is less than the set value, it is confirmed that the first attribute of the category of the first pixel is a grayscale attribute, otherwise, the first attribute of the category of the first pixel is a normal attribute.

[0124] S306: Determine the category of each to-be-processed pixel in the image data according to the first attribute of the category of each first pixel and the second attribute of the category of each first pixel.

[0125] In the embodiment of the present application, after the first attribute and the second attribute of the category of each first pixel are obtained, the category of each pixel to be processed in the image data can be determined. Exemplarily, if the first attribute of the category of the first pixel obtained is a normal attribute and the second attribute is text, then the category of the first pixel in the image data can be determined to be text; if the first attribute of the category of the first pixel obtained is a grayscale attribute and the second attribute is a line array, then the category of the first pixel in the image data can be determined to be a grayscale line array.

[0126] In practical applications, line arrays (line groups) are a type of image data that is different from text and has different properties from text, such as Figure 5 As shown, the prior art does not distinguish between text and line queues. Based on this, the embodiment of the present application improves the content feature recognition module, and adds the distinction between line queues and text on the basis of traditional image and text segmentation. This can facilitate subsequent additional processing of the line queues to make them more obvious, thereby increasing the output image quality.

[0127] S202: Performing a first optimization process on the image data according to the category of each pixel to be processed to obtain first image data.

[0128] The embodiment of the present application can perform a first optimization process on the image data according to the category of each pixel to be processed to obtain the first image data, wherein the first optimization process may include descreening, text sharpening, document type analysis, and automatic contrast adjustment, etc. In a specific implementation, the user can change the optimization processing means of the first optimization processing module according to the processing requirements of the image data, and the embodiment of the present application does not make specific requirements for this.

[0129] S203: Taking any pixel to be processed in the first image data as a target pixel, obtaining the category of each pixel in the neighborhood of the target pixel;

[0130] S204: Determine a method for obtaining the category of the corresponding pixel to be processed in the second image data according to the category of each pixel in the neighborhood of the target pixel, wherein the second image data is image data obtained by performing reduction or enlargement processing on the first image data.

[0131] In an embodiment of the present application, since the category of each pixel to be processed in the first image data may change when the first image data is reduced or enlarged, for example, the first image data is reduced by 2 times in both the horizontal and vertical directions, which is equivalent to combining the four pixels in the first image data into one pixel. If the categories of the four pixels are relatively mixed, some are text and some are images, then the category of the pixels obtained after reduction cannot be determined.

[0132] In the prior art, for the change of pixel categories after reduction or enlargement, a simple bilinear difference calculation is generally used directly. However, without considering the clutter of the categories, simply performing bilinear difference calculation on the pixel categories will lose the accuracy of the categories. That is, when performing bilinear difference calculation on the pixel categories, if the categories of the surrounding pixels are relatively uniform, the calculation result will be fine. If the categories of the surrounding pixels are relatively cluttered, the result after alignment difference will be inaccurate. For example, if the text category is 1 and the image category is 0, if the surrounding pixels are all text and images, the difference may be 0.4, which does not belong to any category.

[0133] Based on this, the embodiment of the present application provides a method for determining how to calculate the category change of pixels after reduction or enlargement processing. Specifically, in the embodiment of the present application, any pixel to be processed in the first image data can be used as a target pixel, the category of each pixel in the neighborhood of the target pixel is obtained, and the category of each pixel in the neighborhood of the target pixel is attributed, so as to determine the way to adjust the category of the pixel to be processed in the image data after reduction or enlargement processing, wherein the neighborhood of the target pixel is preferably a 3*3 neighborhood of the target pixel.

[0134] In a possible implementation, text, line arrays, grayscale text and grayscale line arrays can be taken as the first category, and images, backgrounds, grayscale images and grayscale backgrounds can be taken as the second category. After obtaining the category of each pixel in the neighborhood of the target pixel, the number of pixels in the neighborhood of the target pixel whose category is the first category and the number of pixels in the second category are determined. If the number of pixels in the first category or the number of pixels in the second category is greater than a preset threshold, that is, the number of pixels belonging to the same category in the neighborhood of the target pixel is large and the categories of the pixels are relatively uniform, then the category of the corresponding pixel to be processed in the second image data is obtained according to the first method, wherein the first method is a bilinear difference calculation method, that is, only the category of the pixel in the first image data needs to be performed bilinear difference calculation to obtain the category of the corresponding pixel to be processed in the second image data.

[0135] If the number of pixels in the first category and the number of pixels in the second category are both less than or equal to the preset threshold, it is proved that the categories of the pixels in the neighborhood of the target pixel are relatively messy, and it is necessary to obtain the category of the corresponding pixel to be processed in the second image data according to the second method, wherein obtaining the category of the corresponding pixel to be processed in the second image data according to the second method specifically includes:

[0136] Determine the first attribute of the category of the corresponding pixel to be processed in the second image data according to the first attribute of the category of the pixels in the neighborhood of the target pixel, determine the second attribute of the category of the corresponding pixel to be processed in the second image data according to the gradient value of the corresponding pixel to be processed in the second image data, and determine the category of the corresponding pixel to be processed in the second image data according to the first attribute and the second attribute of the category of the corresponding pixel to be processed in the second image data.

[0137] In a possible implementation, determining the first attribute of the category of the corresponding pixel to be processed in the second image data according to the first attribute of the category of the pixels in the neighborhood of the target pixel specifically includes:

[0138] Determine the number of pixels whose first attribute of the category is a grayscale attribute and the number of pixels whose first attribute of the category is a normal attribute in the neighborhood of the target pixel. When the number of pixels of the grayscale attribute is greater than the number of pixels of the normal attribute, adjust the first attribute of the category of the corresponding pixel to be processed in the second image data to the grayscale attribute. When the number of pixels of the grayscale attribute is less than or equal to the number of pixels of the normal attribute, adjust the first attribute of the category of the corresponding pixel to be processed in the second image data to the normal attribute.

[0139] In a possible implementation, determining the second attribute of the category of the corresponding pixel to be processed in the second image data according to the gradient value of the corresponding pixel to be processed in the second image data specifically includes:

[0140] Obtain a gradient value of a pixel to be processed corresponding to the second image data, and determine a second attribute of a category of the pixel to be processed corresponding to the second image data according to the gradient value. The specific process of determining the second attribute of the category of the pixel to be processed corresponding to the second image data according to the gradient value can refer to the specific contents in S303-S304. For the sake of brevity, the embodiments of the present application will not be described in detail herein.

[0141] The embodiments of the present application can not only re-identify the categories of pixels after being shrunk or enlarged, but also re-identify the categories of pixels after being shrunk or enlarged in different ways according to the categories of pixels in the neighborhood, thereby ensuring effective identification of pixel category changes and reducing the problem of inaccurate subsequent processing due to tag changes and inaccurate identification of tag changes after scaling.

[0142] In a possible implementation, the processing of the first image data is not only reduction or enlargement, but also rotation, that is, the second image data can be obtained by performing reduction and / or rotation processing, or enlargement and / or rotation processing on the first image data. At this time, if the rotation processing is performed, since the pixel points before and after the rotation correspond one to one, it is only necessary to rotate the category of each pixel to be processed in the first image data synchronously with the corresponding pixel to be processed in the first image data.

[0143] In a possible implementation, in order to improve the quality of the final output image, the embodiment of the present application further Figure 1 The modules after the rotation and scaling module are improved based on pixel categories to improve the optimization processing performance of subsequent modules.

[0144] Specifically, the embodiment of the present application improves the filtering module so that the filtering module can perform adaptive filtering processing on the second image data based on the category of each pixel to be processed in the second image data, wherein the adaptive filtering processing includes descreening, text sharpening, and improving the contrast and sharpening of the line array on the second image data, that is, improving the contrast of the line array before sharpening the line array to ensure the clarity of the line array, thereby improving the overall quality of the image. In addition, the filtering module of the embodiment of the present application can also perform a separate descreening operation on the image area, so that the image quality is improved without affecting the sharpness of the text.

[0145] Specifically, the embodiment of the present application also provides Gamma (gamma, Figure 1 The Gamma module (not shown) is improved so that the Gamma module can brighten the portrait area of ​​the second image data based on the category of each pixel to be processed in the second image data, while not processing the text area. This not only improves the brightness of the image area and achieves the effect of saving ink, but also does not affect the effect of the text area.

[0146] Specifically, the embodiment of the present application also improves the ink saving part, so that the ink saving part can perform ink saving processing on the black text area of ​​the second image data based on the category of each pixel to be processed in the second image data, that is, the embodiment of the present application can apply a separate ink saving algorithm to the black text area to save ink without changing the image quality.

[0147] Specifically, the embodiment of the present application also adds color trapping processing to the part after the scanning module ( Figure 1 (not shown) is used to further determine whether the pixel is black when the first attribute of the category is gray, and only perform color trapping on black. "Color trapping" means "color trapping", which refers to complementing the color around the black pixel, and the complemented color is the same as the surrounding pixels to compensate for the color matching accuracy of the image forming device and improve the quality of printed images.

[0148] Specifically, the embodiment of the present application also provides a printing color correction module ( Figure 1 (not shown) is improved so that the print color correction module uses only black toner to perform image formation operations for pixels whose first attribute of the category is grayscale attribute, thereby reducing the impact of color misregistration and avoiding color cast in grayscale images.

[0149] In practical applications, the grayscale attributes are generally converted into grayscale values ​​to improve the quality of gray text, and in the printing pipeline, the grayscale values ​​are converted into grayscale values ​​through the printing color correction module ( Figure 1 The gray part is corrected to pure gray (not shown in the figure), but since the pixels with gray attributes will be printed with a mixed K composed of CMYK during printing, this may cause color cast in the gray image again. However, after the gray part in the image is detected, the embodiment of the present application prints it with pure K during printing, thereby improving the quality of gray image printing. Specifically, since the printing is performed by converting RGB to CMYK through a mapping table, after the gray attribute is identified, another mapping table can be used to map the pixels with gray attributes, and the gray of the mapping table is printed with pure K, thereby reducing the color cast problem of gray pixels during printing.

[0150] The pixel category recognition method of the embodiment of the present application does not affect the accuracy of the category, can greatly improve the image and text segmentation effect, facilitates subsequent optimization processing, and improves the image quality; at the same time, the embodiment of the present application has special attribute values ​​for grayscale features and line teams, which can solve the color cast problem of grayscale features in the output image and improve the clarity of the line team; at the same time, the embodiment of the present application also performs different processing based on different tags in subsequent filtering modules, thereby improving the image processing effect as a whole.

[0151] Corresponding to the above embodiment, the embodiment of the present application also provides an image processing device.

[0152] See also Figure 6 , is a schematic diagram of the structure of an image processing device provided in an embodiment of the present application. Figure 6 As shown, the image processing device 600 includes: a first determination unit 601, used to determine the category of each pixel to be processed in the image data; a first optimization processing unit 602, used to perform a first optimization processing on the image data according to the category of each pixel to be processed, so as to obtain the first image data; a reduction or enlargement processing unit 603, used to perform a reduction or enlargement processing on the first image data, so as to obtain the second image data; an acquisition unit 604, used to take any pixel to be processed in the first image data as a target pixel, and acquire the category of each pixel in the neighborhood of the target pixel; a second determination unit 605, used to determine a method for acquiring the category of the corresponding pixel to be processed in the second image data according to the category of each pixel in the neighborhood of the target pixel.

[0153] The specific contents of the embodiments of the present application can be found in the description of the above method embodiments, which will not be repeated here for the sake of brevity.

[0154] Corresponding to the above embodiments, the present application also provides an electronic device.

[0155] See also Figure 7 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, and the electronic device 700 may include: a processor 710, a memory 720, and a communication unit 730. These components communicate through one or more buses. Those skilled in the art can understand that the structure of the electronic device shown in the figure does not constitute a limitation on the embodiment of the present application. It can be a bus structure or a star structure, and can also include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0156] The communication unit 730 is used to establish a communication channel so that the electronic device can communicate with other devices, receive user data sent by other devices or send user data to other devices.

[0157] The processor 710 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It runs or executes software programs, instructions, and / or modules stored in the memory 720, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 710 can only include a central processing unit (CPU). In the embodiment of the present application, the CPU can be a single computing core or multiple computing cores.

[0158] The memory 720 is used to store the execution instructions of the processor 710. The memory 720 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0159] When the execution instructions in the memory 720 are executed by the processor 710, the electronic device 700 can execute Figure 2 Some or all of the steps in the illustrated embodiments.

[0160] In a specific implementation, the embodiment of the present application further provides a computer storage medium, wherein the computer storage medium may store a program, and when the program is executed, the program may include some or all of the steps in each embodiment of the image processing method provided in the embodiment of the present application. The storage medium may be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0161] In a specific implementation, an embodiment of the present application also provides a computer program product, wherein the computer program product includes executable instructions, and when the executable instructions are executed on a computer, the computer executes part or all of the steps in each embodiment of the image processing method provided in the embodiment of the present application.

[0162] Those skilled in the art can clearly understand that the technology in the embodiments of the present application can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application or some parts of the embodiments.

[0163] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the device embodiment and the terminal embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.

Claims

1. An image processing method, comprising: Determining the category of each pixel to be processed in the image data; Performing a first optimization process on the image data according to the category of each pixel to be processed to obtain first image data; Performing reduction or enlargement processing on the first image data to obtain second image data; Characterized in that the method further comprises: Taking any pixel to be processed in the first image data as a target pixel, obtaining the category of each pixel in the neighborhood of the target pixel; A method for obtaining the category of the corresponding pixel to be processed in the second image data is determined according to the category of each pixel in the neighborhood of the target pixel.

2. The image processing method according to claim 1, characterized in that: The method of determining the category of the corresponding pixel to be processed in the second image data according to the category of each pixel in the neighborhood of the target pixel includes: Determining the number of pixels of the first category and the number of pixels of the second category in the neighborhood of the target pixel according to the category of each pixel in the neighborhood of the target pixel; If the number of pixels of the first category or the number of pixels of the second category in the neighborhood of the target pixel is greater than a preset threshold, the category of the corresponding pixel to be processed in the second image data is obtained according to a first method, wherein the first method is a bilinear difference calculation method.

3. The image processing method according to claim 2, characterized in that: The method further comprises: If the number of pixels of the first category and the number of pixels of the second category in the neighborhood of the target pixel are both less than or equal to the preset threshold, the category of the corresponding pixel to be processed in the second image data is obtained according to a second method.

4. The image processing method according to claim 3, characterized in that: The obtaining, according to the second method, the category of the corresponding pixel to be processed in the second image data includes: Determine a first attribute of a category of a corresponding pixel to be processed in the second image data according to a first attribute of a category of pixels in a neighborhood of the target pixel, wherein the first attribute includes a grayscale attribute and a normal attribute; Determining a second attribute of a category of a corresponding pixel to be processed in the second image data according to a gradient value of the corresponding pixel to be processed in the second image data, wherein the second attribute includes text, line array, image and / or background; The category of the corresponding pixel to be processed in the second image data is determined according to the first attribute and the second attribute of the category of the corresponding pixel to be processed in the second image data.

5. The image processing method according to claim 4, characterized in that: The determining of the first attribute of the category of the corresponding pixel to be processed in the second image data according to the first attribute of the category of the pixels in the neighborhood of the target pixel, wherein the first attribute includes a grayscale attribute and a normal attribute, comprises: Determine the number of pixels whose first attribute of the category is a grayscale attribute and the number of pixels whose first attribute of the category is a normal attribute in the neighborhood of the target pixel; When the number of pixels of the grayscale attribute is greater than the number of pixels of the normal attribute, the first attribute of the category of the corresponding pixel to be processed in the second image data is adjusted to the grayscale attribute; when the number of pixels of the grayscale attribute is less than or equal to the number of pixels of the normal attribute, the first attribute of the category of the corresponding pixel to be processed in the second image data is adjusted to the normal attribute.

6. The image processing method according to claim 4, characterized in that: The determining, according to the gradient value of the corresponding pixel to be processed in the second image data, the second attribute of the category of the corresponding pixel to be processed in the second image data comprises: Obtaining a gradient value of a corresponding pixel to be processed in the second image data; A second attribute of the category of the corresponding pixel to be processed is determined according to the gradient value.

7. The image processing method according to claim 1, characterized in that: The performing reduction or enlargement processing on the first image data to obtain the second image data further comprises: The first image data is subjected to reduction and / or rotation processing, or enlargement and / or rotation processing, to obtain the second image data, wherein when the first image data is subjected to rotation processing, the category of each pixel to be processed in the first image data is rotated synchronously with the corresponding pixel to be processed in the first image data.

8. The image processing method according to claim 1, characterized in that: Determining the category of each pixel to be processed in the image data includes: Taking any pixel in the image data whose RGB value is greater than the RGB value of the background pixel as a first pixel, and assigning a value to the first pixel; Performing edge detection on the first pixel after the assignment to obtain a gradient value of the first pixel; determining an initial second attribute of the category of the first pixel based on the gradient value; adjusting the initial second attribute of the category of the first pixel based on the initial second attribute of the category of the pixels in the connected domain of the first pixel to obtain the second attribute of the category of the first pixel; Determine a first attribute of the category of the first pixel according to the RGB mean value of pixels in the neighborhood of the first pixel; The category of each to-be-processed pixel in the image data is determined according to a first attribute of the category of each first pixel and a second attribute of the category of each first pixel.

9. The image processing method according to claim 8, characterized in that: The determining an initial second attribute of the category of the first pixel based on the gradient value comprises: Determining whether the first pixel is a line queue by using a preset fixed template; determining an initial second attribute of the category of the first pixel being a line team as a line team; Determine the gradient value range of the first pixel that is not a line team; An initial second attribute of the category of the first pixel is determined to be text, image or background according to the gradient value range of the first pixel.

10. The image processing method according to claim 8, characterized in that: The adjusting the initial second attribute of the category of the first pixel based on the initial second attribute of the category of the pixels in the connected domain of the first pixel includes: Obtaining the number of pixels whose initial second attribute of a category in a connected domain of the first pixel is a line queue; The initial second attribute of the category of the first pixel whose number of pixels is greater than the first preset value and whose initial second attribute is text is adjusted to a line queue.

11. The image processing method according to claim 8, characterized in that: The adjusting the initial second attribute of the category of the first pixel based on the initial second attribute of the category of the pixels in the connected domain of the first pixel includes: Acquire an initial second attribute of a category in a connected domain of the first pixel, which is the number of pixels in the image; The initial second attribute of the category of the first pixels whose number of pixels is greater than the second preset value and whose initial second attribute is text is adjusted to image.

12. The image processing method according to claim 1, characterized in that: After obtaining the second image data, the method further includes: Adaptive filtering is performed on the second image data based on the category of each pixel to be processed in the second image data, wherein the adaptive filtering includes descreening, text sharpening, and line contrast enhancement and sharpening.

13. The image processing method according to claim 1, characterized in that: After obtaining the second image data, the method further includes: The black text area of ​​the second image data is subjected to ink saving processing based on the category of each to-be-processed pixel in the second image data.

14. The image processing method according to claim 1, characterized in that: After obtaining the second image data, the method further includes: The second image data is subjected to color trapping processing based on the category of each to-be-processed pixel in the second image data.

15. The image processing method according to claim 1, characterized in that: After obtaining the second image data, the method further includes: A brightening process is performed on a portrait area of ​​the second image data based on a category of each to-be-processed pixel in the second image data.

16. The image processing method according to claim 4, characterized in that: After obtaining the second image data, the method further includes: For pixels whose first attribute of the category is a grayscale attribute, only black toner is used for the image forming operation.

17. An image processing device, comprising: A first determining unit, used to determine the category of each pixel to be processed in the image data; A first optimization processing unit, configured to perform a first optimization process on the image data according to the category of each pixel to be processed, so as to obtain first image data; A reduction or enlargement processing unit, used for performing reduction or enlargement processing on the first image data to obtain second image data; Characterized in that the device also includes: An acquisition unit, configured to take any pixel to be processed in the first image data as a target pixel and acquire the category of each pixel in a neighborhood of the target pixel; The second determining unit is used to determine a method for obtaining the category of the corresponding pixel to be processed in the second image data according to the category of each pixel in the neighborhood of the target pixel.

18. An electronic device, characterized in that: include: processor; Memory; A computer program is stored in the memory, and when the computer program is executed, the electronic device executes the method according to any one of claims 1 to 16.

19. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 16.

Citation Information

Patent Citations

  • Image resampling method and device, terminal and computer readable storage medium

    CN110738625A

  • Image processing method, device and equipment and storage medium

    CN112734654A

  • Image processing method and device, image text obtaining method and device and electronic equipment

    CN115035530A

  • Image processing method and device, equipment and storage medium

    CN116912269A