WO2021139179A1 - Image sample generation method and apparatus based on local shadow special effect - Google Patents

Image sample generation method and apparatus based on local shadow special effect Download PDF

Info

Publication number
WO2021139179A1
WO2021139179A1 PCT/CN2020/111946 CN2020111946W WO2021139179A1 WO 2021139179 A1 WO2021139179 A1 WO 2021139179A1 CN 2020111946 W CN2020111946 W CN 2020111946W WO 2021139179 A1 WO2021139179 A1 WO 2021139179A1
Authority
WO
WIPO (PCT)
Prior art keywords
picture
image
uniform light
pixel
blurred
Prior art date
Application number
PCT/CN2020/111946
Other languages
French (fr)
Chinese (zh)
Inventor
雷晨雨
程晓
张国辉
宋晨
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021139179A1 publication Critical patent/WO2021139179A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration by the use of more than one image, e.g. averaging, subtraction
    • G06T5/73
    • G06T5/90
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20212Image combination
    • G06T2207/20221Image fusion; Image merging
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02TCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
    • Y02T10/00Road transport of goods or passengers
    • Y02T10/10Internal combustion engine [ICE] based vehicles
    • Y02T10/40Engine management systems

Definitions

  • This application relates to the field of artificial intelligence image processing technology, and in particular to a method, device, computer equipment, and storage medium for generating image samples based on partial shadow special effects.
  • ID cards are objects related to personal privacy. Due to factors such as security and privacy, the collection is very difficult. Therefore, when doing ID card-related algorithm research, there is an extreme lack of ID card image samples, which makes it more difficult to obtain sample data for training ID card recognition models.
  • the embodiment of the application provides an image sample generation method, device, computer equipment, and storage medium based on partial shadow special effects, aiming to solve the extreme lack of ID card image samples in the process of training ID card recognition models in the prior art, resulting in training The problem of increasing difficulty in obtaining sample data of ID card recognition model.
  • an embodiment of the present application provides an image sample generation method based on partial shadow special effects, which includes:
  • an embodiment of the present application provides an image sample generating device based on partial shadow special effects, which includes:
  • the picture receiving unit is used to receive and save the input picture
  • the contrast and brightness adjustment unit is used to call a pre-stored contrast and brightness adjustment algorithm to adjust the contrast and brightness of the input picture to obtain dark pictures and bright pictures corresponding to the input picture;
  • the fuzzy forward uniform light image acquisition unit is configured to acquire the original image size of the input image, initialize an initial fuzzy forward uniform light image according to the original image size, and blur the initial blurred forward uniform light image Forward homogenization, get the current fuzzy positive homogenization picture;
  • the Gaussian blur unit is used to perform Gaussian blurring on the current blurred forward uniform light picture to obtain a Gaussian blurred picture;
  • the picture synthesis unit is configured to synthesize the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture.
  • an embodiment of the present application provides a computer device, which includes a memory, a processor, and a computer program stored on the memory and running on the processor, and the processor executes the computer
  • the program implements the image sample generation method based on the partial shadow special effect described in the first aspect.
  • an embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the above-mentioned first On the one hand, the method for generating image samples based on local shadow special effects.
  • the embodiment of the application provides an image sample generation method, device, computer equipment, and storage medium based on partial shadow special effects, including receiving and saving an input picture; calling a pre-stored contrast brightness adjustment algorithm, and performing contrast brightness on the input picture Adjust to obtain the dark picture and the bright picture corresponding to the input picture; obtain the original image size of the input picture, initialize according to the original image size to obtain an initial blur forward uniform light picture, and compare the initial blur forward Perform a fuzzy forward homogenization picture to obtain a current blurred forward homogenization picture; perform Gaussian blurring on the current fuzzy forward homogenization picture to obtain a Gaussian blurred picture; and according to the dark picture and the corresponding dark picture of the input picture
  • the bright picture and the Gaussian blurred picture are synthesized to obtain an image sample corresponding to the input picture. It realizes the expansion of the image samples of the input pictures based on the special effects of partial shadows, which reduces the difficulty of obtaining ID card image samples, and the expanded image samples are close to the samples taken in the real scene, which
  • FIG. 1 is a schematic diagram of an application scenario of an image sample generation method based on partial shadow effects provided by an embodiment of the application;
  • FIG. 2 is a schematic flowchart of an image sample generation method based on partial shadow effects provided by an embodiment of the application
  • FIG. 3 is a schematic block diagram of an image sample generating apparatus based on partial shadow special effects provided by an embodiment of the application;
  • Fig. 4 is a schematic block diagram of a computer device provided by an embodiment of the application.
  • FIG. 1 is a schematic diagram of an application scenario of an image sample generation method based on partial shadow special effects provided by an embodiment of this application
  • FIG. 2 is a schematic diagram of an image sample generation method based on partial shadow special effects provided by an embodiment of this application
  • a schematic flow chart The method for generating image samples based on partial shadow special effects is applied to a server, and the method is executed by application software installed in the server.
  • the method includes steps S110 to S150.
  • the input picture including one or more ID card pictures may be sent from the user end to the server.
  • an example of generating another image sample based on a single ID card picture (that is, the aforementioned input picture) is taken as an example.
  • one image sample is generated based on a single ID card image based on an image sample based on the local shadow special effect, and then multiple image samples are generated based on a single ID card image and repeated multiple times based on the image sample based on the local shadow special effect. In this way, the number of ID card image samples can be effectively expanded, and the problem of the extreme lack of ID card image samples in the process of training the ID card recognition model is solved.
  • S120 Invoke a pre-stored contrast and brightness adjustment algorithm, adjust the contrast and brightness of the input picture, to obtain a dark picture and a bright picture corresponding to the input picture.
  • the server obtains an input picture
  • the locally stored contrast and brightness adjustment algorithm can be called at this time
  • the input picture is darkened to obtain a dark picture
  • the input picture is brightened Process to get a bright picture.
  • the dark picture and the light picture obtained at this time are to be superimposed with the subsequent Gaussian blurred picture, so as to generate an image sample with a better simulation input picture effect.
  • the contrast brightness adjustment algorithm is:
  • y ij [x ij -127.5*(1-B)]*k+127.5*(1+B);
  • x ij represents the pixel value of the pixel in the i-th row and j-th column of the input image
  • y ij represents the pixel value of the pixel in the i-th row and j-th column after the contrast brightness adjustment
  • B is the brightness adjustment parameter
  • B The value range of is [-1,1]
  • the value range of the brightness adjustment parameter B is [-1,1], and its function is to adjust the brightness of the image.
  • B takes a value between [-1,0]
  • the input image can be adjusted.
  • Dark when B takes a value between [0,1], the input picture can be brightened.
  • the value range of the contrast adjustment parameter k is [-1,1], and its function is to adjust the contrast of the image
  • the value range of arctan(k) is [1,89].
  • step S120 includes:
  • the uneven brightness distribution may occur in the bright picture or the dark picture, which seriously affects the picture quality and increases the difficulty of subsequent image processing.
  • the image can be homogenized.
  • the MASK uniform light algorithm can be used to process the picture to enhance high-frequency information and suppress low-frequency information, thereby enhancing the detail contrast of the picture and suppressing abnormal brightness changes of the picture, so as to achieve the purpose of uniform light.
  • an initial fuzzy forward uniform light picture with the same picture size as the input picture is initially generated (it can also be It is understood that the initial blurred forward uniform light picture is exactly the same as the input picture), and then the MASK uniform light is performed on it to obtain the current blurred forward uniform light picture.
  • the obtained current fuzzy forward homogenized image can participate in the processing of dark or bright images after further processing, thereby enhancing the detail contrast of the obtained sample image and suppressing abnormal brightness changes of the sample image.
  • step S130 includes:
  • a current fuzzy forward uniform light image is obtained during initialization, and the current fuzzy forward uniform light image can be subjected to planar MASK using the planar MASK algorithm (that is, the planar fuzzy forward uniform light algorithm) to obtain the current Blur the picture with the forward uniform light.
  • planar MASK algorithm that is, the planar fuzzy forward uniform light algorithm
  • each pixel in the current blurred forward uniform light image is judged as follows:
  • step S130 includes:
  • the initial fuzzy forward uniform light image is subjected to planar fuzzy forward uniform light through the curved surface fuzzy forward uniform light algorithm, to obtain the current fuzzy forward uniform light image;
  • a current fuzzy forward uniform light image is obtained during initialization, and the current fuzzy forward uniform light image can also be surface-masked through the curved surface MASK algorithm (that is, the curved surface fuzzy forward uniform light algorithm), to obtain The current picture is blurred forward and even light.
  • each pixel in the current blurred forward uniform light image is judged as follows:
  • any one of the planar MASK algorithm or the curved surface MASK algorithm can be selected to perform the homogenization process on the initial fuzzy forward homogenization image.
  • S140 Perform Gaussian blurring on the current blurred forward uniform light image to obtain a Gaussian blurred image.
  • the Gaussian blur process of the image is the convolution of the image and the normal distribution. Since the normal distribution is also called Gaussian distribution, this technique is called Gaussian blur.
  • step S140 includes:
  • the filter kernel size is a random number in [10,100] to perform Gaussian blurring on the current blurred forward uniform light picture to obtain a Gaussian blurred picture;
  • (x, y) represents the current blurred forward uniform light picture
  • the pixel coordinates of, ⁇ is the variance of x.
  • Gaussian blur is defined in two-dimensional space as At this time, after Gaussian blurring is performed on the current blurred forward homogenized image through Gaussian blurring in the two-dimensional space, a Gaussian blurred image with reduced image noise and reduced level of detail can be obtained.
  • the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture are obtained in the previous steps.
  • the bright picture can be processed by Gaussian blurred picture, and the dark picture After Gaussian blurring, the pictures are processed and then superimposed to obtain image samples corresponding to the input pictures.
  • the generated picture samples have high fidelity.
  • step S150 includes:
  • the first final pixel matrix and the second final pixel matrix are added and summed to obtain an image sample corresponding to the input picture.
  • the purpose of normalizing the Gaussian blurred picture is to process it into a weight matrix, so as to calculate the respective weights of the bright pictures and the dark pictures when they are superimposed.
  • the first matrix is taken as the weight corresponding to the bright picture
  • the second matrix is taken as the weight corresponding to the dark picture
  • the first final pixel matrix and the second final pixel matrix are added and summed to obtain the input picture
  • the effects of the above-mentioned pictures obtained by special effects based on partial shadows are very close to samples taken in real scenes, and can even simulate samples that are difficult to collect in real scenes.
  • step S150 the method further includes:
  • Both the input picture and the image sample are sent to the user terminal.
  • the input picture and the image sample can be sent to the user terminal, and the user terminal can train the ID card recognition model based on the expanded image sample.
  • the method further includes:
  • the ID card recognition model (such as convolutional neural network) to be trained is trained in the user terminal according to the image training set including the input image and image samples, the obtained ID card recognition model is sent to the server Store it.
  • the ID card recognition model such as convolutional neural network
  • the method further includes:
  • the server can be used as a blockchain node device to upload the parameter set corresponding to the ID card identification model to the blockchain network, making full use of the non-tamperable characteristics of blockchain data to realize the ID card identification model
  • the data of the corresponding parameter set is solidified and stored.
  • the server After the server re-downloads and obtains the parameter set corresponding to the ID card recognition model from the blockchain network, it can restore the ID card recognition model again according to the parameter set corresponding to the ID card recognition model.
  • the corresponding summary information is obtained based on the parameter set corresponding to the ID card recognition model.
  • the summary information is obtained by hashing the parameter set corresponding to the ID card recognition model, for example, obtained by using the sha256 algorithm.
  • Uploading summary information to the blockchain can ensure its security and fairness and transparency to users.
  • the server can download the summary information from the blockchain to verify whether the parameter set corresponding to the ID card recognition model has been tampered with.
  • the blockchain referred to in this example is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of the information (anti-counterfeiting) and generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
  • This method realizes the expansion of image samples based on local shadow effects for input pictures, reduces the difficulty of obtaining ID card image samples, and the expanded image samples are close to samples taken in real scenes, which solves the problem of small samples.
  • An embodiment of the present application also provides an image sample generating device based on a partial shadow special effect, which is used to execute any embodiment of the aforementioned image sample generating method based on a partial shadow special effect.
  • FIG. 3 is a schematic block diagram of an image sample generating apparatus based on partial shadow special effects according to an embodiment of the present application.
  • the device 100 for generating image samples based on partial shadow special effects can be configured in a server.
  • the image sample generating device 100 based on the partial shadow special effect includes: a picture receiving unit 110, a contrast brightness adjustment unit 120, a blur forward uniform light picture acquisition unit 130, a Gaussian blur unit 140, and a picture synthesis unit 150.
  • the picture receiving unit 110 receives and saves the input picture.
  • the input picture including one or more ID card pictures may be sent from the user end to the server.
  • an example of generating another image sample based on a single ID card picture (that is, the aforementioned input picture) is taken as an example.
  • one image sample is generated based on a single ID card image based on an image sample based on the local shadow special effect, and then multiple image samples are generated based on a single ID card image and repeated multiple times based on the image sample based on the local shadow special effect. In this way, the number of ID card image samples can be effectively expanded, and the problem of the extreme lack of ID card image samples in the process of training the ID card recognition model is solved.
  • the contrast and brightness adjustment unit 120 is configured to call a pre-stored contrast and brightness adjustment algorithm to adjust the contrast and brightness of the input picture to obtain dark pictures and bright pictures corresponding to the input picture.
  • the server obtains an input picture
  • the locally stored contrast and brightness adjustment algorithm can be called at this time
  • the input picture is darkened to obtain a dark picture
  • the input picture is brightened Process to get a bright picture.
  • the dark picture and the light picture obtained at this time are to be superimposed with the subsequent Gaussian blurred picture, so as to generate an image sample with a better simulation input picture effect.
  • the contrast brightness adjustment algorithm is:
  • y ij [x ij -127.5*(1-B)]*k+127.5*(1+B);
  • x ij represents the pixel value of the pixel in the i-th row and j-th column of the input picture
  • y ij represents the pixel value of the pixel in the i-th row and j-th column after the contrast brightness adjustment
  • B is the brightness adjustment parameter
  • B The value range of is [-1,1]
  • the value range of the brightness adjustment parameter B is [-1,1], and its function is to adjust the brightness of the image.
  • B takes a value between [-1,0]
  • the input image can be adjusted.
  • Dark when B takes a value between [0,1], the input picture can be brightened.
  • the value range of the contrast adjustment parameter k is [-1,1], and its function is to adjust the contrast of the image
  • the value range of arctan(k) is [1,89].
  • the contrast and brightness adjustment unit 120 includes:
  • a pixel value obtaining unit configured to obtain the pixel value of each pixel in the input picture
  • the dark picture acquisition unit is used to call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [-1, 0], so as to perform brightness contrast on the pixel value of each pixel Adjust to obtain the first adjusted pixel value corresponding to each pixel to obtain a dark picture;
  • the bright picture acquisition unit is used to call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [0, 1] to adjust the brightness and contrast of the pixel value of each pixel , Obtain the second adjusted pixel value corresponding to each pixel point to obtain a bright picture.
  • the fuzzy forward uniform light image acquisition unit 130 is configured to acquire the original image size of the input image, initialize an initial fuzzy forward uniform light image according to the original image size, and perform processing on the initial blurred forward uniform light image Blur forward uniform light, get the current fuzzy forward uniform light picture.
  • the uneven brightness distribution may occur in the bright picture or the dark picture, which seriously affects the picture quality and increases the difficulty of subsequent image processing.
  • the image can be homogenized.
  • the MASK uniform light algorithm can be used to process the picture to enhance high-frequency information and suppress low-frequency information, thereby enhancing the detail contrast of the picture and suppressing abnormal brightness changes of the picture, so as to achieve the purpose of uniform light.
  • an initial fuzzy forward uniform light picture with the same picture size as the input picture is initially generated (it can also be It is understood that the initial blurred forward uniform light picture is exactly the same as the input picture), and then the MASK uniform light is performed on it to obtain the current blurred forward uniform light picture.
  • the obtained current fuzzy forward homogenized image can participate in the processing of dark or bright images after further processing, thereby enhancing the detail contrast of the obtained sample image and suppressing abnormal brightness changes of the sample image.
  • the fuzzy forward uniform light image acquisition unit 130 is further configured to:
  • a current fuzzy forward uniform light image is obtained during initialization, and the current fuzzy forward uniform light image can be subjected to planar MASK using the planar MASK algorithm (that is, the planar fuzzy forward uniform light algorithm) to obtain the current Blur the picture with the forward uniform light.
  • planar MASK algorithm that is, the planar fuzzy forward uniform light algorithm
  • each pixel in the current blurred forward uniform light image is judged as follows:
  • the fuzzy forward uniform light image acquisition unit 130 is further configured to:
  • the initial fuzzy forward uniform light image is subjected to planar fuzzy forward uniform light through the curved surface fuzzy forward uniform light algorithm, to obtain the current fuzzy forward uniform light image;
  • a current fuzzy forward uniform light image is obtained during initialization, and the current fuzzy forward uniform light image can also be surface-masked through the curved surface MASK algorithm (that is, the curved surface fuzzy forward uniform light algorithm), to obtain The current picture is blurred forward and even light.
  • each pixel in the current blurred forward uniform light image is judged as follows:
  • the high frequency information in the initial blurred forward uniform light image is also enhanced, the low frequency information therein is suppressed, and the abnormal brightness change of the initial blurred forward uniform light image is suppressed. That is, during specific implementation, any one of the planar MASK algorithm or the curved surface MASK algorithm can be selected to perform the homogenization process on the initial blurred forward homogenization image.
  • the Gaussian blurring unit 140 is configured to perform Gaussian blurring on the current blurred forward uniform light image to obtain a Gaussian blurred image.
  • the Gaussian blur process of the image is the convolution of the image and the normal distribution. Since the normal distribution is also called Gaussian distribution, this technique is called Gaussian blur.
  • the Gaussian blur unit 140 is also used for:
  • the filter kernel size is a random number in [10,100] to perform Gaussian blurring on the current blurred forward uniform light picture to obtain a Gaussian blurred picture;
  • (x, y) represents the current blurred forward uniform light picture
  • the pixel coordinates of, ⁇ is the variance of x.
  • Gaussian blur is defined in two-dimensional space as At this time, after Gaussian blurring is performed on the current blurred forward homogenized image through Gaussian blurring in the two-dimensional space, a Gaussian blurred image with reduced image noise and reduced level of detail can be obtained.
  • the picture synthesis unit 150 is configured to synthesize the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture.
  • the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture are obtained in the previous steps.
  • the bright picture can be processed by Gaussian blurred picture, and the dark picture After Gaussian blurring, the pictures are processed and then superimposed to obtain image samples corresponding to the input pictures.
  • the generated picture samples have high fidelity.
  • the picture synthesis unit 150 includes:
  • a normalization unit configured to perform normalization processing on the Gaussian blurred picture to obtain a normalized picture
  • a weight matrix calculation unit configured to obtain a pixel matrix corresponding to the normalized picture as a first matrix, and subtract the first matrix from the identity matrix to obtain a second matrix;
  • a picture weight processing unit configured to multiply the bright picture pixel matrix corresponding to the bright picture by the first matrix to obtain a first final pixel matrix, and multiply the pixel matrix corresponding to the dark picture by the second matrix where it is located Obtain the second final pixel matrix;
  • the picture weight summation and superposition unit is configured to add and sum the first final pixel matrix and the second final pixel matrix to obtain an image sample corresponding to the input picture.
  • the purpose of normalizing the Gaussian blurred picture is to process it into a weight matrix, so as to calculate the respective weights of the bright pictures and the dark pictures when they are superimposed.
  • the first matrix is taken as the weight corresponding to the bright picture
  • the second matrix is taken as the weight corresponding to the dark picture
  • the first final pixel matrix and the second final pixel matrix are added and summed to obtain the input picture
  • the effects of the above-mentioned pictures obtained by special effects based on partial shadows are very close to samples taken in real scenes, and can even simulate samples that are difficult to collect in real scenes.
  • the device 100 for generating image samples based on partial shadow special effects further includes:
  • the picture sending unit is configured to send both the input picture and the image sample to the user terminal.
  • the input picture and the image sample can be sent to the user terminal, and the user terminal can train the ID card recognition model based on the expanded image sample.
  • the device 100 for generating image samples based on partial shadow special effects further includes:
  • the model receiving unit is used to receive and store the ID card recognition model trained by the user terminal according to the picture training set including the input picture and the image sample.
  • the ID card recognition model (such as convolutional neural network) to be trained is trained in the user terminal according to the image training set including the input image and image samples, the obtained ID card recognition model is sent to the server Store it.
  • the ID card recognition model such as convolutional neural network
  • the device 100 for generating image samples based on partial shadow special effects further includes:
  • the parameter chaining unit is used to upload the parameter set corresponding to the ID card recognition model to the blockchain network.
  • the server can be used as a blockchain node device to upload the parameter set corresponding to the ID card identification model to the blockchain network, making full use of the non-tamperable characteristics of blockchain data to realize the ID card identification model
  • the data of the corresponding parameter set is solidified and stored.
  • the server After the server re-downloads and obtains the parameter set corresponding to the ID card recognition model from the blockchain network, it can restore the ID card recognition model again according to the parameter set corresponding to the ID card recognition model.
  • the corresponding summary information is obtained based on the parameter set corresponding to the ID card recognition model.
  • the summary information is obtained by hashing the parameter set corresponding to the ID card recognition model, for example, obtained by using the sha256 algorithm.
  • Uploading summary information to the blockchain can ensure its security and fairness and transparency to users.
  • the server can download the summary information from the blockchain to verify whether the parameter set corresponding to the ID card recognition model has been tampered with.
  • the blockchain referred to in this example is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of the information (anti-counterfeiting) and generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
  • the device realizes the expansion of image samples of input pictures based on the special effects of partial shadows, which reduces the difficulty of obtaining ID card image samples, and the expanded image samples are close to samples taken in real scenes, which solves the problem of small samples.
  • the above-mentioned image sample generating device based on partial shadow special effects can be implemented in the form of a computer program, and the computer program can be run on a computer device as shown in FIG. 4.
  • FIG. 4 is a schematic block diagram of a computer device according to an embodiment of the present application.
  • the computer device 500 is a server, and the server may be an independent server or a server cluster composed of multiple servers.
  • the computer device 500 includes a processor 502, a memory, and a network interface 505 connected through a system bus 501, where the memory may include a non-volatile storage medium 503 and an internal memory 504.
  • the non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032.
  • the processor 502 can execute an image sample generation method based on partial shadow effects.
  • the processor 502 is used to provide calculation and control capabilities, and support the operation of the entire computer device 500.
  • the internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503.
  • the processor 502 can make the processor 502 execute an image sample generation method based on partial shadow effects.
  • the network interface 505 is used for network communication, such as providing data information transmission.
  • the structure shown in FIG. 4 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied.
  • the specific computer device 500 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
  • the processor 502 is configured to run a computer program 5032 stored in a memory to implement the method for generating image samples based on partial shadow special effects disclosed in the embodiments of the present application.
  • the embodiment of the computer device shown in FIG. 4 does not constitute a limitation on the specific configuration of the computer device.
  • the computer device may include more or less components than those shown in the figure. Or some parts are combined, or different parts are arranged.
  • the computer device may only include a memory and a processor. In such embodiments, the structures and functions of the memory and the processor are the same as those of the embodiment shown in FIG. 4, and will not be repeated here.
  • the processor 502 may be a central processing unit (Central Processing Unit, CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSPs), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
  • a computer-readable storage medium In another embodiment of the present application, a computer-readable storage medium is provided.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the computer-readable storage medium stores a computer program, where the computer program is executed by a processor to realize the method for generating image samples based on partial shadow special effects disclosed in the embodiments of the present application.
  • the disclosed equipment, device, and method may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods, or the units with the same function may be combined into one. Units, for example, multiple units or components can be combined or integrated into another system, or some features can be omitted or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may also be electrical, mechanical or other forms of connection.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments of the present application.
  • the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium.
  • the technical solution of this application is essentially or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium. It includes several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), magnetic disk or optical disk and other media that can store program codes.

