CN115601253A - Image processing method, image processing device, storage medium and electronic equipment - Google Patents

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

Info

Publication number
CN115601253A
CN115601253A CN202211136148.9A CN202211136148A CN115601253A CN 115601253 A CN115601253 A CN 115601253A CN 202211136148 A CN202211136148 A CN 202211136148A CN 115601253 A CN115601253 A CN 115601253A
Authority
CN
China
Prior art keywords
target
image
processed
components
color
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211136148.9A
Other languages
Chinese (zh)
Inventor
刘勇
熊永福
李凤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing Ant Consumer Finance Co ltd
Original Assignee
Chongqing Ant Consumer Finance Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chongqing Ant Consumer Finance Co ltd filed Critical Chongqing Ant Consumer Finance Co ltd
Priority to CN202211136148.9A priority Critical patent/CN115601253A/en
Publication of CN115601253A publication Critical patent/CN115601253A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • G06T5/77
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/40Filling a planar surface by adding surface attributes, e.g. colour or texture

Abstract

The embodiment of the specification discloses an image processing method, an image processing device, a storage medium and electronic equipment, wherein the method comprises the following steps: acquiring a target area including a seal in an image to be processed, processing the target area only to acquire a plurality of saturation S components corresponding to the target area, and further determining pixel points corresponding to M minimum S components in the S components as target pixel points, namely determining the target pixel points by adopting an S space sequencing segmentation method, thereby distinguishing the seal from other contents in the image to be processed; and finally, filling a pixel area corresponding to the seal by a method of modifying the pixel value of the target pixel point.

Description