Abstract

Provided are an image sample generation method and apparatus based on a local shadow special effect, a computer device, and a storage medium. The present invention relates to artificial intelligence technology. The method comprises: calling a contrast and brightness adjustment algorithm, and carrying out contrast and brightness adjustment on an input image to obtain a corresponding dark image and a corresponding bright image; acquiring an original image size of the input image, and according to the original image size, carrying out initialization to obtain an initial fuzzy forward dodging image, and carrying out fuzzy forward dodging on the initial fuzzy forward dodging image to obtain a current fuzzy forward dodging image (S130); carrying out Gaussian blurring on the current fuzzy forward dodging image to obtain a Gaussian-blurred image (S140); and according to the dark image and the bright image corresponding to the input image and the Gaussian-blurred image, carrying out synthesis to obtain an image sample corresponding to the input image (S150). The method achieves image sample extension based on a local shadow special effect for an input image, and reduces the acquisition difficulty for acquiring an identity card image sample, and the extended image sample is close to a sample photographed in a real scene, and the problem of small samples is solved.

Description

基于局部阴影特效的图像样本生成方法及装置Image sample generation method and device based on local shadow special effect
本申请要求于2020年7月31日提交中国专利局、申请号为202010763065.7,申请名称为“基于局部阴影特效的图像样本生成方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on July 31, 2020, the application number is 202010763065.7, and the application title is "Image sample generation method and device based on partial shadow special effects", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请涉及人工智能的图像处理技术领域,尤其涉及一种基于局部阴影特效的图像样本生成方法、装置、计算机设备及存储介质。This application relates to the field of artificial intelligence image processing technology, and in particular to a method, device, computer equipment, and storage medium for generating image samples based on partial shadow special effects.
背景技术Background technique
在身份证鉴伪项目中,发明人意识到身份证的样本采集非常困难,这主要是由于身份证卡片是涉及到个人隐私的物件,出于安全和隐私等因素,收集难度非常大。故在做身份证相关的算法研究的时候,极度缺少身份证图片样本,造成训练身份证识别模型的样本数据的获取难度增大。In the ID verification project, the inventor realized that it is very difficult to collect samples of ID cards. This is mainly because ID cards are objects related to personal privacy. Due to factors such as security and privacy, the collection is very difficult. Therefore, when doing ID card-related algorithm research, there is an extreme lack of ID card image samples, which makes it more difficult to obtain sample data for training ID card recognition models.
发明内容Summary of the invention
本申请实施例提供了一种基于局部阴影特效的图像样本生成方法、装置、计算机设备及存储介质,旨在解决现有技术中训练身份证识别模型的过程中极度缺少身份证图片样本,造成训练身份证识别模型的样本数据的获取难度增大的问题。The embodiment of the application provides an image sample generation method, device, computer equipment, and storage medium based on partial shadow special effects, aiming to solve the extreme lack of ID card image samples in the process of training ID card recognition models in the prior art, resulting in training The problem of increasing difficulty in obtaining sample data of ID card recognition model.
第一方面,本申请实施例提供了一种基于局部阴影特效的图像样本生成方法,其包括:In the first aspect, an embodiment of the present application provides an image sample generation method based on partial shadow special effects, which includes:
接收并保存输入图片;Receive and save the input picture;
调用预先存储的对比度亮度调节算法,将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片;Call a pre-stored contrast and brightness adjustment algorithm, adjust the contrast and brightness of the input picture, to obtain a dark picture and a bright picture corresponding to the input picture;
获取所述输入图片的原图尺寸,根据所述原图尺寸初始化得到一个初始模糊正向匀光图片,对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片;Obtain the original image size of the input picture, initialize an initial blurred forward uniform light image according to the original image size, and perform blur forward uniform light on the initial blurred forward uniform light image to obtain the current blurred forward uniform light Light picture
将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;以及Performing Gaussian blurring on the current blurred forward uniform light image to obtain a Gaussian blurred image; and
根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本。Synthesize according to the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture.
第二方面,本申请实施例提供了一种基于局部阴影特效的图像样本生成装置,其包括:In the second aspect, an embodiment of the present application provides an image sample generating device based on partial shadow special effects, which includes:
图片接收单元,用于接收并保存输入图片;The picture receiving unit is used to receive and save the input picture;
对比度亮度调节单元,用于调用预先存储的对比度亮度调节算法,将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片;The contrast and brightness adjustment unit is used to call a pre-stored contrast and brightness adjustment algorithm to adjust the contrast and brightness of the input picture to obtain dark pictures and bright pictures corresponding to the input picture;
模糊正向匀光图片获取单元,用于获取所述输入图片的原图尺寸,根据所述原图尺寸初始化得到一个初始模糊正向匀光图片,对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片;The fuzzy forward uniform light image acquisition unit is configured to acquire the original image size of the input image, initialize an initial fuzzy forward uniform light image according to the original image size, and blur the initial blurred forward uniform light image Forward homogenization, get the current fuzzy positive homogenization picture;
高斯模糊单元,用于将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;以及The Gaussian blur unit is used to perform Gaussian blurring on the current blurred forward uniform light picture to obtain a Gaussian blurred picture; and
图片合成单元,用于根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本。The picture synthesis unit is configured to synthesize the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture.
第三方面,本申请实施例又提供了一种计算机设备,其包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述第一方面所述的基于局部阴影特效的图像样本生成方法。In a third aspect, an embodiment of the present application provides a computer device, which includes a memory, a processor, and a computer program stored on the memory and running on the processor, and the processor executes the computer The program implements the image sample generation method based on the partial shadow special effect described in the first aspect.
第四方面,本申请实施例还提供了一种计算机可读存储介质,其中所述计算机可读存储介质存储有计算机程序,所述计算机程序当被处理器执行时使所述处理器执行上述第一方面所述的基于局部阴影特效的图像样本生成方法。In a fourth aspect, an embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the above-mentioned first On the one hand, the method for generating image samples based on local shadow special effects.
本申请实施例提供了一种基于局部阴影特效的图像样本生成方法、装置、计算机设备及存储介质,包括接收并保存输入图片;调用预先存储的对比度亮度调节算法,将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片;获取所述输入图片的原图尺寸,根据所述原图尺寸初始化得到一个初始模糊正向匀光图片,对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片;将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;以及根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本。实现了对输入图片基于局部阴影特效进行图像样本的扩充,降低了获取身份证图片样本的获取难度,而且所扩充的图像样本接近真实场景拍摄的样本,解决了小样本问题。The embodiment of the application provides an image sample generation method, device, computer equipment, and storage medium based on partial shadow special effects, including receiving and saving an input picture; calling a pre-stored contrast brightness adjustment algorithm, and performing contrast brightness on the input picture Adjust to obtain the dark picture and the bright picture corresponding to the input picture; obtain the original image size of the input picture, initialize according to the original image size to obtain an initial blur forward uniform light picture, and compare the initial blur forward Perform a fuzzy forward homogenization picture to obtain a current blurred forward homogenization picture; perform Gaussian blurring on the current fuzzy forward homogenization picture to obtain a Gaussian blurred picture; and according to the dark picture and the corresponding dark picture of the input picture The bright picture and the Gaussian blurred picture are synthesized to obtain an image sample corresponding to the input picture. It realizes the expansion of the image samples of the input pictures based on the special effects of partial shadows, which reduces the difficulty of obtaining ID card image samples, and the expanded image samples are close to the samples taken in the real scene, which solves the problem of small samples.
附图说明Description of the drawings
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the technical solutions of the embodiments of the present application more clearly, the following will briefly introduce the drawings used in the description of the embodiments. Obviously, the drawings in the following description are some embodiments of the present application. Ordinary technicians can obtain other drawings based on these drawings without creative work.
图1为本申请实施例提供的基于局部阴影特效的图像样本生成方法的应用场景示意图;FIG. 1 is a schematic diagram of an application scenario of an image sample generation method based on partial shadow effects provided by an embodiment of the application;
图2为本申请实施例提供的基于局部阴影特效的图像样本生成方法的流程示意图;2 is a schematic flowchart of an image sample generation method based on partial shadow effects provided by an embodiment of the application;
图3为本申请实施例提供的基于局部阴影特效的图像样本生成装置的示意性框图;FIG. 3 is a schematic block diagram of an image sample generating apparatus based on partial shadow special effects provided by an embodiment of the application;
图4为本申请实施例提供的计算机设备的示意性框图。Fig. 4 is a schematic block diagram of a computer device provided by an embodiment of the application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be described clearly and completely in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of them. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of this application.
应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。It should be understood that when used in this specification and appended claims, the terms "including" and "including" indicate the existence of the described features, wholes, steps, operations, elements and/or components, but do not exclude one or The existence or addition of multiple other features, wholes, steps, operations, elements, components, and/or collections thereof.
还应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。It should also be understood that the terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in the specification of this application and the appended claims, unless the context clearly indicates other circumstances, the singular forms "a", "an" and "the" are intended to include plural forms.
还应当进一步理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。It should be further understood that the term "and/or" used in the specification and appended claims of this application refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations .
请参阅图1和图2,图1为本申请实施例提供的基于局部阴影特效的图像样本生成方法的应用场景示意图;图2为本申请实施例提供的基于局部阴影特效的图像样本生成方法的流程示意图,该基于局部阴影特效的图像样本生成方法应用于服务器中,该方法通过安装于服务器中的应用软件进行执行。Please refer to FIGS. 1 and 2. FIG. 1 is a schematic diagram of an application scenario of an image sample generation method based on partial shadow special effects provided by an embodiment of this application; FIG. 2 is a schematic diagram of an image sample generation method based on partial shadow special effects provided by an embodiment of this application A schematic flow chart. The method for generating image samples based on partial shadow special effects is applied to a server, and the method is executed by application software installed in the server.
如图2所示,该方法包括步骤S110~S150。As shown in Figure 2, the method includes steps S110 to S150.
S110、接收并保存输入图片。S110. Receive and save the input picture.
在本实施例中,为了扩充包括较少身份证图片张数的图片集中的身份证图片样本,此时可以先将包括一张或多张身份证图片的输入图片由用户端发送至服务器。具体实施时,为了便于理解技术方案,以基于单张身份证图片(也就是上述的输入图片)来生成另一图像样本为例来说明。显然,基于单张身份证图片进行一次基于局部阴影特效的图像样本生成一张图像样本,那么基于单张身份证图片进行重复多次基于局部阴影特效的图像样本生成多张图像样本。通过这一方式可以有效扩充身份证图片样本数量,解决了训练身份证识别模型的过程中极度缺少身份证图片样本的问题。In this embodiment, in order to expand the ID card picture sample in the picture set that includes a small number of ID card pictures, at this time, the input picture including one or more ID card pictures may be sent from the user end to the server. During specific implementation, in order to facilitate the understanding of the technical solution, an example of generating another image sample based on a single ID card picture (that is, the aforementioned input picture) is taken as an example. Obviously, one image sample is generated based on a single ID card image based on an image sample based on the local shadow special effect, and then multiple image samples are generated based on a single ID card image and repeated multiple times based on the image sample based on the local shadow special effect. In this way, the number of ID card image samples can be effectively expanded, and the problem of the extreme lack of ID card image samples in the process of training the ID card recognition model is solved.
S120、调用预先存储的对比度亮度调节算法,将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片。S120: Invoke a pre-stored contrast and brightness adjustment algorithm, adjust the contrast and brightness of the input picture, to obtain a dark picture and a bright picture corresponding to the input picture.
在本实施例中,当服务器获取了一张输入图片后,此时可以调用本地存储的对比度亮度调节算法,将所述输入图片进行调暗处理得到暗图片,并将所述输入图片进行调亮处理得到亮图片。此时获取的暗图片和亮图片是为了与后续的高斯模糊图片进行叠加,从而生成模拟输入图片效果较佳的图像样本。In this embodiment, after the server obtains an input picture, the locally stored contrast and brightness adjustment algorithm can be called at this time, the input picture is darkened to obtain a dark picture, and the input picture is brightened Process to get a bright picture. The dark picture and the light picture obtained at this time are to be superimposed with the subsequent Gaussian blurred picture, so as to generate an image sample with a better simulation input picture effect.
在一实施例中,所述对比度亮度调节算法为:In an embodiment, the contrast brightness adjustment algorithm is:
y ij=[x ij-127.5*(1-B)]*k+127.5*(1+B); y ij =[x ij -127.5*(1-B)]*k+127.5*(1+B);
其中,x ij表示所述输入图片中第i行第j列像素点的像素值;y ij表示对比度亮度调节后中第i行第j列像素点的像素值;B为亮度调节参数,且B的取值范围是[-1,1];k为对比度调节参数,且k=tan((45+44*c)/180*π),c的取值范围是[-1,1]。 Where x ij represents the pixel value of the pixel in the i-th row and j-th column of the input image; y ij represents the pixel value of the pixel in the i-th row and j-th column after the contrast brightness adjustment; B is the brightness adjustment parameter, and B The value range of is [-1,1]; k is the contrast adjustment parameter, and k=tan((45+44*c)/180*π), and the value range of c is [-1,1].
在本实施例中,亮度调节参数B的取值范围是[-1,1],其作用是对图像进行亮度调节,当B取[-1,0]之间的值时可将输入图片调暗,当B取[0,1]之间的值时可将输入图片调亮。对比度调节参数k的取值范围是[-1,1],其作用是对图像进行对比度调节,arctan(k)的取值范围是[1,89]。其中,当B=0时y ij=(x ij-127.5)*k+127.5,这时对比度亮度调节算法只调节对比度;当c=0时,k=1,y ij=x ij+255*B,这时对比度亮度调节算法只调节亮度。 In this embodiment, the value range of the brightness adjustment parameter B is [-1,1], and its function is to adjust the brightness of the image. When B takes a value between [-1,0], the input image can be adjusted. Dark, when B takes a value between [0,1], the input picture can be brightened. The value range of the contrast adjustment parameter k is [-1,1], and its function is to adjust the contrast of the image, and the value range of arctan(k) is [1,89]. Among them, when B=0, y ij =(x ij -127.5)*k+127.5, then the contrast brightness adjustment algorithm only adjusts the contrast; when c=0, k=1, y ij =x ij +255*B At this time, the contrast and brightness adjustment algorithm only adjusts the brightness.
在一实施例中,步骤S120包括:In an embodiment, step S120 includes:
获取所述输入图片中各像素点的像素值;Obtaining the pixel value of each pixel in the input picture;
调用所述对比度亮度调节算法,将所述对比度亮度调节算法中的亮度调节参数取值范围设置为[-1,0],以将各像素点的像素值进行亮度对比度调节,得到各像素点对应的第一调节后像素值,以得到暗图片;Call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [-1, 0] to adjust the brightness and contrast of the pixel value of each pixel to obtain the corresponding pixel The first adjusted pixel value of to obtain a dark picture;
调用所述对比度亮度调节算法,将所述对比度亮度调节算法中的亮度调节参数取值范围设置为[0,1],以将各像素点的像素值进行亮度对比度调节,得到各像素点对应的第二调节后像素值,以得到亮图片。Call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [0, 1] to adjust the brightness and contrast of the pixel value of each pixel to obtain the corresponding pixel value The second adjusted pixel value to obtain a bright picture.
在本实施例中,根据所述对比度亮度调节算法进行图片的调节时,可以获得明暗程度不同的2幅图片。设置获取暗图片时B的取值为[-1,0],获取亮图片时B的取值为[0,1]。而且在上述过程中,c在取值范围[-1,1]中任意取一个值即可。通过所述对比度亮度调节算法对输入图片进行对比度亮度调节,可以获得图片质量较佳的亮图片和暗图片以进行后续图片加工处理。In this embodiment, when the picture is adjusted according to the contrast and brightness adjustment algorithm, two pictures with different brightness levels can be obtained. Set the value of B to be [-1,0] when obtaining dark pictures, and to [0,1] when obtaining bright pictures. And in the above process, c can take any value in the value range [-1,1]. By adjusting the contrast and brightness of the input picture through the contrast and brightness adjustment algorithm, a bright picture and a dark picture with better picture quality can be obtained for subsequent picture processing.
S130、获取所述输入图片的原图尺寸,根据所述原图尺寸初始化得到一个初始模糊正向匀光图片,对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片。S130. Obtain the original image size of the input image, obtain an initial fuzzy forward uniform light image by initializing the original image size, and perform blur forward uniform light on the initial blurred forward uniform light image to obtain the current blur positive image. To the uniform light picture.
在本实施例中,由于亮图片或是暗图片中可能会出现亮度分布不均匀的现象,严重影响图片质量,增加了后续图像处理难度。此时为了消除图片亮度分布不均匀的现象,可以对图像进行匀光处理。本申请中,可以采用MASK匀光算法对图片进行处理,增强高频信息,抑制低频信息,从而增强图片的细节反差,抑制图片的异常亮度变化,从而实现匀光的目的。In this embodiment, the uneven brightness distribution may occur in the bright picture or the dark picture, which seriously affects the picture quality and increases the difficulty of subsequent image processing. At this time, in order to eliminate the uneven brightness distribution of the picture, the image can be homogenized. In this application, the MASK uniform light algorithm can be used to process the picture to enhance high-frequency information and suppress low-frequency information, thereby enhancing the detail contrast of the picture and suppressing abnormal brightness changes of the picture, so as to achieve the purpose of uniform light.
此时采用MASK匀光算法对图片进行处理时,不是直接对亮图片或者暗图片进行处理,而是先初始生成一个与所述输入图片具有相同图片尺寸的初始模糊正向匀光图片(也可以理解为初始模糊正向匀光图片与输入图片完全相同),然后对其进行MASK匀光得到当前模糊正向匀光图片。所得到的当前模糊正向匀光图片进一步进行处理后即可参与处理暗图片或亮图片,从而增强所得到样本图片的细节反差,抑制样本图片的异常亮度变化。At this time, when the MASK uniform light algorithm is used to process the picture, instead of directly processing the bright picture or the dark picture, an initial fuzzy forward uniform light picture with the same picture size as the input picture is initially generated (it can also be It is understood that the initial blurred forward uniform light picture is exactly the same as the input picture), and then the MASK uniform light is performed on it to obtain the current blurred forward uniform light picture. The obtained current fuzzy forward homogenized image can participate in the processing of dark or bright images after further processing, thereby enhancing the detail contrast of the obtained sample image and suppressing abnormal brightness changes of the sample image.
在一实施例中,作为步骤S130的第一具体实施,所述步骤S130包括:In an embodiment, as a first specific implementation of step S130, step S130 includes:
调用预先存储的平面模糊正向匀光算法,将所述初始模糊正向匀光图片通过所述平面模糊正向匀光算法进行平面模糊正向匀光,得到当前模糊正向匀光图片;其中,所述平面模糊正向匀光算法中平面公式为Y=a1X+b1,a1和b1为随机值;若所述初始模糊正向匀光图片中有像素点位于所述Y=a1X+b1的平面内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于所述Y=a1X+b1的平面外则将对应的像素点的像素值设置为0。Invoking the pre-stored flat fuzzy forward uniform light algorithm, and the initial fuzzy forward uniform light image is subjected to plane fuzzy forward uniform light through the plane fuzzy forward uniform light algorithm to obtain the current blurred forward uniform light image; where , The plane formula in the plane blur forward uniform light algorithm is Y=a1X+b1, and a1 and b1 are random values; if there are pixels in the initial blur forward uniform light picture that are located in the Y=a1X+b1 In the plane, the pixel value of the corresponding pixel is set to 255; if there is a pixel in the initial blurred forward uniform light image that is outside the plane of Y=a1X+b1, then the pixel value of the corresponding pixel is set Is 0.
在本实施例中,在初始化得到一张当前模糊正向匀光图片,可以通过平面MASK算法(即 平面模糊正向匀光算法)对所述当前模糊正向匀光图片进行平面MASK,得到当前模糊正向匀光图片。In this embodiment, a current fuzzy forward uniform light image is obtained during initialization, and the current fuzzy forward uniform light image can be subjected to planar MASK using the planar MASK algorithm (that is, the planar fuzzy forward uniform light algorithm) to obtain the current Blur the picture with the forward uniform light.
通过对当前模糊正向匀光图片进行平面MASK,就是将当前模糊正向匀光图片中的各像素点进行如下判断:By performing planar mask on the current blurred forward uniform light image, each pixel in the current blurred forward uniform light image is judged as follows:
若所述初始模糊正向匀光图片中有像素点位于Y=a1X+b1的平面内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于Y=a1X+b1的平面外则将对应的像素点的像素值设置为0;其中,平面模糊正向匀光算法中平面公式为Y=a1X+b1,a1和b1为随机值。通过上述平面MASK处理,增强了初始模糊正向匀光图片中的高频信息,抑制其中低频信息,抑制初始模糊正向匀光图片的异常亮度变化。If there are pixels in the initial blurred forward uniform light picture that are located in the plane of Y=a1X+b1, the pixel value of the corresponding pixel is set to 255; if there are pixels in the initial blurred forward uniform light picture Outside the plane of Y=a1X+b1, the pixel value of the corresponding pixel is set to 0; the plane formula in the plane blur forward homogenization algorithm is Y=a1X+b1, and a1 and b1 are random values. Through the above-mentioned planar mask processing, the high frequency information in the initial blurred forward uniform light image is enhanced, the low frequency information therein is suppressed, and the abnormal brightness change of the initial blurred forward uniform light image is suppressed.
在一实施例中,作为步骤S130的第二具体实施,所述步骤S130包括:In an embodiment, as a second specific implementation of step S130, the step S130 includes:
调用预先存储的曲面模糊正向匀光算法,将所述初始模糊正向匀光图片通过所述曲面模糊正向匀光算法进行平面模糊正向匀光,得到当前模糊正向匀光图片;其中,所述曲面模糊正向匀光算法中平面公式为a*x 2+b*y 2+c*x*y+d*x+e*y=f,a、b、c、d、e为随机值;若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围外则将对应的像素点的像素值设置为0。 Invoking the pre-stored curved surface fuzzy forward uniform light algorithm, the initial fuzzy forward uniform light image is subjected to planar fuzzy forward uniform light through the curved surface fuzzy forward uniform light algorithm, to obtain the current fuzzy forward uniform light image; where , The plane formula in the curved surface fuzzy forward homogenization algorithm is a*x 2 +b*y 2 +c*x*y+d*x+e*y=f, a, b, c, d, e are Random value; if there are pixels in the initial blurred forward homogenized image that are located in the plane range of a*x 2 +b*y 2 +c*x*y+d*x+e*y=f, it will correspond The pixel value of the pixel point of is set to 255; if there is a pixel point in the initial blurry forward homogenization picture located at a*x 2 +b*y 2 +c*x*y+d*x+e*y=f Set the pixel value of the corresponding pixel to 0 outside the plane range.
在本实施例中,在初始化得到一张当前模糊正向匀光图片,还可以通过曲面MASK算法(即曲面模糊正向匀光算法)对所述当前模糊正向匀光图片进行曲面MASK,得到当前模糊正向匀光图片。In this embodiment, a current fuzzy forward uniform light image is obtained during initialization, and the current fuzzy forward uniform light image can also be surface-masked through the curved surface MASK algorithm (that is, the curved surface fuzzy forward uniform light algorithm), to obtain The current picture is blurred forward and even light.
通过对当前模糊正向匀光图片进行曲面MASK,就是将当前模糊正向匀光图片中的各像素点进行如下判断:By performing surface MASK on the current blurred forward uniform light image, each pixel in the current blurred forward uniform light image is judged as follows:
若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围外则将对应的像素点的像素值设置为0;其中,曲面模糊正向匀光算法中曲面公式为a*x 2+b*y 2+c*x*y+d*x+e*y=f,a、b、c、d、e为随机值。通过上述曲面MASK处理,也实现了增强初始模糊正向匀光图片中的高频信息,抑制其中低频信息,抑制初始模糊正向匀光图片的异常亮度变化。也即在具体实施时,可以选择平面MASK算法或曲面MASK算法中的其中任意一种对所述初始模糊正向匀光图片进行匀光处理。 If there are pixels in the initial blurred forward homogenization image that are located in the plane range of a*x 2 + b*y 2 + c*x*y+d*x+e*y=f, then the corresponding pixel points The pixel value of is set to 255; if there is a pixel in the initial blurred forward homogenization picture that is located in the plane range of a*x 2 +b*y 2 +c*x*y+d*x+e*y=f Outside, set the pixel value of the corresponding pixel to 0; among them, the surface formula in the surface fuzzy forward uniform light algorithm is a*x 2 +b*y 2 +c*x*y+d*x+e*y =f, a, b, c, d, e are random values. Through the above-mentioned curved surface MASK processing, the high frequency information in the initial blurred forward uniform light image is also enhanced, the low frequency information therein is suppressed, and the abnormal brightness change of the initial blurred forward uniform light image is suppressed. That is, in specific implementation, any one of the planar MASK algorithm or the curved surface MASK algorithm can be selected to perform the homogenization process on the initial fuzzy forward homogenization image.
S140、将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片。S140: Perform Gaussian blurring on the current blurred forward uniform light image to obtain a Gaussian blurred image.
在本实施例中,当得到了所述当前模糊正向匀光图片后,为了减少图像噪声以及降低细节层次。图像的高斯模糊过程就是图像与正态分布做卷积。由于正态分布又叫作高斯分布,故此项技术称为高斯模糊。In this embodiment, after the current blurred forward uniform light image is obtained, in order to reduce image noise and reduce the level of detail. The Gaussian blur process of the image is the convolution of the image and the normal distribution. Since the normal distribution is also called Gaussian distribution, this technique is called Gaussian blur.
在一实施例中,步骤S140包括:In an embodiment, step S140 includes:
采用二维高斯函数
Figure PCTCN2020111946-appb-000001
且滤波核尺寸为[10,100]中的随机数将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;其中,(x,y)表示所述当前模糊正向匀光图片中的像素点坐标,σ是x的方差。
Use a two-dimensional Gaussian function
Figure PCTCN2020111946-appb-000001
And the filter kernel size is a random number in [10,100] to perform Gaussian blurring on the current blurred forward uniform light picture to obtain a Gaussian blurred picture; where (x, y) represents the current blurred forward uniform light picture The pixel coordinates of, σ is the variance of x.
高斯模糊在二维空间定义为
Figure PCTCN2020111946-appb-000002
此时通过二维空间的高斯模糊对所述当前模糊正向匀光图片进行高斯模糊后,即可得到减少图像噪声以及降低细节层次后的高斯模糊后图片。
Gaussian blur is defined in two-dimensional space as
Figure PCTCN2020111946-appb-000002
At this time, after Gaussian blurring is performed on the current blurred forward homogenized image through Gaussian blurring in the two-dimensional space, a Gaussian blurred image with reduced image noise and reduced level of detail can be obtained.
S150、根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本。S150. Synthesize according to the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture.
在本实施例中,在前面的步骤中得到了所述输入图片对应的暗图片和亮图片及所述高斯模糊后图片,此时可以分别将亮图片经过高斯模糊后图片处理,以及将暗图片经过高斯模糊后图片处理后叠加,即可得到与所述输入图片对应的图像样本,通过这一处理,所生成的图 片样本逼真度高。In this embodiment, the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture are obtained in the previous steps. At this time, the bright picture can be processed by Gaussian blurred picture, and the dark picture After Gaussian blurring, the pictures are processed and then superimposed to obtain image samples corresponding to the input pictures. Through this processing, the generated picture samples have high fidelity.
在一实施例中,步骤S150包括:In an embodiment, step S150 includes:
将所述高斯模糊后图片进行归一化处理,得到归一化图片;Performing normalization processing on the Gaussian blurred picture to obtain a normalized picture;
获取所述归一化图片对应的像素矩阵以作为第一矩阵,将单位矩阵减去所述第一矩阵得到第二矩阵;Acquiring a pixel matrix corresponding to the normalized picture as a first matrix, and subtracting the first matrix from the identity matrix to obtain a second matrix;
将所述亮图片对应的亮图片像素矩阵与所述第一矩阵相乘得到第一最终像素矩阵,将所述暗图片对应的像素矩阵与所处第二矩阵相乘得到第二最终像素矩阵;Multiplying the pixel matrix of the bright picture corresponding to the bright picture by the first matrix to obtain a first final pixel matrix, and multiplying the pixel matrix corresponding to the dark picture by the second matrix where it is located to obtain a second final pixel matrix;
将所述第一最终像素矩阵与所述第二最终像素矩阵相加求和,得到与所述输入图片对应的图像样本。The first final pixel matrix and the second final pixel matrix are added and summed to obtain an image sample corresponding to the input picture.
在本实施例中,对所述高斯模糊后图片进行归一化处理,是为了将其处理为权重矩阵,以分别计算亮图片和暗图片在叠加时分别对应的权重。具体实施时,将第一矩阵作为亮图片对应的权重,将第二矩阵作为暗图片对应的权重,之后将第一最终像素矩阵与第二最终像素矩阵相加求和,得到与所述输入图片对应的图像样本,上述通过基于局部阴影特效得到的图片的效果非常接近真实场景拍摄的样本,甚至可以模拟出在真实场景中很难采集的样本。In this embodiment, the purpose of normalizing the Gaussian blurred picture is to process it into a weight matrix, so as to calculate the respective weights of the bright pictures and the dark pictures when they are superimposed. In specific implementation, the first matrix is taken as the weight corresponding to the bright picture, and the second matrix is taken as the weight corresponding to the dark picture, and then the first final pixel matrix and the second final pixel matrix are added and summed to obtain the input picture Corresponding image samples, the effects of the above-mentioned pictures obtained by special effects based on partial shadows are very close to samples taken in real scenes, and can even simulate samples that are difficult to collect in real scenes.
在一实施例中,步骤S150之后还包括:In an embodiment, after step S150, the method further includes:
将所述输入图片与所述图像样本均发送至用户端。Both the input picture and the image sample are sent to the user terminal.
在本实施例中,当在服务器中根据输入图片扩展得到的图像样本后,可以将输入图片和图像样本发送至用户端,用户端中可以根据扩充后的图像样本进行身份证识别模型的训练。In this embodiment, after the image sample obtained by expanding the input picture in the server, the input picture and the image sample can be sent to the user terminal, and the user terminal can train the ID card recognition model based on the expanded image sample.
具体实施时,在所述将所述输入图片与所述图像样本均发送至用户端的步骤之后还包括:During specific implementation, after the step of sending both the input picture and the image sample to the user terminal, the method further includes:
接收并存储用户端根据包括输入图片和图像样本的图片训练集训练得到的身份证识别模型。Receive and store the ID card recognition model trained by the user terminal according to the picture training set including the input picture and the image sample.
在本实施例中,当在用户端中根据包括输入图片和图像样本的图片训练集对训练待训练身份证识别模型(如卷积神经网络)进行训练,所得到的身份证识别模型发送至服务器进行存储。In this embodiment, when the ID card recognition model (such as convolutional neural network) to be trained is trained in the user terminal according to the image training set including the input image and image samples, the obtained ID card recognition model is sent to the server Store it.
在一实施例中,所述接收并存储用户端根据包括输入图片和图像样本的图片训练集训练得到的身份证识别模型的步骤之后,还包括:In an embodiment, after the step of receiving and storing the ID card recognition model trained by the user terminal according to the picture training set including the input picture and the image sample, the method further includes:
将所述身份证识别模型对应的参数集上传至区块链网络。Upload the parameter set corresponding to the ID card recognition model to the blockchain network.
在本实施例中,服务器可以作为一个区块链节点设备,将所述身份证识别模型对应的参数集上传至区块链网络,充分利用区块链数据不可篡改的特性,实现身份证识别模型对应的参数集的数据固化存储。服务器从区块链网络重新下载获取了所述身份证识别模型对应的参数集后,可以根据所述身份证识别模型对应的参数集重新还原身份证识别模型。In this embodiment, the server can be used as a blockchain node device to upload the parameter set corresponding to the ID card identification model to the blockchain network, making full use of the non-tamperable characteristics of blockchain data to realize the ID card identification model The data of the corresponding parameter set is solidified and stored. After the server re-downloads and obtains the parameter set corresponding to the ID card recognition model from the blockchain network, it can restore the ID card recognition model again according to the parameter set corresponding to the ID card recognition model.
其中,基于所述身份证识别模型对应的参数集得到对应的摘要信息,具体来说,摘要信息由所述身份证识别模型对应的参数集进行散列处理得到,比如利用sha256算法处理得到。将摘要信息上传至区块链可保证其安全性和对用户的公正透明性。服务器可以从区块链中下载得该摘要信息,以便查证所述身份证识别模型对应的参数集是否被篡改。本示例所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。Wherein, the corresponding summary information is obtained based on the parameter set corresponding to the ID card recognition model. Specifically, the summary information is obtained by hashing the parameter set corresponding to the ID card recognition model, for example, obtained by using the sha256 algorithm. Uploading summary information to the blockchain can ensure its security and fairness and transparency to users. The server can download the summary information from the blockchain to verify whether the parameter set corresponding to the ID card recognition model has been tampered with. The blockchain referred to in this example is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain, essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of the information (anti-counterfeiting) and generation of the next block. The blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
该方法实现了对输入图片基于局部阴影特效进行图像样本的扩充,降低了获取身份证图片样本的获取难度,而且所扩充的图像样本接近真实场景拍摄的样本,解决了小样本问题。This method realizes the expansion of image samples based on local shadow effects for input pictures, reduces the difficulty of obtaining ID card image samples, and the expanded image samples are close to samples taken in real scenes, which solves the problem of small samples.
本申请实施例还提供一种基于局部阴影特效的图像样本生成装置,该基于局部阴影特效的图像样本生成装置用于执行前述基于局部阴影特效的图像样本生成方法的任一实施例。具体地,请参阅图3,图3是本申请实施例提供的基于局部阴影特效的图像样本生成装置的示意性框图。该基于局部阴影特效的图像样本生成装置100可以配置于服务器中。An embodiment of the present application also provides an image sample generating device based on a partial shadow special effect, which is used to execute any embodiment of the aforementioned image sample generating method based on a partial shadow special effect. Specifically, please refer to FIG. 3, which is a schematic block diagram of an image sample generating apparatus based on partial shadow special effects according to an embodiment of the present application. The device 100 for generating image samples based on partial shadow special effects can be configured in a server.
如图3所示,基于局部阴影特效的图像样本生成装置100包括:图片接收单元110、对 比度亮度调节单元120、模糊正向匀光图片获取单元130、高斯模糊单元140、图片合成单元150。As shown in FIG. 3, the image sample generating device 100 based on the partial shadow special effect includes: a picture receiving unit 110, a contrast brightness adjustment unit 120, a blur forward uniform light picture acquisition unit 130, a Gaussian blur unit 140, and a picture synthesis unit 150.
图片接收单元110,接收并保存输入图片。The picture receiving unit 110 receives and saves the input picture.
在本实施例中,为了扩充包括较少身份证图片张数的图片集中的身份证图片样本,此时可以先将包括一张或多张身份证图片的输入图片由用户端发送至服务器。具体实施时,为了便于理解技术方案,以基于单张身份证图片(也就是上述的输入图片)来生成另一图像样本为例来说明。显然,基于单张身份证图片进行一次基于局部阴影特效的图像样本生成一张图像样本,那么基于单张身份证图片进行重复多次基于局部阴影特效的图像样本生成多张图像样本。通过这一方式可以有效扩充身份证图片样本数量,解决了训练身份证识别模型的过程中极度缺少身份证图片样本的问题。In this embodiment, in order to expand the ID card picture sample in the picture set that includes a small number of ID card pictures, at this time, the input picture including one or more ID card pictures may be sent from the user end to the server. During specific implementation, in order to facilitate the understanding of the technical solution, an example of generating another image sample based on a single ID card picture (that is, the aforementioned input picture) is taken as an example. Obviously, one image sample is generated based on a single ID card image based on an image sample based on the local shadow special effect, and then multiple image samples are generated based on a single ID card image and repeated multiple times based on the image sample based on the local shadow special effect. In this way, the number of ID card image samples can be effectively expanded, and the problem of the extreme lack of ID card image samples in the process of training the ID card recognition model is solved.
对比度亮度调节单元120,用于调用预先存储的对比度亮度调节算法,将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片。The contrast and brightness adjustment unit 120 is configured to call a pre-stored contrast and brightness adjustment algorithm to adjust the contrast and brightness of the input picture to obtain dark pictures and bright pictures corresponding to the input picture.
在本实施例中,当服务器获取了一张输入图片后,此时可以调用本地存储的对比度亮度调节算法,将所述输入图片进行调暗处理得到暗图片,并将所述输入图片进行调亮处理得到亮图片。此时获取的暗图片和亮图片是为了与后续的高斯模糊图片进行叠加,从而生成模拟输入图片效果较佳的图像样本。In this embodiment, after the server obtains an input picture, the locally stored contrast and brightness adjustment algorithm can be called at this time, the input picture is darkened to obtain a dark picture, and the input picture is brightened Process to get a bright picture. The dark picture and the light picture obtained at this time are to be superimposed with the subsequent Gaussian blurred picture, so as to generate an image sample with a better simulation input picture effect.
在一实施例中,所述对比度亮度调节算法为:In an embodiment, the contrast brightness adjustment algorithm is:
y ij=[x ij-127.5*(1-B)]*k+127.5*(1+B); y ij =[x ij -127.5*(1-B)]*k+127.5*(1+B);
其中,x ij表示所述输入图片中第i行第j列像素点的像素值;y ij表示对比度亮度调节后中第i行第j列像素点的像素值;B为亮度调节参数,且B的取值范围是[-1,1];k为对比度调节参数,且k=tan((45+44*c)/180*π),c的取值范围是[-1,1]。 Where x ij represents the pixel value of the pixel in the i-th row and j-th column of the input picture; y ij represents the pixel value of the pixel in the i-th row and j-th column after the contrast brightness adjustment; B is the brightness adjustment parameter, and B The value range of is [-1,1]; k is the contrast adjustment parameter, and k=tan((45+44*c)/180*π), and the value range of c is [-1,1].
在本实施例中,亮度调节参数B的取值范围是[-1,1],其作用是对图像进行亮度调节,当B取[-1,0]之间的值时可将输入图片调暗,当B取[0,1]之间的值时可将输入图片调亮。对比度调节参数k的取值范围是[-1,1],其作用是对图像进行对比度调节,arctan(k)的取值范围是[1,89]。其中,当B=0时y ij=(x ij-127.5)*k+127.5,这时对比度亮度调节算法只调节对比度;当c=0时,k=1,y ij=x ij+255*B,这时对比度亮度调节算法只调节亮度。 In this embodiment, the value range of the brightness adjustment parameter B is [-1,1], and its function is to adjust the brightness of the image. When B takes a value between [-1,0], the input image can be adjusted. Dark, when B takes a value between [0,1], the input picture can be brightened. The value range of the contrast adjustment parameter k is [-1,1], and its function is to adjust the contrast of the image, and the value range of arctan(k) is [1,89]. Among them, when B=0, y ij =(x ij -127.5)*k+127.5, then the contrast brightness adjustment algorithm only adjusts the contrast; when c=0, k=1, y ij =x ij +255*B At this time, the contrast and brightness adjustment algorithm only adjusts the brightness.
在一实施例中,对比度亮度调节单元120包括:In an embodiment, the contrast and brightness adjustment unit 120 includes:
像素值获取单元,用于获取所述输入图片中各像素点的像素值;A pixel value obtaining unit, configured to obtain the pixel value of each pixel in the input picture;
暗图片获取单元,用于调用所述对比度亮度调节算法,将所述对比度亮度调节算法中的亮度调节参数取值范围设置为[-1,0],以将各像素点的像素值进行亮度对比度调节,得到各像素点对应的第一调节后像素值,以得到暗图片;The dark picture acquisition unit is used to call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [-1, 0], so as to perform brightness contrast on the pixel value of each pixel Adjust to obtain the first adjusted pixel value corresponding to each pixel to obtain a dark picture;
亮图片获取单元,用于调用所述对比度亮度调节算法,将所述对比度亮度调节算法中的亮度调节参数取值范围设置为[0,1],以将各像素点的像素值进行亮度对比度调节,得到各像素点对应的第二调节后像素值,以得到亮图片。The bright picture acquisition unit is used to call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [0, 1] to adjust the brightness and contrast of the pixel value of each pixel , Obtain the second adjusted pixel value corresponding to each pixel point to obtain a bright picture.
在本实施例中,根据所述对比度亮度调节算法进行图片的调节时,可以获得明暗程度不同的2幅图片。设置获取暗图片时B的取值为[-1,0],获取亮图片时B的取值为[0,1]。而且在上述过程中,c在取值范围[-1,1]中任意取一个值即可。通过所述对比度亮度调节算法对输入图片进行对比度亮度调节,可以获得图片质量较佳的亮图片和暗图片以进行后续图片加工处理。In this embodiment, when the picture is adjusted according to the contrast and brightness adjustment algorithm, two pictures with different brightness levels can be obtained. Set the value of B to be [-1,0] when obtaining dark pictures, and to [0,1] when obtaining bright pictures. And in the above process, c can take any value in the value range [-1,1]. By adjusting the contrast and brightness of the input picture through the contrast and brightness adjustment algorithm, a bright picture and a dark picture with better picture quality can be obtained for subsequent picture processing.
模糊正向匀光图片获取单元130,用于获取所述输入图片的原图尺寸,根据所述原图尺寸初始化得到一个初始模糊正向匀光图片,对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片。The fuzzy forward uniform light image acquisition unit 130 is configured to acquire the original image size of the input image, initialize an initial fuzzy forward uniform light image according to the original image size, and perform processing on the initial blurred forward uniform light image Blur forward uniform light, get the current fuzzy forward uniform light picture.
在本实施例中,由于亮图片或是暗图片中可能会出现亮度分布不均匀的现象,严重影响图片质量,增加了后续图像处理难度。此时为了消除图片亮度分布不均匀的现象,可以对图像进行匀光处理。本申请中,可以采用MASK匀光算法对图片进行处理,增强高频信息,抑制低频信息,从而增强图片的细节反差,抑制图片的异常亮度变化,从而实现匀光的目的。In this embodiment, the uneven brightness distribution may occur in the bright picture or the dark picture, which seriously affects the picture quality and increases the difficulty of subsequent image processing. At this time, in order to eliminate the uneven brightness distribution of the picture, the image can be homogenized. In this application, the MASK uniform light algorithm can be used to process the picture to enhance high-frequency information and suppress low-frequency information, thereby enhancing the detail contrast of the picture and suppressing abnormal brightness changes of the picture, so as to achieve the purpose of uniform light.
此时采用MASK匀光算法对图片进行处理时,不是直接对亮图片或者暗图片进行处理,而是先初始生成一个与所述输入图片具有相同图片尺寸的初始模糊正向匀光图片(也可以理解为初始模糊正向匀光图片与输入图片完全相同),然后对其进行MASK匀光得到当前模糊正向匀光图片。所得到的当前模糊正向匀光图片进一步进行处理后即可参与处理暗图片或亮图片,从而增强所得到样本图片的细节反差,抑制样本图片的异常亮度变化。At this time, when the MASK uniform light algorithm is used to process the picture, instead of directly processing the bright picture or the dark picture, an initial fuzzy forward uniform light picture with the same picture size as the input picture is initially generated (it can also be It is understood that the initial blurred forward uniform light picture is exactly the same as the input picture), and then the MASK uniform light is performed on it to obtain the current blurred forward uniform light picture. The obtained current fuzzy forward homogenized image can participate in the processing of dark or bright images after further processing, thereby enhancing the detail contrast of the obtained sample image and suppressing abnormal brightness changes of the sample image.
在一实施例中,作为模糊正向匀光图片获取单元130的第一具体实施,所述模糊正向匀光图片获取单元130还用于:In an embodiment, as a first specific implementation of the fuzzy forward uniform light image acquisition unit 130, the fuzzy forward uniform light image acquisition unit 130 is further configured to:
调用预先存储的平面模糊正向匀光算法,将所述初始模糊正向匀光图片通过所述平面模糊正向匀光算法进行平面模糊正向匀光,得到当前模糊正向匀光图片;其中,所述平面模糊正向匀光算法中平面公式为Y=a1X+b1,a1和b1为随机值;若所述初始模糊正向匀光图片中有像素点位于所述Y=a1X+b1的平面内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于所述Y=a1X+b1的平面外则将对应的像素点的像素值设置为0。Invoking the pre-stored flat fuzzy forward uniform light algorithm, and the initial fuzzy forward uniform light image is subjected to plane fuzzy forward uniform light through the plane fuzzy forward uniform light algorithm to obtain the current blurred forward uniform light image; where , The plane formula in the plane blur forward uniform light algorithm is Y=a1X+b1, and a1 and b1 are random values; if there are pixels in the initial blur forward uniform light picture that are located in the Y=a1X+b1 In the plane, the pixel value of the corresponding pixel is set to 255; if there is a pixel in the initial blurred forward uniform light image that is outside the plane of Y=a1X+b1, then the pixel value of the corresponding pixel is set Is 0.
在本实施例中,在初始化得到一张当前模糊正向匀光图片,可以通过平面MASK算法(即平面模糊正向匀光算法)对所述当前模糊正向匀光图片进行平面MASK,得到当前模糊正向匀光图片。In this embodiment, a current fuzzy forward uniform light image is obtained during initialization, and the current fuzzy forward uniform light image can be subjected to planar MASK using the planar MASK algorithm (that is, the planar fuzzy forward uniform light algorithm) to obtain the current Blur the picture with the forward uniform light.
通过对当前模糊正向匀光图片进行平面MASK,就是将当前模糊正向匀光图片中的各像素点进行如下判断:By performing planar mask on the current blurred forward uniform light image, each pixel in the current blurred forward uniform light image is judged as follows:
若所述初始模糊正向匀光图片中有像素点位于Y=a1X+b1的平面内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于Y=a1X+b1的平面外则将对应的像素点的像素值设置为0;其中,平面模糊正向匀光算法中平面公式为Y=a1X+b1,a1和b1为随机值。通过上述平面MASK处理,增强了初始模糊正向匀光图片中的高频信息,抑制其中低频信息,抑制初始模糊正向匀光图片的异常亮度变化。If there are pixels in the initial blurred forward uniform light picture that are located in the plane of Y=a1X+b1, the pixel value of the corresponding pixel is set to 255; if there are pixels in the initial blurred forward uniform light picture Outside the plane of Y=a1X+b1, the pixel value of the corresponding pixel is set to 0; the plane formula in the plane blur forward homogenization algorithm is Y=a1X+b1, and a1 and b1 are random values. Through the above-mentioned planar mask processing, the high frequency information in the initial blurred forward uniform light image is enhanced, the low frequency information therein is suppressed, and the abnormal brightness change of the initial blurred forward uniform light image is suppressed.
在一实施例中,作为模糊正向匀光图片获取单元130的第二具体实施,所述模糊正向匀光图片获取单元130还用于:In an embodiment, as a second specific implementation of the fuzzy forward uniform light image acquisition unit 130, the fuzzy forward uniform light image acquisition unit 130 is further configured to:
调用预先存储的曲面模糊正向匀光算法,将所述初始模糊正向匀光图片通过所述曲面模糊正向匀光算法进行平面模糊正向匀光,得到当前模糊正向匀光图片;其中,所述曲面模糊正向匀光算法中平面公式为a*x 2+b*y 2+c*x*y+d*x+e*y=f,a、b、c、d、e为随机值;若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围外则将对应的像素点的像素值设置为0。 Invoking the pre-stored curved surface fuzzy forward uniform light algorithm, the initial fuzzy forward uniform light image is subjected to planar fuzzy forward uniform light through the curved surface fuzzy forward uniform light algorithm, to obtain the current fuzzy forward uniform light image; where , The plane formula in the curved surface fuzzy forward homogenization algorithm is a*x 2 +b*y 2 +c*x*y+d*x+e*y=f, a, b, c, d, e are Random value; if there are pixels in the initial blurred forward homogenized image that are located in the plane range of a*x 2 +b*y 2 +c*x*y+d*x+e*y=f, it will correspond The pixel value of the pixel point of is set to 255; if there is a pixel point in the initial blurry forward homogenization picture located at a*x 2 +b*y 2 +c*x*y+d*x+e*y=f Set the pixel value of the corresponding pixel to 0 outside the plane range.
在本实施例中,在初始化得到一张当前模糊正向匀光图片,还可以通过曲面MASK算法(即曲面模糊正向匀光算法)对所述当前模糊正向匀光图片进行曲面MASK,得到当前模糊正向匀光图片。In this embodiment, a current fuzzy forward uniform light image is obtained during initialization, and the current fuzzy forward uniform light image can also be surface-masked through the curved surface MASK algorithm (that is, the curved surface fuzzy forward uniform light algorithm), to obtain The current picture is blurred forward and even light.
通过对当前模糊正向匀光图片进行曲面MASK,就是将当前模糊正向匀光图片中的各像素点进行如下判断:By performing surface MASK on the current blurred forward uniform light image, each pixel in the current blurred forward uniform light image is judged as follows:
若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围外则将对应的像素点的像素值设置为0;其中,曲面模糊正向匀光算法中曲面公式为a*x 2+b*y 2+c*x*y+d*x+e*y=f,a、b、c、d、e为随机值。通过上述曲面MASK处理,也实现了增强初始模糊正向匀光图片中的高频信息,抑制其中低频信息,抑制初始模糊正向匀光图片的异常亮度变化。也即在具体实施时,可以选择平面MASK算法或曲面MASK算法中的其中任意一种对所述初始模糊正向匀光图片进行匀光处理。 If there are pixels in the initial blurred forward homogenization image that are located in the plane range of a*x 2 + b*y 2 + c*x*y+d*x+e*y=f, then the corresponding pixel points The pixel value of is set to 255; if there is a pixel in the initial blurred forward homogenization picture that is located in the plane range of a*x 2 +b*y 2 +c*x*y+d*x+e*y=f Outside, set the pixel value of the corresponding pixel to 0; among them, the surface formula in the surface fuzzy forward uniform light algorithm is a*x 2 +b*y 2 +c*x*y+d*x+e*y =f, a, b, c, d, e are random values. Through the above-mentioned curved surface MASK processing, the high frequency information in the initial blurred forward uniform light image is also enhanced, the low frequency information therein is suppressed, and the abnormal brightness change of the initial blurred forward uniform light image is suppressed. That is, during specific implementation, any one of the planar MASK algorithm or the curved surface MASK algorithm can be selected to perform the homogenization process on the initial blurred forward homogenization image.
高斯模糊单元140,用于将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后 图片。The Gaussian blurring unit 140 is configured to perform Gaussian blurring on the current blurred forward uniform light image to obtain a Gaussian blurred image.
在本实施例中,当得到了所述当前模糊正向匀光图片后,为了减少图像噪声以及降低细节层次。图像的高斯模糊过程就是图像与正态分布做卷积。由于正态分布又叫作高斯分布,故此项技术称为高斯模糊。In this embodiment, after the current blurred forward uniform light image is obtained, in order to reduce image noise and reduce the level of detail. The Gaussian blur process of the image is the convolution of the image and the normal distribution. Since the normal distribution is also called Gaussian distribution, this technique is called Gaussian blur.
在一实施例中,高斯模糊单元140还用于:In an embodiment, the Gaussian blur unit 140 is also used for:
采用二维高斯函数
Figure PCTCN2020111946-appb-000003
且滤波核尺寸为[10,100]中的随机数将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;其中,(x,y)表示所述当前模糊正向匀光图片中的像素点坐标,σ是x的方差。
Use a two-dimensional Gaussian function
Figure PCTCN2020111946-appb-000003
And the filter kernel size is a random number in [10,100] to perform Gaussian blurring on the current blurred forward uniform light picture to obtain a Gaussian blurred picture; where (x, y) represents the current blurred forward uniform light picture The pixel coordinates of, σ is the variance of x.
高斯模糊在二维空间定义为
Figure PCTCN2020111946-appb-000004
此时通过二维空间的高斯模糊对所述当前模糊正向匀光图片进行高斯模糊后,即可得到减少图像噪声以及降低细节层次后的高斯模糊后图片。
Gaussian blur is defined in two-dimensional space as
Figure PCTCN2020111946-appb-000004
At this time, after Gaussian blurring is performed on the current blurred forward homogenized image through Gaussian blurring in the two-dimensional space, a Gaussian blurred image with reduced image noise and reduced level of detail can be obtained.
图片合成单元150,用于根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本。The picture synthesis unit 150 is configured to synthesize the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture.
在本实施例中,在前面的步骤中得到了所述输入图片对应的暗图片和亮图片及所述高斯模糊后图片,此时可以分别将亮图片经过高斯模糊后图片处理,以及将暗图片经过高斯模糊后图片处理后叠加,即可得到与所述输入图片对应的图像样本,通过这一处理,所生成的图片样本逼真度高。In this embodiment, the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture are obtained in the previous steps. At this time, the bright picture can be processed by Gaussian blurred picture, and the dark picture After Gaussian blurring, the pictures are processed and then superimposed to obtain image samples corresponding to the input pictures. Through this processing, the generated picture samples have high fidelity.
在一实施例中,图片合成单元150包括:In an embodiment, the picture synthesis unit 150 includes:
归一化单元,用于将所述高斯模糊后图片进行归一化处理,得到归一化图片;A normalization unit, configured to perform normalization processing on the Gaussian blurred picture to obtain a normalized picture;
权重矩阵计算单元,用于获取所述归一化图片对应的像素矩阵以作为第一矩阵,将单位矩阵减去所述第一矩阵得到第二矩阵;A weight matrix calculation unit, configured to obtain a pixel matrix corresponding to the normalized picture as a first matrix, and subtract the first matrix from the identity matrix to obtain a second matrix;
图片权重处理单元,用于将所述亮图片对应的亮图片像素矩阵与所述第一矩阵相乘得到第一最终像素矩阵,将所述暗图片对应的像素矩阵与所处第二矩阵相乘得到第二最终像素矩阵;A picture weight processing unit, configured to multiply the bright picture pixel matrix corresponding to the bright picture by the first matrix to obtain a first final pixel matrix, and multiply the pixel matrix corresponding to the dark picture by the second matrix where it is located Obtain the second final pixel matrix;
图片权重求和叠加单元,用于将所述第一最终像素矩阵与所述第二最终像素矩阵相加求和,得到与所述输入图片对应的图像样本。The picture weight summation and superposition unit is configured to add and sum the first final pixel matrix and the second final pixel matrix to obtain an image sample corresponding to the input picture.
在本实施例中,对所述高斯模糊后图片进行归一化处理,是为了将其处理为权重矩阵,以分别计算亮图片和暗图片在叠加时分别对应的权重。具体实施时,将第一矩阵作为亮图片对应的权重,将第二矩阵作为暗图片对应的权重,之后将第一最终像素矩阵与第二最终像素矩阵相加求和,得到与所述输入图片对应的图像样本,上述通过基于局部阴影特效得到的图片的效果非常接近真实场景拍摄的样本,甚至可以模拟出在真实场景中很难采集的样本。In this embodiment, the purpose of normalizing the Gaussian blurred picture is to process it into a weight matrix, so as to calculate the respective weights of the bright pictures and the dark pictures when they are superimposed. In specific implementation, the first matrix is taken as the weight corresponding to the bright picture, and the second matrix is taken as the weight corresponding to the dark picture, and then the first final pixel matrix and the second final pixel matrix are added and summed to obtain the input picture Corresponding image samples, the effects of the above-mentioned pictures obtained by special effects based on partial shadows are very close to samples taken in real scenes, and can even simulate samples that are difficult to collect in real scenes.
在一实施例中,基于局部阴影特效的图像样本生成装置100还包括:In an embodiment, the device 100 for generating image samples based on partial shadow special effects further includes:
图片发送单元,用于将所述输入图片与所述图像样本均发送至用户端。The picture sending unit is configured to send both the input picture and the image sample to the user terminal.
在本实施例中,当在服务器中根据输入图片扩展得到的图像样本后,可以将输入图片和图像样本发送至用户端,用户端中可以根据扩充后的图像样本进行身份证识别模型的训练。In this embodiment, after the image sample obtained by expanding the input picture in the server, the input picture and the image sample can be sent to the user terminal, and the user terminal can train the ID card recognition model based on the expanded image sample.
具体实施时,基于局部阴影特效的图像样本生成装置100还包括:During specific implementation, the device 100 for generating image samples based on partial shadow special effects further includes:
模型接收单元,用于接收并存储用户端根据包括输入图片和图像样本的图片训练集训练得到的身份证识别模型。The model receiving unit is used to receive and store the ID card recognition model trained by the user terminal according to the picture training set including the input picture and the image sample.
在本实施例中,当在用户端中根据包括输入图片和图像样本的图片训练集对训练待训练身份证识别模型(如卷积神经网络)进行训练,所得到的身份证识别模型发送至服务器进行存储。In this embodiment, when the ID card recognition model (such as convolutional neural network) to be trained is trained in the user terminal according to the image training set including the input image and image samples, the obtained ID card recognition model is sent to the server Store it.
在一实施例中,基于局部阴影特效的图像样本生成装置100还包括:In an embodiment, the device 100 for generating image samples based on partial shadow special effects further includes:
参数上链单元,用于将所述身份证识别模型对应的参数集上传至区块链网络。The parameter chaining unit is used to upload the parameter set corresponding to the ID card recognition model to the blockchain network.
在本实施例中,服务器可以作为一个区块链节点设备,将所述身份证识别模型对应的参数集上传至区块链网络,充分利用区块链数据不可篡改的特性,实现身份证识别模型对应的参数集的数据固化存储。服务器从区块链网络重新下载获取了所述身份证识别模型对应的参 数集后,可以根据所述身份证识别模型对应的参数集重新还原身份证识别模型。In this embodiment, the server can be used as a blockchain node device to upload the parameter set corresponding to the ID card identification model to the blockchain network, making full use of the non-tamperable characteristics of blockchain data to realize the ID card identification model The data of the corresponding parameter set is solidified and stored. After the server re-downloads and obtains the parameter set corresponding to the ID card recognition model from the blockchain network, it can restore the ID card recognition model again according to the parameter set corresponding to the ID card recognition model.
其中,基于所述身份证识别模型对应的参数集得到对应的摘要信息,具体来说,摘要信息由所述身份证识别模型对应的参数集进行散列处理得到,比如利用sha256算法处理得到。将摘要信息上传至区块链可保证其安全性和对用户的公正透明性。服务器可以从区块链中下载得该摘要信息,以便查证所述身份证识别模型对应的参数集是否被篡改。本示例所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。Wherein, the corresponding summary information is obtained based on the parameter set corresponding to the ID card recognition model. Specifically, the summary information is obtained by hashing the parameter set corresponding to the ID card recognition model, for example, obtained by using the sha256 algorithm. Uploading summary information to the blockchain can ensure its security and fairness and transparency to users. The server can download the summary information from the blockchain to verify whether the parameter set corresponding to the ID card recognition model has been tampered with. The blockchain referred to in this example is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain, essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information for verification. The validity of the information (anti-counterfeiting) and generation of the next block. The blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
该装置实现了对输入图片基于局部阴影特效进行图像样本的扩充,降低了获取身份证图片样本的获取难度,而且所扩充的图像样本接近真实场景拍摄的样本,解决了小样本问题。The device realizes the expansion of image samples of input pictures based on the special effects of partial shadows, which reduces the difficulty of obtaining ID card image samples, and the expanded image samples are close to samples taken in real scenes, which solves the problem of small samples.
上述基于局部阴影特效的图像样本生成装置可以实现为计算机程序的形式,该计算机程序可以在如图4所示的计算机设备上运行。The above-mentioned image sample generating device based on partial shadow special effects can be implemented in the form of a computer program, and the computer program can be run on a computer device as shown in FIG. 4.
请参阅图4,图4是本申请实施例提供的计算机设备的示意性框图。该计算机设备500是服务器,服务器可以是独立的服务器,也可以是多个服务器组成的服务器集群。Please refer to FIG. 4, which is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device 500 is a server, and the server may be an independent server or a server cluster composed of multiple servers.
参阅图4,该计算机设备500包括通过系统总线501连接的处理器502、存储器和网络接口505,其中,存储器可以包括非易失性存储介质503和内存储器504。Referring to FIG. 4, the computer device 500 includes a processor 502, a memory, and a network interface 505 connected through a system bus 501, where the memory may include a non-volatile storage medium 503 and an internal memory 504.
该非易失性存储介质503可存储操作系统5031和计算机程序5032。该计算机程序5032被执行时,可使得处理器502执行基于局部阴影特效的图像样本生成方法。The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, the processor 502 can execute an image sample generation method based on partial shadow effects.
该处理器502用于提供计算和控制能力,支撑整个计算机设备500的运行。The processor 502 is used to provide calculation and control capabilities, and support the operation of the entire computer device 500.
该内存储器504为非易失性存储介质503中的计算机程序5032的运行提供环境,该计算机程序5032被处理器502执行时,可使得处理器502执行基于局部阴影特效的图像样本生成方法。The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can make the processor 502 execute an image sample generation method based on partial shadow effects.
该网络接口505用于进行网络通信,如提供数据信息的传输等。本领域技术人员可以理解,图4中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备500的限定,具体的计算机设备500可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。The network interface 505 is used for network communication, such as providing data information transmission. Those skilled in the art can understand that the structure shown in FIG. 4 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
其中,所述处理器502用于运行存储在存储器中的计算机程序5032,以实现本申请实施例公开的基于局部阴影特效的图像样本生成方法。Wherein, the processor 502 is configured to run a computer program 5032 stored in a memory to implement the method for generating image samples based on partial shadow special effects disclosed in the embodiments of the present application.
本领域技术人员可以理解,图4中示出的计算机设备的实施例并不构成对计算机设备具体构成的限定,在其他实施例中,计算机设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。例如,在一些实施例中,计算机设备可以仅包括存储器及处理器,在这样的实施例中,存储器及处理器的结构及功能与图4所示实施例一致,在此不再赘述。Those skilled in the art can understand that the embodiment of the computer device shown in FIG. 4 does not constitute a limitation on the specific configuration of the computer device. In other embodiments, the computer device may include more or less components than those shown in the figure. Or some parts are combined, or different parts are arranged. For example, in some embodiments, the computer device may only include a memory and a processor. In such embodiments, the structures and functions of the memory and the processor are the same as those of the embodiment shown in FIG. 4, and will not be repeated here.
应当理解,在本申请实施例中,处理器502可以是中央处理单元(Central Processing Unit,CPU),该处理器502还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that in this embodiment of the application, the processor 502 may be a central processing unit (Central Processing Unit, CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (Digital Signal Processors, DSPs), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
在本申请的另一实施例中提供计算机可读存储介质。该计算机可读存储介质可以是非易失性,也可以是易失性。该计算机可读存储介质存储有计算机程序,其中计算机程序被处理器执行时实现本申请实施例公开的基于局部阴影特效的图像样本生成方法。In another embodiment of the present application, a computer-readable storage medium is provided. The computer-readable storage medium may be non-volatile or volatile. The computer-readable storage medium stores a computer program, where the computer program is executed by a processor to realize the method for generating image samples based on partial shadow special effects disclosed in the embodiments of the present application.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的设备、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能 够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those skilled in the art can clearly understand that, for the convenience and conciseness of description, the specific working process of the above-described equipment, device, and unit can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here. A person of ordinary skill in the art may realize that the units and algorithm steps of the examples described in the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both, in order to clearly illustrate the hardware and software Interchangeability, in the above description, the composition and steps of each example have been generally described in accordance with the function. Whether these functions are executed by hardware or software depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
在本申请所提供的几个实施例中,应该理解到,所揭露的设备、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为逻辑功能划分,实际实现时可以有另外的划分方式,也可以将具有相同功能的单元集合成一个单元,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口、装置或单元的间接耦合或通信连接,也可以是电的,机械的或其它的形式连接。In the several embodiments provided in this application, it should be understood that the disclosed equipment, device, and method may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, or the units with the same function may be combined into one. Units, for example, multiple units or components can be combined or integrated into another system, or some features can be omitted or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may also be electrical, mechanical or other forms of connection.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本申请实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments of the present application.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以是两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, the functional units in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分,或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application is essentially or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium. It includes several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), magnetic disk or optical disk and other media that can store program codes.
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。The above are only specific implementations of this application, but the protection scope of this application is not limited to this. Anyone familiar with the technical field can easily think of various equivalents within the technical scope disclosed in this application. Modifications or replacements, these modifications or replacements shall be covered within the protection scope of this application. Therefore, the protection scope of this application shall be subject to the protection scope of the claims.

Claims (20)

  1. 一种基于局部阴影特效的图像样本生成方法,其中,包括:An image sample generation method based on special effects of partial shadows, which includes:
    接收并保存输入图片;Receive and save the input picture;
    调用预先存储的对比度亮度调节算法,将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片;Call a pre-stored contrast and brightness adjustment algorithm, adjust the contrast and brightness of the input picture, to obtain a dark picture and a bright picture corresponding to the input picture;
    获取所述输入图片的原图尺寸,根据所述原图尺寸初始化得到一个初始模糊正向匀光图片,对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片;Obtain the original image size of the input picture, initialize an initial blurred forward uniform light image according to the original image size, and perform blur forward uniform light on the initial blurred forward uniform light image to obtain the current blurred forward uniform light Light picture
    将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;以及Performing Gaussian blurring on the current blurred forward uniform light image to obtain a Gaussian blurred image; and
    根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本。Synthesize according to the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture.
  2. 根据权利要求1所述的基于局部阴影特效的图像样本生成方法,其中,所述对比度亮度调节算法为:The method for generating image samples based on partial shadow special effects according to claim 1, wherein the contrast brightness adjustment algorithm is:
    y ij=[x ij-127.5*(1-B)]*k+127.5*(1+B); y ij =[x ij -127.5*(1-B)]*k+127.5*(1+B);
    其中,x ij表示所述输入图片中第i行第j列像素点的像素值;y ij表示对比度亮度调节后中第i行第j列像素点的像素值;B为亮度调节参数,且B的取值范围是[-1,1];k为对比度调节参数,且k=tan((45+44*c)/180*π),c的取值范围是[-1,1]; Where x ij represents the pixel value of the pixel in the i-th row and j-th column of the input image; y ij represents the pixel value of the pixel in the i-th row and j-th column after the contrast brightness adjustment; B is the brightness adjustment parameter, and The value range of is [-1,1]; k is the contrast adjustment parameter, and k=tan((45+44*c)/180*π), the value range of c is [-1,1];
    所述将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片,包括;The adjusting the contrast and brightness of the input picture to obtain a dark picture and a bright picture corresponding to the input picture includes;
    获取所述输入图片中各像素点的像素值;Obtaining the pixel value of each pixel in the input picture;
    调用所述对比度亮度调节算法,将所述对比度亮度调节算法中的亮度调节参数取值范围设置为[-1,0],以将各像素点的像素值进行亮度对比度调节,得到各像素点对应的第一调节后像素值,以得到暗图片;Call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [-1, 0] to adjust the brightness and contrast of the pixel value of each pixel to obtain the corresponding pixel The first adjusted pixel value of to obtain a dark picture;
    调用所述对比度亮度调节算法,将所述对比度亮度调节算法中的亮度调节参数取值范围设置为[0,1],以将各像素点的像素值进行亮度对比度调节,得到各像素点对应的第二调节后像素值,以得到亮图片。Call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [0, 1] to adjust the brightness and contrast of the pixel value of each pixel to obtain the corresponding pixel value The second adjusted pixel value to obtain a bright picture.
  3. 根据权利要求1所述的基于局部阴影特效的图像样本生成方法,其中,所述对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片,包括:The method for generating image samples based on local shadow special effects according to claim 1, wherein said performing blur forward homogenization on said initial blurred forward homogenization picture to obtain a current blurred forward homogenization picture comprises:
    调用预先存储的平面模糊正向匀光算法,将所述初始模糊正向匀光图片通过所述平面模糊正向匀光算法进行平面模糊正向匀光,得到当前模糊正向匀光图片;其中,所述平面模糊正向匀光算法中平面公式为Y=a1X+b1,a1和b1为随机值;若所述初始模糊正向匀光图片中有像素点位于所述Y=a1X+b1的平面内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于所述Y=a1X+b1的平面外则将对应的像素点的像素值设置为0。Invoking the pre-stored flat fuzzy forward uniform light algorithm, and the initial fuzzy forward uniform light image is subjected to plane fuzzy forward uniform light through the plane fuzzy forward uniform light algorithm to obtain the current blurred forward uniform light image; where , The plane formula in the plane blur forward uniform light algorithm is Y=a1X+b1, and a1 and b1 are random values; if there are pixels in the initial blur forward uniform light picture that are located in the Y=a1X+b1 In the plane, the pixel value of the corresponding pixel is set to 255; if there is a pixel in the initial blurred forward uniform light image that is outside the plane of Y=a1X+b1, then the pixel value of the corresponding pixel is set Is 0.
  4. 根据权利要求1所述的基于局部阴影特效的图像样本生成方法,其中,所述对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片,包括:The method for generating image samples based on local shadow special effects according to claim 1, wherein said performing blur forward homogenization on said initial blurred forward homogenization picture to obtain a current blurred forward homogenization picture comprises:
    调用预先存储的曲面模糊正向匀光算法,将所述初始模糊正向匀光图片通过所述曲面模糊正向匀光算法进行平面模糊正向匀光,得到当前模糊正向匀光图片;其中,所述曲面模糊正向匀光算法中平面公式为a*x 2+b*y 2+c*x*y+d*x+e*y=f,a、b、c、d、e为随机值;若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围外则将对应的像素点的像素值设置为0。 Invoking the pre-stored curved surface fuzzy forward uniform light algorithm, the initial fuzzy forward uniform light image is subjected to planar fuzzy forward uniform light through the curved surface fuzzy forward uniform light algorithm, to obtain the current fuzzy forward uniform light image; where , The plane formula in the curved surface fuzzy forward homogenization algorithm is a*x 2 +b*y 2 +c*x*y+d*x+e*y=f, a, b, c, d, e are Random value; if there are pixels in the initial blurred forward homogenized image that are located in the plane range of a*x 2 +b*y 2 +c*x*y+d*x+e*y=f, it will correspond The pixel value of the pixel point of is set to 255; if there is a pixel point in the initial blurry forward homogenization picture located at a*x 2 +b*y 2 +c*x*y+d*x+e*y=f Set the pixel value of the corresponding pixel to 0 outside the plane range.
  5. 根据权利要求1所述的基于局部阴影特效的图像样本生成方法,其中,所述将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片,包括:The method for generating image samples based on local shadow special effects according to claim 1, wherein said performing Gaussian blurring on the current blurred forward uniform light picture to obtain a Gaussian blurred picture comprises:
    采用二维高斯函数
    Figure PCTCN2020111946-appb-100001
    且滤波核尺寸为[10,100]中的随机数将所述 当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;其中,(x,y)表示所述当前模糊正向匀光图片中的像素点坐标,σ是x的方差。
    Use a two-dimensional Gaussian function
    Figure PCTCN2020111946-appb-100001
    And the filter kernel size is a random number in [10,100] to perform Gaussian blurring on the current blurred forward uniform light picture to obtain a Gaussian blurred picture; where (x, y) represents the current blurred forward uniform light picture The pixel coordinates of, σ is the variance of x.
  6. 根据权利要求5所述的基于局部阴影特效的图像样本生成方法,其中,所述根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本,包括:The method for generating image samples based on local shadow special effects according to claim 5, wherein the synthesis is performed according to the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain a picture corresponding to the input picture Image samples of including:
    将所述高斯模糊后图片进行归一化处理,得到归一化图片;Performing normalization processing on the Gaussian blurred picture to obtain a normalized picture;
    获取所述归一化图片对应的像素矩阵以作为第一矩阵,将单位矩阵减去所述第一矩阵得到第二矩阵;Acquiring a pixel matrix corresponding to the normalized picture as a first matrix, and subtracting the first matrix from the identity matrix to obtain a second matrix;
    将所述亮图片对应的亮图片像素矩阵与所述第一矩阵相乘得到第一最终像素矩阵,将所述暗图片对应的像素矩阵与所处第二矩阵相乘得到第二最终像素矩阵;Multiplying the pixel matrix of the bright picture corresponding to the bright picture by the first matrix to obtain a first final pixel matrix, and multiplying the pixel matrix corresponding to the dark picture by the second matrix where it is located to obtain a second final pixel matrix;
    将所述第一最终像素矩阵与所述第二最终像素矩阵相加求和,得到与所述输入图片对应的图像样本。The first final pixel matrix and the second final pixel matrix are added and summed to obtain an image sample corresponding to the input picture.
  7. 根据权利要求1所述的基于局部阴影特效的图像样本生成方法,其中,还包括:The method for generating image samples based on partial shadow special effects according to claim 1, further comprising:
    将所述输入图片与所述图像样本均发送至用户端。Both the input picture and the image sample are sent to the user terminal.
  8. 根据权利要求1所述的基于局部阴影特效的图像样本生成方法,其中,还包括:The method for generating image samples based on partial shadow special effects according to claim 1, further comprising:
    接收并存储用户端根据包括输入图片和图像样本的图片训练集训练得到的身份证识别模型;Receive and store the ID card recognition model trained by the user terminal according to the picture training set including the input picture and the image sample;
    将所述身份证识别模型对应的参数集上传至区块链网络。Upload the parameter set corresponding to the ID card recognition model to the blockchain network.
  9. 一种基于局部阴影特效的图像样本生成装置,其中,包括:An image sample generating device based on local shadow special effects, which includes:
    图片接收单元,用于接收并保存输入图片;The picture receiving unit is used to receive and save the input picture;
    对比度亮度调节单元,用于调用预先存储的对比度亮度调节算法,将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片;The contrast and brightness adjustment unit is used to call a pre-stored contrast and brightness adjustment algorithm to adjust the contrast and brightness of the input picture to obtain dark pictures and bright pictures corresponding to the input picture;
    模糊正向匀光图片获取单元,用于获取所述输入图片的原图尺寸,根据所述原图尺寸初始化得到一个初始模糊正向匀光图片,对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片;The fuzzy forward uniform light image acquisition unit is configured to acquire the original image size of the input image, initialize an initial fuzzy forward uniform light image according to the original image size, and blur the initial blurred forward uniform light image Forward homogenization, get the current fuzzy positive homogenization picture;
    高斯模糊单元,用于将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;以及The Gaussian blur unit is used to perform Gaussian blurring on the current blurred forward uniform light picture to obtain a Gaussian blurred picture; and
    图片合成单元,用于根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本。The picture synthesis unit is configured to synthesize the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture.
  10. 一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现以下步骤:A computer device includes a memory, a processor, and a computer program stored on the memory and capable of running on the processor, wherein the processor implements the following steps when the processor executes the computer program:
    接收并保存输入图片;Receive and save the input picture;
    调用预先存储的对比度亮度调节算法,将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片;Call a pre-stored contrast and brightness adjustment algorithm, adjust the contrast and brightness of the input picture, to obtain a dark picture and a bright picture corresponding to the input picture;
    获取所述输入图片的原图尺寸,根据所述原图尺寸初始化得到一个初始模糊正向匀光图片,对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片;Obtain the original image size of the input picture, initialize an initial blurred forward uniform light image according to the original image size, and perform blur forward uniform light on the initial blurred forward uniform light image to obtain the current blurred forward uniform light Light picture
    将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;以及Performing Gaussian blurring on the current blurred forward uniform light image to obtain a Gaussian blurred image; and
    根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本。Synthesize according to the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture.
  11. 根据权利要求10所述的计算机设备,其中,所述对比度亮度调节算法为:The computer device according to claim 10, wherein the contrast brightness adjustment algorithm is:
    y ij=[x ij-127.5*(1-B)]*k+127.5*(1+B); y ij =[x ij -127.5*(1-B)]*k+127.5*(1+B);
    其中,x ij表示所述输入图片中第i行第j列像素点的像素值;y ij表示对比度亮度调节后中第i行第j列像素点的像素值;B为亮度调节参数,且B的取值范围是[-1,1];k为对比度调节参数,且k=tan((45+44*c)/180*π),c的取值范围是[-1,1]; Where x ij represents the pixel value of the pixel in the i-th row and j-th column of the input image; y ij represents the pixel value of the pixel in the i-th row and j-th column after the contrast brightness adjustment; B is the brightness adjustment parameter, and B The value range of is [-1,1]; k is the contrast adjustment parameter, and k=tan((45+44*c)/180*π), the value range of c is [-1,1];
    所述将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片,包括;The adjusting the contrast and brightness of the input picture to obtain a dark picture and a bright picture corresponding to the input picture includes;
    获取所述输入图片中各像素点的像素值;Obtaining the pixel value of each pixel in the input picture;
    调用所述对比度亮度调节算法,将所述对比度亮度调节算法中的亮度调节参数取值范围设置为[-1,0],以将各像素点的像素值进行亮度对比度调节,得到各像素点对应的第一调节后像素值,以得到暗图片;Call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [-1, 0] to adjust the brightness and contrast of the pixel value of each pixel to obtain the corresponding pixel The first adjusted pixel value of to obtain a dark picture;
    调用所述对比度亮度调节算法,将所述对比度亮度调节算法中的亮度调节参数取值范围设置为[0,1],以将各像素点的像素值进行亮度对比度调节,得到各像素点对应的第二调节后像素值,以得到亮图片。Call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [0, 1] to adjust the brightness and contrast of the pixel value of each pixel to obtain the corresponding pixel value The second adjusted pixel value to obtain a bright picture.
  12. 根据权利要求10所述的计算机设备,其中,所述对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片,包括:11. The computer device according to claim 10, wherein said performing the blur and forward uniform light on the initial blurry forward uniform light image to obtain the current blur forward uniform light image comprises:
    调用预先存储的平面模糊正向匀光算法,将所述初始模糊正向匀光图片通过所述平面模糊正向匀光算法进行平面模糊正向匀光,得到当前模糊正向匀光图片;其中,所述平面模糊正向匀光算法中平面公式为Y=a1X+b1,a1和b1为随机值;若所述初始模糊正向匀光图片中有像素点位于所述Y=a1X+b1的平面内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于所述Y=a1X+b1的平面外则将对应的像素点的像素值设置为0。Invoking the pre-stored flat fuzzy forward uniform light algorithm, and the initial fuzzy forward uniform light image is subjected to plane fuzzy forward uniform light through the plane fuzzy forward uniform light algorithm to obtain the current blurred forward uniform light image; where , The plane formula in the plane blur forward uniform light algorithm is Y=a1X+b1, and a1 and b1 are random values; if there are pixels in the initial blur forward uniform light picture that are located in the Y=a1X+b1 In the plane, the pixel value of the corresponding pixel is set to 255; if there is a pixel in the initial blurred forward uniform light image that is outside the plane of Y=a1X+b1, then the pixel value of the corresponding pixel is set Is 0.
  13. 根据权利要求10所述的计算机设备,其中,所述对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片,包括:11. The computer device according to claim 10, wherein said performing the blur and forward uniform light on the initial blurry forward uniform light image to obtain the current blur forward uniform light image comprises:
    调用预先存储的曲面模糊正向匀光算法,将所述初始模糊正向匀光图片通过所述曲面模糊正向匀光算法进行平面模糊正向匀光,得到当前模糊正向匀光图片;其中,所述曲面模糊正向匀光算法中平面公式为a*x 2+b*y 2+c*x*y+d*x+e*y=f,a、b、c、d、e为随机值;若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于a*x 2+b*y 2+c*x*y+d*x+e*y=f的平面范围外则将对应的像素点的像素值设置为0。 Invoking the pre-stored curved surface fuzzy forward uniform light algorithm, the initial fuzzy forward uniform light image is subjected to planar fuzzy forward uniform light through the curved surface fuzzy forward uniform light algorithm, to obtain the current fuzzy forward uniform light image; where , The plane formula in the curved surface fuzzy forward homogenization algorithm is a*x 2 +b*y 2 +c*x*y+d*x+e*y=f, a, b, c, d, e are Random value; if there are pixels in the initial blurred forward homogenized image that are located in the plane range of a*x 2 +b*y 2 +c*x*y+d*x+e*y=f, it will correspond The pixel value of the pixel point of is set to 255; if there is a pixel point in the initial blurry forward homogenization picture located at a*x 2 +b*y 2 +c*x*y+d*x+e*y=f Set the pixel value of the corresponding pixel to 0 outside the plane range.
  14. 根据权利要求10所述的计算机设备,其中,所述将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片,包括:10. The computer device according to claim 10, wherein said performing Gaussian blurring on the current blurred forward uniform light image to obtain a Gaussian blurred image comprises:
    采用二维高斯函数
    Figure PCTCN2020111946-appb-100002
    且滤波核尺寸为[10,100]中的随机数将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;其中,(x,y)表示所述当前模糊正向匀光图片中的像素点坐标,σ是x的方差。
    Use a two-dimensional Gaussian function
    Figure PCTCN2020111946-appb-100002
    And the filter kernel size is a random number in [10,100] to perform Gaussian blurring on the current blurred forward uniform light picture to obtain a Gaussian blurred picture; where (x, y) represents the current blurred forward uniform light picture The pixel coordinates of, σ is the variance of x.
  15. 根据权利要求14所述的计算机设备,其中,所述根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本,包括:14. The computer device according to claim 14, wherein said synthesizing according to the dark picture and light picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture comprises:
    将所述高斯模糊后图片进行归一化处理,得到归一化图片;Performing normalization processing on the Gaussian blurred picture to obtain a normalized picture;
    获取所述归一化图片对应的像素矩阵以作为第一矩阵,将单位矩阵减去所述第一矩阵得到第二矩阵;Acquiring a pixel matrix corresponding to the normalized picture as a first matrix, and subtracting the first matrix from the identity matrix to obtain a second matrix;
    将所述亮图片对应的亮图片像素矩阵与所述第一矩阵相乘得到第一最终像素矩阵,将所述暗图片对应的像素矩阵与所处第二矩阵相乘得到第二最终像素矩阵;Multiplying the pixel matrix of the bright picture corresponding to the bright picture by the first matrix to obtain a first final pixel matrix, and multiplying the pixel matrix corresponding to the dark picture by the second matrix where it is located to obtain a second final pixel matrix;
    将所述第一最终像素矩阵与所述第二最终像素矩阵相加求和,得到与所述输入图片对应的图像样本。The first final pixel matrix and the second final pixel matrix are added and summed to obtain an image sample corresponding to the input picture.
  16. 根据权利要求10所述的计算机设备,其中,还包括:The computer device according to claim 10, further comprising:
    将所述输入图片与所述图像样本均发送至用户端。Both the input picture and the image sample are sent to the user terminal.
  17. 根据权利要求10所述的计算机设备,其中,还包括:The computer device according to claim 10, further comprising:
    接收并存储用户端根据包括输入图片和图像样本的图片训练集训练得到的身份证识别模型;Receive and store the ID card recognition model trained by the user terminal according to the image training set including input images and image samples;
    将所述身份证识别模型对应的参数集上传至区块链网络。Upload the parameter set corresponding to the ID card recognition model to the blockchain network.
  18. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序当被处理器执行以下操作:A computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to perform the following operations:
    接收并保存输入图片;Receive and save the input picture;
    调用预先存储的对比度亮度调节算法,将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片;Call a pre-stored contrast and brightness adjustment algorithm, adjust the contrast and brightness of the input picture, to obtain a dark picture and a bright picture corresponding to the input picture;
    获取所述输入图片的原图尺寸,根据所述原图尺寸初始化得到一个初始模糊正向匀光图片,对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片;Obtain the original image size of the input picture, initialize an initial blurred forward uniform light image according to the original image size, and perform blur forward uniform light on the initial blurred forward uniform light image to obtain the current blurred forward uniform light Light picture
    将所述当前模糊正向匀光图片进行高斯模糊,得到高斯模糊后图片;以及Performing Gaussian blurring on the current blurred forward uniform light image to obtain a Gaussian blurred image; and
    根据所述输入图片对应的暗图片和亮图片以及所述高斯模糊后图片进行合成,得到与所述输入图片对应的图像样本。Synthesize according to the dark picture and the bright picture corresponding to the input picture and the Gaussian blurred picture to obtain an image sample corresponding to the input picture.
  19. 根据权利要求18所述的计算机可读存储介质,其中,所述对比度亮度调节算法为:18. The computer-readable storage medium of claim 18, wherein the contrast brightness adjustment algorithm is:
    y ij=[x ij-127.5*(1-B)]*k+127.5*(1+B); y ij =[x ij -127.5*(1-B)]*k+127.5*(1+B);
    其中,x ij表示所述输入图片中第i行第j列像素点的像素值;y ij表示对比度亮度调节后中第i行第j列像素点的像素值;B为亮度调节参数,且B的取值范围是[-1,1];k为对比度调节参数,且k=tan((45+44*c)/180*π),c的取值范围是[-1,1]; Where x ij represents the pixel value of the pixel in the i-th row and j-th column of the input picture; y ij represents the pixel value of the pixel in the i-th row and j-th column after the contrast brightness adjustment; B is the brightness adjustment parameter, and B The value range of is [-1,1]; k is the contrast adjustment parameter, and k=tan((45+44*c)/180*π), the value range of c is [-1,1];
    所述将所述输入图片进行对比度亮度调节,得到与所述输入图片对应的暗图片和亮图片,包括;The adjusting the contrast and brightness of the input picture to obtain a dark picture and a bright picture corresponding to the input picture includes;
    获取所述输入图片中各像素点的像素值;Obtaining the pixel value of each pixel in the input picture;
    调用所述对比度亮度调节算法,将所述对比度亮度调节算法中的亮度调节参数取值范围设置为[-1,0],以将各像素点的像素值进行亮度对比度调节,得到各像素点对应的第一调节后像素值,以得到暗图片;Call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [-1, 0] to adjust the brightness and contrast of the pixel value of each pixel to obtain the corresponding pixel The first adjusted pixel value of to obtain a dark picture;
    调用所述对比度亮度调节算法,将所述对比度亮度调节算法中的亮度调节参数取值范围设置为[0,1],以将各像素点的像素值进行亮度对比度调节,得到各像素点对应的第二调节后像素值,以得到亮图片。Call the contrast and brightness adjustment algorithm, and set the value range of the brightness adjustment parameter in the contrast and brightness adjustment algorithm to [0, 1] to adjust the brightness and contrast of the pixel value of each pixel to obtain the corresponding pixel value The second adjusted pixel value to obtain a bright picture.
  20. 根据权利要求18所述的计算机可读存储介质,其中,所述对所述初始模糊正向匀光图片进行模糊正向匀光,得到当前模糊正向匀光图片,包括:18. The computer-readable storage medium according to claim 18, wherein said performing blur and forward dodging on the initial blurry forward dodging picture to obtain a current blurry forward dodging picture comprises:
    调用预先存储的平面模糊正向匀光算法,将所述初始模糊正向匀光图片通过所述平面模糊正向匀光算法进行平面模糊正向匀光,得到当前模糊正向匀光图片;其中,所述平面模糊正向匀光算法中平面公式为Y=a1X+b1,a1和b1为随机值;若所述初始模糊正向匀光图片中有像素点位于所述Y=a1X+b1的平面内则将对应的像素点的像素值设置为255;若所述初始模糊正向匀光图片中有像素点位于所述Y=a1X+b1的平面外则将对应的像素点的像素值设置为0。Invoking the pre-stored flat fuzzy forward uniform light algorithm, and the initial fuzzy forward uniform light image is subjected to plane fuzzy forward uniform light through the plane fuzzy forward uniform light algorithm to obtain the current blurred forward uniform light image; where , The plane formula in the plane blur forward uniform light algorithm is Y=a1X+b1, and a1 and b1 are random values; if there are pixels in the initial blur forward uniform light picture that are located in the Y=a1X+b1 In the plane, the pixel value of the corresponding pixel is set to 255; if there is a pixel in the initial blurred forward uniform light image that is outside the plane of Y=a1X+b1, then the pixel value of the corresponding pixel is set Is 0.