Image processing method, image processing device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of image processing technologies, and in particular, to an image processing method and apparatus, a storage medium, and an electronic device.
Background
With the popularization of online transaction services, people increasingly transact required matters, such as loan application, passport transaction, account transfer and the like, in a line mode. Online transactions typically require users to upload various types of authentication material, including large amounts of image material, such as user identification of assets, passport copies, debit notes, and the like. However, various seals, such as government seals or personal seals, are often present on the image as the authentication material. Due to the existence of the seal, original text content on the image can be shielded to different degrees, and difficulty is brought to image analysis of a system.
Disclosure of Invention
The embodiment of the specification provides an image processing method, an image processing device, a storage medium and electronic equipment, which can effectively solve the problem that other text contents are blocked by a seal in an image. The technical scheme is as follows:
in a first aspect, an embodiment of the present specification provides an image processing method, including:
acquiring a target area including a seal in an image to be processed;
determining a plurality of saturation S components corresponding to the target color in the target area;
determining pixel points corresponding to the minimum M S components in the S components as target pixel points;
and setting the pixel value of the target pixel point as a target pixel value.
In a second aspect, an embodiment of the present specification provides an image processing apparatus, including:
the region acquisition module is used for acquiring a target region including a seal in the image to be processed;
the first determining module is used for determining a plurality of saturation S components corresponding to the target color in the target area;
a second determining module, configured to determine, as a target pixel, a pixel corresponding to M smallest S components of the plurality of S components;
and the pixel setting module is used for setting the pixel value of the target pixel point as a target pixel value.
In a third aspect, embodiments of the present specification provide a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the above-mentioned method steps.
In a fourth aspect, embodiments of the present specification provide a computer program product, which stores a plurality of instructions adapted to be loaded by a processor and to perform the above-mentioned method steps,
in a fifth aspect, embodiments of the present specification provide an electronic device, which may include: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the above-mentioned method steps.
The technical scheme provided by some embodiments of the present description brings beneficial effects at least including:
the method and the device for processing the image to be processed have the advantages that the target area including the seal in the image to be processed is obtained, only the target area is processed to obtain the multiple saturation S components corresponding to the target area, the problem of low efficiency caused by processing the whole image to be processed can be avoided, and the problem of judgment errors caused by processing the irrelevant area when the color space of the whole image to be processed is avoided; further, the specification determines pixel points corresponding to the minimum M S components in the S components as target pixel points, namely, the target pixel points are determined by adopting an S space sequencing and dividing method, so that the seal is effectively distinguished from other contents in the image to be processed; finally, filling a pixel area corresponding to the seal by a method of modifying the pixel value of the target pixel point, and avoiding damaging other contents in the image to be processed; the image processing method for segmenting the seal and reserving other contents provided by the specification is simple, efficient and high in accuracy.
Drawings
In order to more clearly illustrate the embodiments of the present specification or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present specification, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic diagram of an image to be processed according to an embodiment of the present disclosure;
fig. 2A is a schematic diagram illustrating an architecture of an image processing method according to an embodiment of the present disclosure;
fig. 2B is a schematic diagram of an architecture of another image processing method provided in the embodiments of the present disclosure;
fig. 3 is a schematic flowchart of an image processing method provided in an embodiment of the present specification;
FIG. 4 is a schematic diagram illustrating a pre-post comparison of an image to be processed according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of another image processing method provided in an embodiment of the present specification;
fig. 6 is a flowchart illustrating an image processing method provided in an embodiment of the present specification;
fig. 7 is a schematic structural diagram of an image processing apparatus provided in an embodiment of the present specification;
fig. 8 is a schematic structural diagram of an electronic device provided in an embodiment of the present specification.
Detailed Description
The technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present specification without any creative effort belong to the protection scope of the present specification.
In the description herein, it is to be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In the description of the present specification, it is to be noted that, unless explicitly stated or limited otherwise, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements but may alternatively include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. The specific meanings of the above terms in the present specification can be understood as specific cases by those of ordinary skill in the art. Further, in the description of the present specification, "a plurality" means two or more unless otherwise specified. "and/or" describes the association relationship of the associated object, indicating that there may be three relationships, for example, a and/or B, which may indicate: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The present specification will be described in detail with reference to specific examples.
With the popularization of online transaction services, people increasingly transact required matters, such as loan application, passport transaction, account transfer and the like, in a line mode. Online transactions typically require users to upload various types of authentication material, including large amounts of image material, such as user identification of assets, passport copies, debit notes, and the like. However, there are various seals on the image as the authentication material, such as a government seal or a personal seal. Due to the existence of the seal, original text content on the image can be shielded to different degrees, and difficulty is brought to image analysis of a system.
An image refers to a description or portrayal of a similarity, vividness, or of a natural thing or an objective object (human, animal, plant, landscape, etc.), or an image can be understood to be a representation of a natural thing or an objective object (human, animal, plant, landscape, etc.) that contains information about the object being described. Generally, an image is a picture with a visual effect. The image to be processed can be understood as the image to be processed in this embodiment. The image to be processed can be a photograph, a drawing, a clip art, a map, a satellite cloud picture, a movie picture, an X-ray film, an electroencephalogram, an electrocardiogram and the like.
For example, as shown in fig. 1, a schematic diagram of a to-be-processed image provided by an embodiment of the present disclosure is provided, where the to-be-processed image 100 is a borrowing voucher, and a depositor's stamp is located at a lower left corner of the to-be-processed image 100. The stamp shields part of the text content on the image 100 to be processed, and interferes with the subsequent extraction of effective text content or other image processing operations on the image 100 to be processed.
It should be understood that fig. 1 is only an example, and the embodiment of the present disclosure also includes any other type of stamp or watermark that may also block other contents in the image, and does not set any limit to the size, storage format, contents, and the like of the image.
In this specification, the execution subject is an electronic apparatus. The electronic device includes, but is not limited to, a Mobile Station (MS), a Mobile Terminal device (Mobile Terminal), a Mobile phone (Mobile phone), a handset (handset), and a portable device (portable equipment), and the electronic device may communicate with one or more core networks through a Radio Access Network (RAN). For example, the electronic device may be a mobile telephone (or "cellular" telephone), or a portable, pocket, hand-held, computer-included, or vehicle-mounted mobile device or apparatus, or a smart electronic watch with communications capabilities. The electronic equipment also comprises a server cluster formed by one server or a plurality of servers, receives requests or information through a plurality of interfaces, and provides corresponding data or services based on the requested content. The plurality of servers may be a plurality of physical servers that are independent in hardware. The plurality of servers are in a plurality of virtual servers, the plurality of virtual servers are deployed in the same hardware resource pool, and the deployment mode of the virtual servers includes but is not limited to: VMware, virtualBox, and VirtualPC.
In one embodiment, as shown in fig. 2A, an architecture diagram for image processing provided for embodiments of the present specification includes an electronic device 201. The electronic device 201 is mounted with a display element, which may be any device capable of implementing a display function, such as: the display element may be a Cathode ray tube (CR) display, a Light-emitting diode (LED) display, an electronic ink panel, a Liquid Crystal Display (LCD), a Plasma Display Panel (PDP), or the like. The user may view information such as displayed text, pictures, videos, and the like by using a display element on the electronic device 201, and send an instruction to the processor of the electronic device 201 through the display element, for example, send an upload to-be-processed image to the processor of the electronic device by performing an operation of long pressing, clicking, or double clicking on the display element of the electronic device 201, or select a target color, so that the processor of the electronic device 201 performs stamp removing processing on the to-be-processed image, and displays the stamp-removed image through the display element. In addition, the electronic device 201 may further include an image pickup element, and the user acquires an image to be processed through the image pickup element of the electronic device 201 and further performs image processing on the image to be processed through a processor of the electronic device 201.
In another embodiment, as shown in fig. 2B, another architecture diagram for image processing provided by the embodiments of the present disclosure includes: the server 202, an electronic device 2031, an electronic device 2032, an electronic device 2033, an electronic device 2034, and an electronic device 2035. The user uploads the image to be processed to the server 202 through the electronic device 203 serving as the user side, so that the server 202 executes an image processing method on the image to be processed and obtains the image to be processed with the stamp removed, and the image to be processed with the stamp removed is sent to the electronic device 203 serving as the user side, so that the user can check the image. It is understood that the number and type of electronic devices shown in fig. 2B are merely examples, and that other numbers and types of electronic devices are also encompassed by the present application.
In one embodiment, as shown in fig. 3, a flowchart of an image processing method proposed for the embodiments of the present specification, which can be implemented by relying on a computer program, can be run on an image processing apparatus based on the von neumann architecture. The computer program may be integrated into the application or may run as a separate tool-like application.
Specifically, the image processing method specifically includes the steps of:
s102, acquiring a target area including a seal in the image to be processed.
The acquisition mode of the image to be processed can be as follows: the user inputs the image to be processed to the processor of the electronic device through the display element or the input element of the electronic device, so that the processor of the electronic device acquires the image to be processed. For example, the user scans or photographs an image material through a mobile communication device having a photographing function, or the user clicks a target image through an interactive liquid crystal display of the mobile communication device to upload the target image. The acquisition mode of the image to be processed can also be as follows: the server executing the image processing method receives the to-be-processed image uploaded by other electronic devices in a wireless or wired manner, for example, the server receives the to-be-processed image sent by a user through the electronic device through a network interface. It is to be understood that the present specification does not set any limit to the manner of acquiring the image to be processed.
The image to be processed comprises a plurality of regions formed by pixel points, each region comprises at least one pixel point, at least one target region in the image to be processed is determined, and the target region comprises the pixel points forming the seal. For example, as shown in fig. 3, fig. 3 is a schematic diagram illustrating a comparison of an image to be processed according to an embodiment of the present disclosure, and a target area 201 of a stamp is included in an image to be processed 301 on the left side of fig. 3.
In an embodiment, the method for acquiring the target region including the stamp in the image to be processed may be implemented by a stamp detection model, for example, a model including a pre-training sub-model, shuffle, and a classification sub-model Support Vector Machine (SVM). Specifically, feature extraction is performed on each candidate region of an input image to be processed through a Shufflenet, then the extracted features are input into an SVM, and the SVM predicts whether a seal is included and the position of the seal when the seal is included according to the extracted image features. And if the candidate area is detected to contain the seal, outputting an image to be detected with the mark comprising the target area of the seal. And if the detected image to be detected does not contain the seal, outputting the image to be processed before input. In addition, aiming at the fact that the image to be detected is a video frame image, frame extraction processing is firstly carried out on the video, and then the target area including the seal in the image to be processed is obtained through the method.
And S104, determining a plurality of saturation S components corresponding to the target color in the target area.
Determining a target color of a target area in an image to be processed, and further determining data of a saturation component S corresponding to each pixel point according to a plurality of pixel points corresponding to the target color, namely determining a plurality of saturation components S corresponding to the target color.
In one embodiment, the method of obtaining the target color is obtaining a preset target color. For example, since most of the current stamps on the market are red or blue, the preset target color is red and/or blue, that is, the preset target color is red, or the preset target color is blue, or the preset target colors are red and blue. For example, the target colors preset in the memory by the related art are red and blue, and the priority of the target color is red > blue; when the processor receives and executes the image processing method, according to the preset target color in the memory, firstly, a plurality of saturation S components corresponding to red in the target area are obtained; and if the pixel points corresponding to the target color of red do not exist in the target area, further according to a plurality of saturation S components corresponding to the target color of blue. And if the target area does not have a plurality of pixel points corresponding to the target color, outputting an error report prompt to prompt a user that the image processing process has a problem. It is understood that the specific color of the preset target color is determined according to the colors of most stamps on the market, the target colors of red and/or blue are only examples, and other color possibilities are also included in the present application.
In another embodiment, the method for obtaining the target color is to receive a selection instruction of the target color input by a user, and select the target color in response to the selection instruction. In the schematic architecture shown in fig. 2A, a user displays a selection frame of a plurality of target colors on an input element of the electronic device 201, for example, the selection frame of the target colors shown in fig. 2A includes selection frames corresponding to red, green, blue and yellow, respectively, inputs a selection instruction for selecting a target color to the electronic device 201, so that the processor of the electronic device 201 selects the target color based on the selection instruction, and further, the processor of the electronic device 201 acquires a plurality of S components corresponding to the target color of the target area.
If the target area of the image to be processed is an RGB color space, performing conversion of a hue saturation value HSV (hue, saturation, value) color space or conversion of a hue saturation luminance HSL (lightness) color space on the target area of the image to be processed, so as to obtain a plurality of S components corresponding to the target color in the target area, that is, data of a plurality of saturation S channels.
If the target area of the image to be processed is an HSV color space or an HSL color space, a plurality of S components corresponding to the target color, namely data of a plurality of saturation S channels, are directly obtained. For example, N pixel points in the target region corresponding to the target color have saturation S components of 2, 34, 65, 34, 35, 8 … … and X respectively n In other words, the target color corresponds to N saturation S components.
The method for determining the plurality of S components corresponding to the target pixel value may be to further obtain the S components corresponding to the target pixel point in the HSV color space according to the target pixel point corresponding to the target pixel value in the RGB color space. For example, the target color is red in RGB color space, and a plurality of target pixel points whose pixel values are red pixel values are obtained, and a component value of saturation S corresponding to each pixel target pixel point in HSV color space or HSL color space.
The method for determining the plurality of S components corresponding to the target pixel value may further determine a target color according to the S value and the V value in the HSV color space, and further determine a plurality of target pixel points corresponding to the target color and an S component corresponding to each target pixel point, thereby obtaining a plurality of saturation S components corresponding to the target color in the target region.
And S106, determining pixel points corresponding to the minimum M S components in the S components as target pixel points.
When the stamp is overlapped with other text contents in the image to be processed, the saturation of the overlapped part is higher than that of the part which is not overlapped on the stamp because the text contents are mostly black or darker than the background color of the image to be processed. In other words, the target pixel point is a pixel point with low saturation, and the pixel point corresponding to the M smallest S components in the plurality of S components is the target pixel point, that is, the pixel point corresponding to the seal region.
In one embodiment, the value of M is a product of the total number of the plurality of S components and a preset percentage. For example, the preset percentage is 20%, and the target region includes S components corresponding to 100 target colors, so that the number corresponding to the product of the total number of the S components and the preset percentage is obtained as the value of M, that is, M is 20, and further, pixel points corresponding to 20S components with the minimum value in the target region are obtained as target pixel points.
In another embodiment, M takes on a predetermined value. For example, the relevant technician sets M to be 50 as needed, and after the processor determines a plurality of saturation S components corresponding to the target color in the target region, determines, according to the value of M stored in the memory, a pixel point corresponding to 50S components with the smallest value among the plurality of S components as a target pixel point. It can be understood that the relationship between the value of M and the number of S components corresponding to the target color included in the target region is set by the relevant technical personnel as required, for example, the value of M is set to be constantly less than or equal to the number of the plurality of saturation S components corresponding to the target color in the target region, and when it is detected that the preset value of M is greater than the number of the plurality of saturation S components corresponding to the target color in the target region, the value of M is a product of the total number of the plurality of S components and a preset percentage.
In one embodiment, a plurality of S components corresponding to the target color are sorted from small to large, and pixel points corresponding to M S components sorted in the front are determined as target pixel points. For example, when M is a preset value, a plurality of S components corresponding to the target color are sorted from small to large, and pixel points corresponding to M S components in the top of the sorting are target pixel points. For another example, when the value of M is the product of the total number of the S components and a preset percentage, the preset percentage is 20%, the S components corresponding to the target color are sorted from small to large, and the pixels sorted to the top 20% are target pixels.
In another embodiment, a plurality of S components corresponding to the target color are sorted from large to small, and pixel points corresponding to M S components sorted later are determined as target pixel points. For example, when M is a preset value, a plurality of S components corresponding to the target color are sorted from large to small, and pixel points corresponding to M S components sorted later are target pixel points. For another example, when the value of M is the product of the total number of the S components and a preset percentage, the preset percentage is 50%, the S components corresponding to the target color are sorted from large to small, and the pixels in the last 50% of the sorted S components are the target pixels.
It should be understood that the values of M and the specific values of the preset percentage in the above embodiments are only examples, and the present specification does not limit this.
And S104, setting the pixel value of the target pixel point as a target pixel value.
Setting the pixel value of a target pixel point as the seal content as a target pixel value, wherein the color corresponding to the target pixel value is different from the color of the text content of the image to be processed. For example, the color of the text content of the non-stamp area of the image to be processed is black, so the color corresponding to the target pixel value may be any other color except black, preset or based on the user selection. For another example, the color of the text content of the non-stamp area of the image to be processed includes black, green, and yellow, and thus the color corresponding to the target pixel value may be any other color than black, green, and yellow, which is preset or based on the user selection. As shown in fig. 2A, after the user selects the target color through the display element of the electronic device 301 to remove the target color in the target region, the user continues to select the color to be filled through the display element of the electronic device 301, so that the electronic device 301 obtains the pixel value of the color to be filled as the target pixel value based on the selection instruction, and sets the pixel value of the target pixel point to the target pixel value.
In one embodiment, the target pixel value is a pixel value of a background color of the image to be processed, that is, the pixel value of the target pixel point is set as the pixel value of the background color of the image to be processed, so that a user can view the image to be processed without the influence of the stamp more intuitively. As shown in fig. 3, fig. 3 is a schematic diagram illustrating a comparison of an image to be processed according to an embodiment of the present disclosure, and a to-be-processed image 302 on the right side of fig. 3 is a to-be-processed image 301 with a stamp partial image in a target area 201 removed.
In another embodiment, the pixel value of the target pixel point may be set to be transparent, in other words, in a matrix sequence formed by a plurality of pixel points corresponding to the image to be processed, the matrix value corresponding to the target pixel point is deleted, or the matrix value corresponding to the target pixel point is set to null, so that the processor further performs processing such as character recognition on the image to be processed, and the processing efficiency is improved.
In one embodiment, the method for acquiring the pixel value of the background color of the image to be processed comprises the following steps: and acquiring the pixel value of the background color of the image to be processed through the gray level histogram corresponding to the image to be processed. Specifically, a Gray Scale Image corresponding to the whole Image to be processed is obtained, the Gray histogram is a function about Gray level distribution, and the occurrence frequency of a Gray value is counted according to the pixel values of all pixel points in the Image to be processed and the Gray value of the pixel point. Therefore, the gray histogram represents the number of pixel points with certain gray level in the image to be processed, and reflects the frequency of certain gray level in the image to be processed. Further, determining the median of the multiple grayscales in the grayscale histogram as a target gray, determining the color in the RGB color space corresponding to the target gray as the background color of the image to be processed, that is, the pixel value in the RGB color space corresponding to the target gray is a target pixel value, and setting the pixel value of the target pixel point as the target pixel value.
In another embodiment, a method of acquiring pixel values of a background color of an image to be processed includes: obtaining the component of each color channel in the RGB image corresponding to the image to be processed, and determining the pixel value of the background color of the image to be processed. Specifically, RGB three-channel components of each pixel point of an image to be processed in an RGB color space are obtained, medians corresponding to an R channel, a G channel and a B channel are obtained respectively, and finally the combined color is used as the background color of the image to be processed. For example, the image to be processed includes 10 pixel points, components corresponding to the R channel in the RGB three-channel components corresponding to the 10 pixel points are 0, 35, 23, 0, 80, and the R channel components are sequenced to obtain a sequence: 0. 0, 23, 35, 80, obtaining the median 0 as the target component of the R channel, and continuing to obtain the medias corresponding to the G channel and the B channel respectively according to the above steps, for example, the median of the G channel and the median of the B channel are both 0, so that (0,0,0) is used as the target pixel value, and the pixel value of the target pixel point is set as the target pixel value.
In the embodiment, the pixel value of the background color of the image to be processed is used as the target pixel value of the stamp filling area, and the stamp and other text contents in the image to be processed are effectively distinguished, so that the user can conveniently check the stamp and the other text contents.
The method and the device for processing the image to be processed have the advantages that the target area including the stamp in the image to be processed is obtained, only the target area is processed to obtain the multiple saturation S components corresponding to the target area, the problem of low efficiency caused by processing the whole image to be processed can be avoided, and the problem of judgment errors caused by processing irrelevant areas when the whole image to be processed is processed in a color space is avoided; further, the specification determines pixel points corresponding to the minimum M S components in the S components as target pixel points, namely, the target pixel points are determined by adopting an S space sequencing and dividing method, so that the seal is effectively distinguished from other contents in the image to be processed; finally, filling a pixel area corresponding to the seal by a method of modifying the pixel value of the target pixel point, and avoiding damaging other contents in the image to be processed; the image processing method for segmenting the seal and reserving other contents provided by the specification is simple, efficient and high in accuracy.
In one embodiment, as shown in fig. 5, a flowchart of an image processing method proposed for the embodiments of the present specification, which can be implemented by relying on a computer program, can be run on an image processing apparatus based on the von neumann architecture. The computer program may be integrated into the application or may run as a separate tool-like application.
Specifically, the image processing method specifically includes the steps of:
s202, acquiring a plurality of candidate areas in the image to be processed.
And acquiring a plurality of candidate regions in the image to be processed through a preset candidate region selection model. For example, a plurality of candidate regions in the image to be processed are acquired through a fast region convolution neural network fast-RCNN. Fig. 6 is a schematic flowchart of another image processing method provided in an embodiment of the present disclosure, and fig. 6 is a flowchart of another image processing method, including an image to be processed 400. A candidate region 401, a candidate region 402, a candidate region 403, a candidate region 404, and a candidate region 405 on the image to be processed 400 are acquired. It is to be understood that the number and form of the candidate regions shown in fig. 6 are only illustrative, and the present specification does not limit this.
And S204, determining a target area including the seal in the plurality of candidate areas according to a preset size condition.
In one embodiment, the predetermined size condition is that the size value of the candidate region is within a first predetermined range. Because the size of the actual stamp is relatively fixed, and the shape of the stamp is generally circular or square, that is, the size of the stamp area is relatively fixed. Therefore, the target area including the stamp in the plurality of candidate areas can be quickly determined through the preset size condition that the size value is in the first preset range. For example, the shape of the seal of each stage of government, court or conference is generally circular, the diameter is 4.2cm, the width of the circular edge is 0.1cm, the size of the seal of the contract of the industry and commerce is generally circular, the diameter is 5.8cm, the width of the circular edge is 0.1cm, and the first preset range includes: the length is 3 cm-7 cm, and the width is 3 cm-7 cm.
In another embodiment, the preset size condition is that the aspect ratio of the candidate region is within a second preset range. Because the size of the actual stamp is relatively fixed and the stamp is generally circular or square, i.e., the size of the stamp area is relatively fixed. And the target area including the seal in the plurality of candidate areas can be quickly determined through the preset size condition that the aspect ratio of the candidate areas is within the second preset range. For example, the second predetermined range of aspect ratios of the candidate regions is 0.5 to 2.
In another embodiment, the predetermined size condition is that the size value of the candidate region is within a first predetermined range and the aspect ratio of the candidate region is within a second predetermined range. Specifically, at least one first candidate region with a size value in a first preset range is obtained from the plurality of candidate regions, and further, a target region is obtained from the plurality of first candidate regions according to a size condition that an aspect ratio of the candidate region is in a second preset range. For example, the size value of at least one first candidate region satisfies a first preset range: the length is 3 cm-7 cm, the width is 3 cm-7 cm, and a target area which meets the second preset range of the aspect ratio of the candidate area and is 0.5-2 is further determined.
In addition, if there is a candidate region in the plurality of candidate regions that satisfies that the size value of the candidate region is within the first preset range, but there is no candidate region that satisfies that the aspect ratio of the candidate region is within the second preset range, it indicates that the shooting angle of the image to be processed does not satisfy the requirement, for example, an included angle between the shooting surface of the user and the image to be processed is greater than 45 °, that is, the user shoots the image to be processed by a shooting angle that is not parallel to the image to be processed. And if the situation exists, outputting prompt information for prompting the user to shoot or upload the image to be processed again.
It should be understood that the dimensional conditions shown in the present embodiment are only examples, and the present specification includes specific numerical values corresponding to any one of the dimensional conditions, which are set by a person skilled in the relevant art as required.
As shown in fig. 6, fig. 6 is a schematic flowchart of another image processing method provided in an embodiment of the present specification, including an image to be processed 400. The method comprises the steps of obtaining a candidate region 401, a candidate region 402, a candidate region 403, a candidate region 404 and a candidate region 405 on an image 400 to be processed, and obtaining a target region 403 containing a stamp on the image 400 to be processed through a preset size condition.
In an embodiment, if the number of the target regions meeting the preset size condition is greater than 1, the target region with the largest pixel area among the plurality of target regions is determined as the target region to be processed, or the target region to be processed is determined through a selection box input by a user. The final target area is determined by the pixel area, and only the stamp area which may cover the text content of the image to be processed in the image to be processed to the maximum extent or has the maximum influence on the image to be processed is processed in the embodiment, so that the image processing efficiency is improved.
And S206, carrying out hue saturation value HSV color space transformation on the target area to obtain a plurality of saturation S components corresponding to the target color in the target area.
The target region is subjected to hue saturation value HSV COLOR space transformation, for example, the target region of RGB COLOR space is converted to HSV COLOR space by cvtColor (frame, cv-COLOR-BGR 2 HSV) function of OpenCV. And extracting a plurality of saturation S components corresponding to the target color in the HSV color space, namely data of a plurality of S channels corresponding to the target color. As shown in fig. 6, the target area 403 is subjected to HSV color space transformation, resulting in the target area 403 based on HSV color space.
And S208, determining pixel points corresponding to the minimum M S components in the S components as target pixel points.
See S104 above, which is not described herein again. As shown in fig. 6, a plurality of S components of the target color in the target area 402 are sorted, where in fig. 6, the S components are sorted from small to large, and the pixels sorted by the first percentage before the sorting are the target pixels, that is, the pixels corresponding to the S components of the first preset percentage before the sorting are the target pixels.
S210, setting the pixel value of the target pixel point as a target pixel value.
See S106 above, which is not described herein again. As shown in fig. 6, the target area in the HSV color space is converted into an RGB color space, and the pixel value of the target pixel point corresponding to the stamp area in the target area in the to-be-processed image in the RGB color space is further set as a target pixel value, so that the user can check the target pixel value conveniently.
The method and the device for processing the image to be processed have the advantages that the target area including the seal in the image to be processed is obtained, only the target area is processed to obtain the multiple saturation S components corresponding to the target area, the problem of low efficiency caused by processing the whole image to be processed can be avoided, and the problem of judgment errors caused by processing the irrelevant area when the color space of the whole image to be processed is avoided; further, the specification determines pixel points corresponding to the minimum M S components in the S components as target pixel points, namely, the target pixel points are determined by adopting an S space sequencing and dividing method, so that the seal is effectively distinguished from other contents in the image to be processed; finally, filling a pixel area corresponding to the seal by a method of modifying the pixel value of the target pixel point, and avoiding damaging other contents in the image to be processed; the image processing method for segmenting the seal and reserving other contents provided by the specification is simple, efficient and high in accuracy.
The following are examples of apparatus that may be used to perform embodiments of the methods described herein. For details which are not disclosed in the embodiments of the apparatus of the present description, reference is made to the embodiments of the method of the present description.
Referring to fig. 7, a schematic structural diagram of an image processing apparatus provided in an exemplary embodiment of the present specification is shown. The image processing apparatus may be implemented as all or a part of an apparatus by software, hardware, or a combination of both. The image processing apparatus includes a region acquisition module 702, a first determination module 704, a second determination module 706, and a pixel setting module 708.
An area obtaining module 702, configured to obtain a target area including a stamp in an image to be processed;
a first determining module 704, configured to determine a plurality of saturation S components corresponding to a target color in the target region;
a second determining module 706, configured to determine, as target pixels, pixels corresponding to M smallest S components in the plurality of S components;
a pixel setting module 708, configured to set a pixel value of the target pixel point as a target pixel value.
In one embodiment, the second determining module 706 includes:
the first sequencing module is used for sequencing a plurality of S components corresponding to the target color from small to large and determining pixel points corresponding to M S components which are sequenced at the front as target pixel points; or
And the second sorting module is used for sorting the plurality of S components corresponding to the target color from large to small and determining pixel points corresponding to M S components which are sorted later as target pixel points.
In one embodiment, the value of M is a product of the total number of the S components and a preset percentage; or the value of M is a preset value.
In one embodiment, the first determining module 704 includes:
and the color transformation unit is used for carrying out hue saturation value HSV color space transformation on the target area to obtain a plurality of saturation S components corresponding to the target color in the target area.
In one embodiment, the region acquisition module 702 includes:
the candidate acquisition unit is used for acquiring a plurality of candidate areas in the image to be processed;
and the size determining unit is used for determining the target areas including the seals in the candidate areas according to a preset size condition.
In one embodiment, the dimensional conditions include: the size value of the candidate region is within a first preset range and/or the aspect ratio of the candidate region is within a second preset range.
In an embodiment, the candidate obtaining unit is specifically configured to:
and acquiring a plurality of candidate areas in the image to be processed through a fast area convolution neural network.
In one embodiment, the target pixel value is a pixel value of a background color of the image to be processed.
In one embodiment, the image processing apparatus further comprises:
and the background acquisition module is used for determining the pixel value of the background color of the image to be processed according to the gray level histogram corresponding to the image to be processed or the component of each color channel in the RGB image.
In one embodiment, the image processing apparatus further comprises:
the preset color unit is used for acquiring a preset target color; or the like, or, alternatively,
the instruction receiving unit is used for receiving a selection instruction of a target color input by a user and responding to the selection instruction to select the target color.
It should be noted that, when the image processing apparatus provided in the foregoing embodiment executes the image processing method, only the division of the functional modules is illustrated, and in practical applications, the above functions may be distributed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions. In addition, the image processing apparatus and the image processing method provided by the above embodiments belong to the same concept, and details of implementation processes thereof are referred to in the method embodiments and are not described herein again.
The method and the device for processing the image to be processed have the advantages that the target area including the stamp in the image to be processed is obtained, only the target area is processed to obtain the multiple saturation S components corresponding to the target area, the problem of low efficiency caused by processing the whole image to be processed can be avoided, and the problem of judgment errors caused by processing irrelevant areas when the whole image to be processed is processed in a color space is avoided; further, the specification determines pixel points corresponding to the minimum M S components in the S components as target pixel points, namely, the target pixel points are determined by adopting an S space sequencing and dividing method, so that the seal is effectively distinguished from other contents in the image to be processed; finally, filling a pixel area corresponding to the seal by a method of modifying the pixel value of the target pixel point, and avoiding damaging other contents in the image to be processed; the image processing method for segmenting the seal and reserving other contents provided by the specification is simple, efficient and high in accuracy.
The above example numbers are for description only and do not represent the merits of the examples.
An embodiment of the present specification further provides a computer storage medium, where the computer storage medium may store a plurality of instructions, where the instructions are suitable for being loaded by a processor and executing the image processing method according to the embodiment shown in fig. 1 to 6, and a specific execution process may refer to specific descriptions of the embodiment shown in fig. 1 to 6, which is not described herein again.
The present specification further provides a computer program product, where at least one instruction is stored, and the at least one instruction is loaded by the processor and executes the image processing method according to the embodiment shown in fig. 1 to 6, where a specific execution process may refer to specific descriptions of the embodiment shown in fig. 1 to 6, and is not described herein again.
Please refer to fig. 8, which provides a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. As shown in fig. 8, the electronic device 800 may include: at least one processor 801, at least one network interface 804, a user interface 803, a memory 805, at least one communication bus 802.
Wherein a communication bus 802 is used to enable connective communication between these components.
The user interface 803 may include a Display screen (Display) and a Camera (Camera), and the optional user interface 803 may also include a standard wired interface and a wireless interface.
The network interface 804 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface).
Processor 801 may include one or more processing cores, among other things. The processor 801 interfaces with various components throughout the server 800 using various interfaces and lines to perform various functions of the server 800 and process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 805 and invoking data stored in the memory 805. Alternatively, the processor 801 may be implemented in at least one hardware form of Digital Signal Processing (DSP), field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 801 may integrate one or a combination of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen; the modem is used to handle wireless communications. It is to be understood that the modem may not be integrated into the processor 801, but may be implemented by a single chip.
The Memory 805 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 805 includes a non-transitory computer-readable medium. The memory 805 may be used to store an instruction, a program, code, a set of codes, or a set of instructions. The memory 805 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, and the like; the storage data area may store data and the like referred to in the above respective method embodiments. The memory 805 may optionally be at least one memory device located remotely from the processor 801. As shown in fig. 8, the memory 805, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and an image processing application program.
In the electronic device 800 shown in fig. 8, the user interface 803 is mainly used as an interface for providing input for a user, and acquiring data input by the user; and the processor 801 may be configured to invoke an image processing application stored in the memory 805 and specifically perform the following operations:
acquiring a target area including a seal in an image to be processed;
determining a plurality of saturation S components corresponding to the target color in the target area;
determining pixel points corresponding to the minimum M S components in the S components as target pixel points;
and setting the pixel value of the target pixel point as a target pixel value.
In an embodiment, the processor 801 executes the following steps of determining a pixel point corresponding to the M smallest S components in the plurality of S components as a target pixel point:
sequencing a plurality of S components corresponding to the target color from small to large, and determining pixel points corresponding to M S components which are sequenced at the front as target pixel points; or
And sequencing the plurality of S components corresponding to the target color from large to small, and determining pixel points corresponding to M S components which are sequenced later as target pixel points.
In one embodiment, the value of M is a product of the total number of the S components and a preset percentage; or the value of M is a preset value.
In one embodiment, the processor 801 performs the determining of the multiple saturation S components corresponding to the target color in the target region, specifically performs:
and carrying out Hue Saturation Value (HSV) color space transformation on the target area to obtain a plurality of saturation S components corresponding to the target color in the target area.
In an embodiment, the processor 801 executes the obtaining of the target area including the stamp in the image to be processed, specifically executing:
acquiring a plurality of candidate regions in the image to be processed;
and determining the target areas including the seal in the plurality of candidate areas according to a preset size condition.
In one embodiment, the dimensional conditions include: the size value of the candidate region is within a first preset range and/or the aspect ratio of the candidate region is within a second preset range.
In one embodiment, the processor 801 performs the acquiring of the plurality of candidate regions in the image to be processed specifically by:
and acquiring a plurality of candidate areas in the image to be processed through a fast area convolution neural network.
In one embodiment, the target pixel value is a pixel value of a background color of the image to be processed.
In one embodiment, before the processor 801 performs the setting of the pixel value of the target pixel point to the target pixel value, the following is further performed:
and determining the pixel value of the background color of the image to be processed according to the gray level histogram corresponding to the image to be processed or the component of each color channel in the RGB image.
In one embodiment, before the processor 801 performs the determining of the plurality of saturation S components corresponding to the target color in the target region, the following is further performed:
the preset color unit is used for acquiring a preset target color; or the like, or, alternatively,
and the receiving instruction unit is used for receiving a selection instruction of the target color input by a user and selecting the target color in response to the selection instruction.
The method and the device for processing the image to be processed have the advantages that the target area including the seal in the image to be processed is obtained, only the target area is processed to obtain the multiple saturation S components corresponding to the target area, the problem of low efficiency caused by processing the whole image to be processed can be avoided, and the problem of judgment errors caused by processing the irrelevant area when the color space of the whole image to be processed is avoided; further, the specification determines pixel points corresponding to the minimum M S components in the S components as target pixel points, namely, the target pixel points are determined by adopting an S space sequencing and dividing method, so that the seal is effectively distinguished from other contents in the image to be processed; finally, filling a pixel area corresponding to the seal by a method of modifying the pixel value of the target pixel point, and avoiding damaging other contents in the image to be processed; the image processing method for segmenting the seal and reserving other contents provided by the specification is simple, efficient and high in accuracy.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory or a random access memory.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present disclosure, and it is not intended to limit the scope of the present disclosure, so that the present disclosure will be covered by the claims and their equivalents.

Claims (14)

1. A method of image processing, the method comprising:
acquiring a target area including a seal in an image to be processed;
determining a plurality of saturation S components corresponding to the target color in the target area;
determining pixel points corresponding to the minimum M S components in the S components as target pixel points;
and setting the pixel value of the target pixel point as a target pixel value.
2. The method according to claim 1, wherein the determining the pixel point corresponding to the minimum M S components in the plurality of S components as a target pixel point comprises:
sequencing a plurality of S components corresponding to the target color from small to large, and determining pixel points corresponding to M S components which are sequenced at the front as target pixel points; or
And sequencing the plurality of S components corresponding to the target color from large to small, and determining pixel points corresponding to M S components which are sequenced later as target pixel points.
3. The method according to claim 1 or 2, wherein the value of M is a product of a total number of the plurality of S components and a preset percentage; or the value of M is a preset value.
4. The method of claim 1, the determining a plurality of saturation S-components corresponding to a target color in the target region, comprising:
and carrying out Hue Saturation Value (HSV) color space transformation on the target area to obtain a plurality of saturation S components corresponding to the target color in the target area.
5. The method according to claim 1, wherein the acquiring the target area including the stamp in the image to be processed comprises:
acquiring a plurality of candidate regions in the image to be processed;
and determining the target areas including the seal in the plurality of candidate areas according to a preset size condition.
6. The method of claim 5, the dimensional conditions comprising: the size value of the candidate region is within a first preset range and/or the aspect ratio of the candidate region is within a second preset range.
7. The method of claim 5, the obtaining a plurality of candidate regions in the image to be processed comprising:
and acquiring a plurality of candidate areas in the image to be processed through a fast area convolution neural network.
8. The method of claim 1, the target pixel value being a pixel value of a background color of the image to be processed.
9. The method of claim 8, wherein before setting the pixel value of the target pixel point to the target pixel value, further comprising:
and determining the pixel value of the background color of the image to be processed according to the gray level histogram corresponding to the image to be processed or the component of each color channel in the RGB image.
10. The method of claim 1, prior to determining a plurality of saturation S components corresponding to a target color in the target region, further comprising:
acquiring a preset target color; or the like, or, alternatively,
receiving a target color selection instruction input by a user, and selecting the target color in response to the selection instruction.
11. An image processing apparatus, the apparatus comprising:
the region acquisition module is used for acquiring a target region including a seal in the image to be processed;
the first determination module is used for determining a plurality of saturation S components corresponding to the target color in the target area;
the second determining module is used for determining pixel points corresponding to the minimum M S components in the S components as target pixel points;
and the pixel setting module is used for setting the pixel value of the target pixel point as a target pixel value.
12. A computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the method steps according to any of claims 1 to 10.
13. A computer program product having stored thereon a plurality of instructions adapted to be loaded by a processor and to carry out the method steps according to any one of claims 1 to 10.
14. An electronic device, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the method steps of any of claims 1 to 10.
CN202211136148.9A 2022-09-19 2022-09-19 Image processing method, image processing device, storage medium and electronic equipment Pending CN115601253A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211136148.9A CN115601253A (en) 2022-09-19 2022-09-19 Image processing method, image processing device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211136148.9A CN115601253A (en) 2022-09-19 2022-09-19 Image processing method, image processing device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN115601253A true CN115601253A (en) 2023-01-13