PCT/CN2020/111946 2020-07-31 2020-08-28 Image sample generation method and apparatus based on local shadow special effect WO2021139179A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010763065.7A CN111914934B (en) 2020-07-31 2020-07-31 Image sample generation method and device based on local shadow special effect
CN202010763065.7 2020-07-31

Publications (1)

Publication Number Publication Date
WO2021139179A1 true WO2021139179A1 (en) 2021-07-15

Family

ID=73287510

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/111946 WO2021139179A1 (en) 2020-07-31 2020-08-28 Image sample generation method and apparatus based on local shadow special effect

Country Status (2)

Country Link
CN (1) CN111914934B (en)
WO (1) WO2021139179A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113674272A (en) * 2021-09-06 2021-11-19 上海集成电路装备材料产业创新中心有限公司 Image detection method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050286794A1 (en) * 2004-06-24 2005-12-29 Apple Computer, Inc. Gaussian blur approximation suitable for GPU
CN108460414A (en) * 2018-02-27 2018-08-28 北京三快在线科技有限公司 Generation method, device and the electronic equipment of training sample image
CN109325532A (en) * 2018-09-18 2019-02-12 成都网阔信息技术股份有限公司 The image processing method of EDS extended data set under a kind of small sample
CN110070130A (en) * 2019-04-23 2019-07-30 杭州智趣智能信息技术有限公司 A kind of certificate information recognition methods, transposition, equipment and medium
CN110163285A (en) * 2019-05-23 2019-08-23 阳光保险集团股份有限公司 Ticket recognition training sample synthetic method and computer storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3348167B2 (en) * 1996-03-26 2002-11-20 シャープ株式会社 Image binarization device
US8472712B2 (en) * 2009-10-20 2013-06-25 Apple Inc. System and method for applying lens shading correction during image processing
US8644638B2 (en) * 2011-02-25 2014-02-04 Microsoft Corporation Automatic localized adjustment of image shadows and highlights
CN104700371B (en) * 2015-03-18 2017-11-03 厦门美图之家科技有限公司 The generation method and system of a kind of masking-out

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050286794A1 (en) * 2004-06-24 2005-12-29 Apple Computer, Inc. Gaussian blur approximation suitable for GPU
CN108460414A (en) * 2018-02-27 2018-08-28 北京三快在线科技有限公司 Generation method, device and the electronic equipment of training sample image
CN109325532A (en) * 2018-09-18 2019-02-12 成都网阔信息技术股份有限公司 The image processing method of EDS extended data set under a kind of small sample
CN110070130A (en) * 2019-04-23 2019-07-30 杭州智趣智能信息技术有限公司 A kind of certificate information recognition methods, transposition, equipment and medium
CN110163285A (en) * 2019-05-23 2019-08-23 阳光保险集团股份有限公司 Ticket recognition training sample synthetic method and computer storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113674272A (en) * 2021-09-06 2021-11-19 上海集成电路装备材料产业创新中心有限公司 Image detection method and device
CN113674272B (en) * 2021-09-06 2024-03-15 上海集成电路装备材料产业创新中心有限公司 Image detection method and device

Also Published As

Publication number Publication date
CN111914934B (en) 2023-07-04
CN111914934A (en) 2020-11-10

Similar Documents

Publication Publication Date Title
Li et al. Low-light image and video enhancement using deep learning: A survey
Chen et al. Hdrunet: Single image hdr reconstruction with denoising and dequantization
Zhang et al. High-quality exposure correction of underexposed photos
US9275445B2 (en) High dynamic range and tone mapping imaging techniques
CN108234858B (en) Image blurring processing method and device, storage medium and electronic equipment
CN111311532B (en) Image processing method and device, electronic device and storage medium
US11004179B2 (en) Image blurring methods and apparatuses, storage media, and electronic devices
CN111985281B (en) Image generation model generation method and device and image generation method and device
CN110166684B (en) Image processing method, image processing device, computer readable medium and electronic equipment
Celebi et al. Fuzzy fusion based high dynamic range imaging using adaptive histogram separation
CN115829055B (en) Federal learning model training method, federal learning model training device, federal learning model training computer equipment and federal learning model storage medium
CN113222855A (en) Image recovery method, device and equipment
CN110751593A (en) Image blurring processing method and device
WO2021139179A1 (en) Image sample generation method and apparatus based on local shadow special effect
CN110717864B (en) Image enhancement method, device, terminal equipment and computer readable medium
Wu et al. Reflectance-guided histogram equalization and comparametric approximation
Chen et al. Single-image hdr reconstruction with task-specific network based on channel adaptive RDN
Li et al. A novel detail weighted histogram equalization method for brightness preserving image enhancement based on partial statistic and global mapping model
Pan et al. ChebyLighter: Optimal Curve Estimation for Low-light Image Enhancement
CN116645305A (en) Low-light image enhancement method based on multi-attention mechanism and Retinex
Ko et al. IceNet for interactive contrast enhancement
CN116167926A (en) Model training method and contrast adjustment method
WO2021164329A1 (en) Image processing method and apparatus, and communication device and readable storage medium
CN109308690A (en) A kind of brightness of image equalization methods and terminal
CN110060210B (en) Image processing method and related device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20911696

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20911696

Country of ref document: EP

Kind code of ref document: A1