Family

ID=84843893

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211136148.9A Pending CN115601253A (en) 2022-09-19 2022-09-19 Image processing method, image processing device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115601253A (en)

Similar Documents

Publication Publication Date Title
CN108009675B (en) Goods packing method, device and system
CN109618173B (en) Video compression method, device and computer readable storage medium
CN108090511B (en) Image classification method and device, electronic equipment and readable storage medium
CN112162930B (en) Control identification method, related device, equipment and storage medium
CN107507160B (en) Image fusion method, terminal and computer readable storage medium
CN112651438A (en) Multi-class image classification method and device, terminal equipment and storage medium
CN110070101A (en) Floristic recognition methods and device, storage medium, computer equipment
US10810462B2 (en) Object detection with adaptive channel features
CN112101359B (en) Text formula positioning method, model training method and related device
CN103353881B (en) Method and device for searching application
US10180782B2 (en) Fast image object detector
CN111028276A (en) Image alignment method and device, storage medium and electronic equipment
CN111680690A (en) Character recognition method and device
CN115482529A (en) Method, equipment, storage medium and device for recognizing fruit image in near scene
CN111507119A (en) Identification code identification method and device, electronic equipment and computer readable storage medium
CN113284063A (en) Image processing method, image processing apparatus, electronic device, and readable storage medium
CN113052923A (en) Tone mapping method, tone mapping apparatus, electronic device, and storage medium
CN109657083B (en) Method and device for establishing textile picture feature library
CN109784379B (en) Updating method and device of textile picture feature library
CN109189246B (en) Method, device and system for processing scribbled content on handwriting board
CN113132786A (en) User interface display method and device and readable storage medium
CN111179287A (en) Portrait instance segmentation method, device, equipment and storage medium
CN111107264A (en) Image processing method, image processing device, storage medium and terminal
CN111160240A (en) Image object recognition processing method and device, intelligent device and storage medium
EP4047547A1 (en) Method and system for removing scene text from images

Legal Events

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