WO2019196542A1 - Image processing method and apparatus - Google Patents

Image processing method and apparatus Download PDF

Info

Publication number
WO2019196542A1
WO2019196542A1 PCT/CN2019/073831 CN2019073831W WO2019196542A1 WO 2019196542 A1 WO2019196542 A1 WO 2019196542A1 CN 2019073831 W CN2019073831 W CN 2019073831W WO 2019196542 A1 WO2019196542 A1 WO 2019196542A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
pile
processed
point
gray value
Prior art date
Application number
PCT/CN2019/073831
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 WO2019196542A1 publication Critical patent/WO2019196542A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/28Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/50Extraction of image or video features by performing operations within image blocks; by using histograms, e.g. histogram of oriented gradients [HoG]; by summing image-intensity values; Projection analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06KGRAPHICAL DATA READING; PRESENTATION OF DATA; RECORD CARRIERS; HANDLING RECORD CARRIERS
    • G06K7/00Methods or arrangements for sensing record carriers, e.g. for reading patterns
    • G06K7/10Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation
    • G06K7/14Methods or arrangements for sensing record carriers, e.g. for reading patterns by electromagnetic radiation, e.g. optical sensing; by corpuscular radiation using light without selection of wavelength, e.g. sensing reflected white light
    • G06K7/1404Methods for optical code recognition
    • G06K7/1408Methods for optical code recognition the method being specifically adapted for the type of code
    • G06K7/14172D bar codes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/46Descriptors for shape, contour or point-related descriptors, e.g. scale invariant feature transform [SIFT] or bags of words [BoW]; Salient regional features
    • G06V10/467Encoded features or binary features, e.g. local binary patterns [LBP]

Definitions

  • the present application relates to the field of information technology, and in particular, to a method and an apparatus for image processing.
  • Image binarization is one of the basic operations in image processing, and refers to an image processing method in which the gray value of a pixel on an image is set to 0 or 255.
  • the process of binarizing an image requires binarization processing for each pixel. Specifically, for each pixel in the image, first, a gray value of each pixel in a preset range with the pixel as a center point may be determined, and then, the determined average gray value of each pixel is calculated, As a threshold corresponding to the pixel, and then determining whether the gray value of the pixel is greater than the threshold, if yes, adjusting the gray value of the pixel to 255, that is, white, if not, adjusting the pixel The gray value is 0, that is, black. Thereby binarizing all pixels in the image to black or white.
  • Figure 1 is a schematic diagram of the existing binarization. Taking the pixel point A in the image as an example, from top to bottom respectively, the preset range corresponding to the pixel point A is determined first, and then the gray value of each pixel in the preset range is determined, and then the average gray level of each pixel is calculated. Value, finally, based on the numerical value of the gray value of the pixel point A and the average gray value, the gray value of the binarization of the pixel point A is determined.
  • the existing binarization processing method needs to calculate the average gray value corresponding to each pixel point, so that the calculation amount is large. Therefore, the present specification proposes a new image processing method to solve the defects existing in the prior art.
  • the embodiment of the present invention provides a method and an apparatus for image processing, which are used to solve the problem that the prior art requires a large amount of calculation when the image is binarized, resulting in low processing efficiency.
  • a method of image processing comprising:
  • a device for identifying the uniqueness of a device comprising:
  • An aliquoting module determines the standard height and the standard width by halving according to the size of the image to be processed
  • a pile positioning module to determine a standard height and a standard width as a spacing, and determine a matrix consisting of a plurality of pile points in the image to be processed
  • a gray scale calculation module for each pile point, determining an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point;
  • the determining adjustment module determines, for each pixel point in the image to be processed, a pile point closest to the pixel point, and determines whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point, and if so, Then, the gray value of the pixel is adjusted to be a first value, and if not, the gray value of the pixel is adjusted to a second value.
  • An apparatus for image processing comprising: one or more processors and a memory, the memory storing a program, and being configured to perform the following steps by one or more processors:
  • the standard height and the standard width are determined by an equal division operation according to the size of the image to be processed, and then the piled point is determined in the image to be processed according to the determined standard height and the standard width.
  • the matrix is then determined by the average gray value of the area around each pile point, and each pixel point in the image to be processed is determined whether the gray value of the pixel point is smaller than the average gray value corresponding to the nearest pile point. And binarizing the pixel points according to the judgment result.
  • the method and apparatus provided by the present specification reduce the number of times the average gray value needs to be calculated, and improve the efficiency of binarization in image processing.
  • Figure 1 is a schematic diagram of the existing binarization
  • Figure 3 is a number of steps of two-dimensional code preprocessing
  • FIG. 4 is a schematic diagram of determining a pile point in an image to be processed provided by the present specification
  • FIG. 5 is a schematic diagram of determining a matrix composed of pile points on an image to be processed provided in the present specification
  • 6a and 6b are schematic diagrams provided by the present specification, taking the width of an image to be processed as an example
  • FIG. 7 is a schematic diagram of calculating an average gray value corresponding to each pile point based on the pile point matrix shown in FIG. 5;
  • FIG. 8 is a schematic diagram showing the presence of a plurality of pile points closest to the distance from the pixel
  • Figure 9 is a schematic diagram of a situation in which misjudgment occurs in binarization
  • FIG. 10 is a schematic structural diagram of an apparatus for image processing according to an embodiment of the present disclosure.
  • FIG. 11 is a schematic structural diagram of an apparatus for image processing according to an embodiment of the present disclosure.
  • the image processing process provided by one or more embodiments of the present specification is specifically a process of image binarization.
  • the performance of devices such as mobile terminals is becoming more and more powerful, so that mobile terminals (such as mobile phones) also have hardware conditions for performing image processing. Therefore, in this specification, it is not limited to which device is responsible for images. Processing.
  • the image processing process can be performed by a server, a mobile phone, a tablet, a personal computer, or the like.
  • the terminal can first determine the image to be processed.
  • the present application is not limited to whether the image to be processed is generated by the terminal itself, acquired from other devices, or provided by other devices. For example, after the mobile phone takes an image, the image is determined as an image to be processed, or the captured image is provided to the server by the webcam, and the image is determined by the server as the image to be processed, or after the server sends the image acquisition request to the terminal. And determine the image returned by the terminal as the image to be processed.
  • image binarization is one of the basic operations in image processing, and is usually used as a part of the processing steps in some image processing processes
  • the image binarization process provided in this specification can be used for image processing alone. Operation, or as part of an image processing process, can be used in conjunction with other image processing operations. For example, when the common two-dimensional code is preprocessed, the image processing process is as shown in FIG. 3, and binarization is seen as a loop in the image processing process.
  • S102 Determine a standard height and a standard width by halving according to the size of the image to be processed.
  • the image to be processed is divided into a plurality of regions, and for each region, the average gray value of the region is taken as the average gray value corresponding to each pixel in the region, so as to ensure the binary value. At the same time, the amount of calculation is reduced.
  • the size of the image to be processed may be determined first, and then the standard height and the standard width are further determined by the halving operation for the execution of the subsequent steps.
  • the terminal may determine the height of the image to be processed, and then perform an equal division calculation on the height of the image to be processed according to the preset value, determine the calculation result, and then, if the calculation result If it is an integer, the calculation result is taken as the standard height, and if the calculation result is not an integer, the calculation result is taken up to an integer, and the rounded result is taken as the standard height.
  • the terminal can determine the standard width through the same process.
  • the preset value can be set as needed, and the specification is not limited. For example, if you want to divide more areas, the value can be set larger. If the area of the area you want to divide is relatively larger, the value can be set smaller.
  • width is the width of the image to be processed
  • height is the height of the image to be processed
  • a is a preset value.
  • the result of the aliquot calculation is either an integer or not an integer.
  • the standard height and the standard width are determined for subsequent determination of the calculated average gray value range in the image to be processed, which needs to be an integer. Thus, when the result of the calculation is not an integer, the result of the calculation is taken up to an integer.
  • the terminal can determine the calculation after dividing the width according to the above formula.
  • the result is 10, which can be determined as the standard width, and the settlement result of the equal division of the height is 9.875, so the upward rounding can be surely the standard height is 10.
  • S104 Determine the standard height and the standard width as the spacing, and determine a matrix consisting of several pile points in the image to be processed.
  • the standard width and the standard height determined in the step S102 are determined by the division operation, it is determined in accordance with the standard width and the standard height, and a matrix composed of pile points is determined in the image to be processed.
  • the matrix of the pile points can be evenly distributed in the image to be processed, so that when binarizing each pixel point, the binarization can be determined according to the average gray value corresponding to the pile point closest to the pixel point. As a result, the problem of excessive calculation is avoided.
  • the terminal may first select any one of the pixels in the image to be processed as a starting point, and then based on the starting point, the standard width is the width spacing of each pile point, and the standard height is the height spacing of each pile point. , generating a matrix of pile points.
  • the pile point matrix is uniformly covered in the image to be processed, as shown in FIG.
  • FIG. 4 is a schematic diagram of determining a pile point in an image to be processed provided by the present specification. Among them, it can be seen that the spacing of the pile points is a standard width and a standard height, and can be uniformly covered in the image to be processed.
  • the terminal may also use any one of the vertices of the image to be processed as the starting pile point, and then determine the pile point on the image to be processed at the standard height and the standard width.
  • the matrix of the composition For example, as shown in Figure 5.
  • step S102 for a calculation result that is not an integer, the terminal determines the standard height (or the standard width) by rounding up. Therefore, when the size of the image to be processed cannot be divisible, the determined The matrix may have the situation as shown in Figures 6a and 6b, i.e. there may be no pile points on the boundary of the image to be processed.
  • 6a and 6b are schematic diagrams provided by the present specification, taking the width of an image to be processed as an example.
  • the preset value used in calculating the standard width is 8, the width of the image to be processed in FIG. 6a is 79, and the width of the image to be processed in FIG. 6b is 81, and the determined standard widths are 10 and 11, respectively. Therefore, when the upper left vertex of the image to be processed is taken as the starting point, there is a case where the pile point fails to conform to the boundary.
  • S106 For each pile point, determine an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point.
  • the terminal may calculate an average gray value corresponding to a region of a specified area around the pile point for each pile point in the pile point matrix determined in step S104, as the average gray value corresponding to the pile point. .
  • This step is similar to the method for determining the average gray value of the area around the pixel point in the prior art.
  • the terminal may be centered on the pile point for each pile point, and the standard height and the standard width are rectangular.
  • the side length determines the area around the pile point, and then calculates the average value of the gray value of each pixel point included in the area around the pile point as the gray value corresponding to the pile point.
  • Fig. 7 is a schematic diagram for calculating an average gray value corresponding to each pile point based on the pile point matrix shown in Fig. 5.
  • the dotted line frame corresponds to the area around each pile point.
  • step S108 determining, for each pixel in the image to be processed, a pile point closest to the pixel point, determining whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point, and then performing the step S110, otherwise step S112 is performed.
  • the terminal after determining the average gray value corresponding to each pile point, the terminal can perform binarization processing on the image to be processed.
  • the terminal may determine a pile point closest to the pixel point from each of the pile points for each pixel in the image to be processed, and then determine whether the gray value of the pixel point is smaller than the determined gray point corresponding to the pile point. The degree value, if yes, proceeds to step S110, otherwise to step S112.
  • Fig. 8 if point A is the same distance from pile point 1 and pile point 2, then one of pile point 1 and pile point 2 can be selected, point B is from pile point 1, pile point 2 If the distance between the pile point 3 and the pile point 4 is the same, then any one of the pile points 1 to 4 can be selected.
  • S112 Adjust the gray value of the pixel to a second value.
  • the gray value of the pixel point when it is determined that the gray value of the pixel point is smaller than the determined gray value corresponding to the pile point, the gray value of the pixel point is adjusted to be the first value, and when the gray value of the pixel point is determined not to be smaller than the determination
  • the gray value of the pixel is adjusted to a second value.
  • the first value and the second value may be set as needed. For example, when the color of the image is represented by 256 colors, the gray value is also 256 gray values, so the first value may be 0, and the second value may be Is 255.
  • the specific first value and the second value can be set as needed, for example, the first value is set to 10, the second value is set to 200, and the like.
  • the standard height and the standard width are determined by halving the image to be processed, and the standard width and the standard height are used as the pitch of the pile point, and the pile point is established on the image to be processed.
  • Matrix then calculate the gray value corresponding to each pile point (the average gray value of the area around the pile point), and then, when binarizing each pixel point, the gray corresponding to the pile point closest to the pixel point As the threshold value, the degree value is determined to adjust the gray value of the pixel point to the first value or the second value, and the binarization of the image to be processed is completed.
  • the execution bodies of the steps of the method provided in the embodiments of the present specification may all be the same device, or the method may also be performed by different devices.
  • the execution body of step S100 and step S102 may be device 1, and the execution body of step S102 may be device 2; or the execution body of step S100 may be device 1, and the execution body of step S102 and step S104 may be device 2; and many more.
  • Fig. 9 is a diagram showing a situation in which misjudgment occurs in binarization. Among them, it can be seen that the gray values of point A and point B are identical, but when the average gray value is calculated corresponding to the surrounding area of 3 ⁇ 3, the determined threshold values are different: 38 and 127, respectively, so the results after binarization are different. The two pixels of the same gray value are adjusted to white and adjusted to black, and the binarization effect is not good.
  • the embodiment of the present specification further provides an apparatus for image processing, as shown in FIG.
  • FIG. 10 is a schematic structural diagram of an apparatus for image processing according to an embodiment of the present disclosure, where the apparatus includes:
  • Determining module 200 determining an image to be processed
  • the halving module 202 determines the standard height and the standard width by halving according to the size of the image to be processed;
  • the pile point positioning module 204 determines a standard height and a standard width as a pitch, and determines a matrix composed of a plurality of pile points in the image to be processed;
  • the grayscale calculation module 206 determines, for each pile point, an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point;
  • the determining adjustment module 208 is configured to determine, for each pixel point in the image to be processed, a pile point closest to the pixel point, and determine whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point, and if Then, the gray value of the pixel is adjusted to be a first value, and if not, the gray value of the pixel is adjusted to a second value.
  • the halving module 202 determines the height and width of the image to be processed, and separately calculates the height and width of the image to be processed according to a preset value, and determines the standard height and the standard width according to the calculation result. .
  • the aliquoting module 202 when the calculation result of the aliquot calculation of the height of the image to be processed is not an integer, takes the calculation result up to an integer as the standard height, when the width of the image to be processed is performed, etc. When the calculation result of the sub-calculation is not an integer, the calculation result is taken up to the integer as the standard width.
  • the pile point positioning module 204 takes any vertex of the image to be processed as a starting pile point, determines a standard height and a standard width as a pitch, and determines that the pile to be processed is composed of a plurality of pile points. Matrix.
  • the gray scale calculation module 206 uses the standard height and the standard width as the side length, the pile point is a center point, determines an area around the pile point, and calculates each pixel point included in the area around the pile point. The average value of the gray value is used as the gray value corresponding to the pile point.
  • the gray value is a 256-level gray value, the first value is 0, and the second value is 255.
  • the determining adjustment module 208 selects any one of the pile points closest to the pixel point when there are a plurality of pile points closest to the pixel point.
  • the present specification correspondingly provides an apparatus for image processing, as shown in FIG. 11, wherein the apparatus includes: one or more processors and a memory, and the memory stores a program. And configured to perform the following steps by one or more processors:
  • PLD Programmable Logic Device
  • FPGA Field Programmable Gate Array
  • HDL Hardware Description Language
  • the controller can be implemented in any suitable manner, for example, the controller can take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor.
  • computer readable program code eg, software or firmware
  • examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, The Microchip PIC18F26K20 and the Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic.
  • the controller can be logically programmed by means of logic gates, switches, ASICs, programmable logic controllers, and embedding.
  • Such a controller can therefore be considered a hardware component, and the means for implementing various functions included therein can also be considered as a structure within the hardware component.
  • a device for implementing various functions can be considered as a software module that can be both a method of implementation and a structure within a hardware component.
  • the system, device, module or unit illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product having a certain function.
  • a typical implementation device is a computer.
  • the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or A combination of any of these devices.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • the memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory.
  • RAM random access memory
  • ROM read only memory
  • Memory is an example of a computer readable medium.
  • Computer readable media includes both permanent and non-persistent, removable and non-removable media.
  • Information storage can be implemented by any method or technology.
  • the information can be computer readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transportable media can be used to store information that can be accessed by a computing device.
  • computer readable media does not include temporary storage of computer readable media, such as modulated data signals and carrier waves.
  • embodiments of the present application can be provided as a method, system, or computer program product.
  • the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment in combination of software and hardware.
  • the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • the application can be described in the general context of computer-executable instructions executed by a computer, such as a program module.
  • program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types.
  • the present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network.
  • program modules can be located in both local and remote computer storage media including storage devices.

Abstract

Disclosed by the present application are an image processing method and apparatus; first, according to the size of an image to be processed, a standard height and standard width are determined by means of an operation to divide into equal parts; according to the determined standard height and standard width, a matrix consisting of pile points in the image to be processed is determined; then, taking an average gray value of the area around each pile point as a determination condition, it is determined, for each pixel in the image, whether the gray value of the pixel is smaller than the average gray value corresponding to the nearest pile point, and the pixel points are binarized according to result of determination.

Description

一种图像处理的方法及装置Method and device for image processing 技术领域Technical field
本申请涉及信息技术领域,尤其涉及一种图像处理的方法及装置。The present application relates to the field of information technology, and in particular, to a method and an apparatus for image processing.
背景技术Background technique
图像二值化是图像处理中的基本操作之一,是指将图像上的像素点的灰度值设置为0或255的图像处理方法。Image binarization is one of the basic operations in image processing, and refers to an image processing method in which the gray value of a pixel on an image is set to 0 or 255.
现有技术中,对图像进行二值化的过程,需要针对每个像素点进行二值化处理。具体的,针对图像中的每个像素点,首先,可确定以该像素点为中心点预设范围内的各像素点灰度值,之后,计算确定出的各像素点的平均灰度值,作为该像素点对应的阈值,然后,判断该像素点的灰度值是否大于该阈值,若是,则调整该像素点的灰度值为255,即,白色,若否,则调整该像素点的灰度值为0,即,黑色。从而将图像中所有像素点都二值化为黑色或者白色。In the prior art, the process of binarizing an image requires binarization processing for each pixel. Specifically, for each pixel in the image, first, a gray value of each pixel in a preset range with the pixel as a center point may be determined, and then, the determined average gray value of each pixel is calculated, As a threshold corresponding to the pixel, and then determining whether the gray value of the pixel is greater than the threshold, if yes, adjusting the gray value of the pixel to 255, that is, white, if not, adjusting the pixel The gray value is 0, that is, black. Thereby binarizing all pixels in the image to black or white.
图1为现有二值化的示意图。以图像中像素点A为例,从上至下分别为:先确定像素点A对应的预设范围,其次确定该预设范围内各像素点灰度值,之后,计算各像素点平均灰度值,最后,根据像素点A的灰度值以及平均灰度值的数值大小关系,判断该像素点A二值化的灰度值。Figure 1 is a schematic diagram of the existing binarization. Taking the pixel point A in the image as an example, from top to bottom respectively, the preset range corresponding to the pixel point A is determined first, and then the gray value of each pixel in the preset range is determined, and then the average gray level of each pixel is calculated. Value, finally, based on the numerical value of the gray value of the pixel point A and the average gray value, the gray value of the binarization of the pixel point A is determined.
可见,现有二值化处理方法,需要计算每个像素点对应的平均灰度值,使得计算量较多。因此,本说明书提出一种新的图像处理方法,以解决现有技术中存在的缺陷。It can be seen that the existing binarization processing method needs to calculate the average gray value corresponding to each pixel point, so that the calculation amount is large. Therefore, the present specification proposes a new image processing method to solve the defects existing in the prior art.
发明内容Summary of the invention
本说明书实施例提供一种图像处理的方法及装置,用于解决现有技术在对图像进行二值化处理时,需要计算量较多,导致处理效率低的问题。The embodiment of the present invention provides a method and an apparatus for image processing, which are used to solve the problem that the prior art requires a large amount of calculation when the image is binarized, resulting in low processing efficiency.
本说明书实施例采用下述技术方案:The embodiments of the present specification adopt the following technical solutions:
一种图像处理的方法,包括:A method of image processing, comprising:
确定待处理图像;Determining the image to be processed;
根据所述待处理图像的尺寸,通过等分操作,确定标准高度以及标准宽度;Determining a standard height and a standard width by halving according to the size of the image to be processed;
以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵;Determining a standard height and a standard width as a pitch, and determining a matrix consisting of a plurality of pile points in the image to be processed;
针对每个桩点,确定该桩点周围指定面积的区域的平均灰度值,作为该桩点对应的灰度值;For each pile point, determining an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point;
针对所述待处理图像中的每个像素点,确定距离该像素点最近的桩点,判断该像素点的灰度值是否小于确定出的桩点对应的灰度值;Determining, according to each pixel point in the image to be processed, a pile point closest to the pixel point, determining whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point;
若是,则调整该像素点的灰度值为第一数值;If yes, adjusting the gray value of the pixel to a first value;
若否,则调整该像素点的灰度值为第二数值。If not, adjust the gray value of the pixel to a second value.
一种识别设备唯一性的装置,包括:A device for identifying the uniqueness of a device, comprising:
确定模块,确定待处理图像;Determining a module to determine an image to be processed;
等分模块,根据所述待处理图像的尺寸,通过等分操作,确定标准高度以及标准宽度;An aliquoting module determines the standard height and the standard width by halving according to the size of the image to be processed;
桩点定位模块,以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵;a pile positioning module to determine a standard height and a standard width as a spacing, and determine a matrix consisting of a plurality of pile points in the image to be processed;
灰度计算模块,针对每个桩点,确定该桩点周围指定面积的区域的平均灰度值,作为该桩点对应的灰度值;a gray scale calculation module, for each pile point, determining an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point;
判断调整模块,针对所述待处理图像中的每个像素点,确定距离该像素点最近的桩点,判断该像素点的灰度值是否小于确定出的桩点对应的灰度值,若是,则调整该像素点的灰度值为第一数值,若否,则调整该像素点的灰度值为第二数值。The determining adjustment module determines, for each pixel point in the image to be processed, a pile point closest to the pixel point, and determines whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point, and if so, Then, the gray value of the pixel is adjusted to be a first value, and if not, the gray value of the pixel is adjusted to a second value.
一种用于图像处理的设备,其中,所述设备包括:一个或多个处理器及存储器,存储器存储有程序,并且被配置成由一个或多个处理器执行以下步骤:An apparatus for image processing, wherein the apparatus comprises: one or more processors and a memory, the memory storing a program, and being configured to perform the following steps by one or more processors:
确定待处理图像;Determining the image to be processed;
根据所述待处理图像的尺寸,通过等分操作,确定标准高度以及标准宽度;Determining a standard height and a standard width by halving according to the size of the image to be processed;
以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵;Determining a standard height and a standard width as a pitch, and determining a matrix consisting of a plurality of pile points in the image to be processed;
针对每个桩点,确定该桩点周围指定面积的区域的平均灰度值,作为该桩点对应的灰度值;For each pile point, determining an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point;
针对所述待处理图像中的每个像素点,确定距离该像素点最近的桩点,判断该像素点的灰度值是否小于确定出的桩点对应的灰度值;Determining, according to each pixel point in the image to be processed, a pile point closest to the pixel point, determining whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point;
若是,则调整该像素点的灰度值为第一数值;If yes, adjusting the gray value of the pixel to a first value;
若否,则调整该像素点的灰度值为第二数值。If not, adjust the gray value of the pixel to a second value.
本说明书实施例采用的上述至少一个技术方案能够达到以下有益效果:The above at least one technical solution adopted by the embodiments of the present specification can achieve the following beneficial effects:
通过本说明书提供的方法及装置,先根据待处理图像的尺寸,通过等分操作确定标准高度以及标准宽度,之后根据确定出的标准高度以及标准宽度,在待处理图像中确定由桩点组成的矩阵,然后以各桩点自身周围区域的平均灰度值作为判断条件,对待处理图像中的每个像素点,判断该像素点的灰度值是否小于距离最近的桩点对应的平均灰度值,并根据判断结果将像素点进行二值化处理。相比现有技术需要计算每个像素点对应的平均灰度值的方法,本说明书提供的方法及装置减少了需要计算平均灰度值的次数,提高了图像处理中二值化的效率。According to the method and device provided by the present specification, the standard height and the standard width are determined by an equal division operation according to the size of the image to be processed, and then the piled point is determined in the image to be processed according to the determined standard height and the standard width. The matrix is then determined by the average gray value of the area around each pile point, and each pixel point in the image to be processed is determined whether the gray value of the pixel point is smaller than the average gray value corresponding to the nearest pile point. And binarizing the pixel points according to the judgment result. Compared with the prior art method for calculating the average gray value corresponding to each pixel point, the method and apparatus provided by the present specification reduce the number of times the average gray value needs to be calculated, and improve the efficiency of binarization in image processing.
附图说明DRAWINGS
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described herein are intended to provide a further understanding of the present application, and are intended to be a part of this application. In the drawing:
图1为现有二值化的示意图;Figure 1 is a schematic diagram of the existing binarization;
图2为本说明书实施例提供的一种图像处理的过程;2 is a process of image processing provided by an embodiment of the present specification;
图3为二维码预处理的若干步骤;Figure 3 is a number of steps of two-dimensional code preprocessing;
图4为本说明书提供的在待处理图像中确定桩点的示意图;4 is a schematic diagram of determining a pile point in an image to be processed provided by the present specification;
图5为本说明书提供的待处理图像上确定由桩点组成的矩阵的示意图;FIG. 5 is a schematic diagram of determining a matrix composed of pile points on an image to be processed provided in the present specification; FIG.
图6a和图6b为本说明书提供的,以待处理图像的宽度为例的示意图;6a and 6b are schematic diagrams provided by the present specification, taking the width of an image to be processed as an example;
图7为基于图5所示的桩点矩阵,计算各桩点对应的平均灰度值的示意图;7 is a schematic diagram of calculating an average gray value corresponding to each pile point based on the pile point matrix shown in FIG. 5;
图8为存在与像素点的距离最近桩点存在多个的示意图;FIG. 8 is a schematic diagram showing the presence of a plurality of pile points closest to the distance from the pixel; FIG.
图9为二值化中出现误判的情况示意图;Figure 9 is a schematic diagram of a situation in which misjudgment occurs in binarization;
图10为本说明书实施例提供的一种图像处理的装置的结构示意图;FIG. 10 is a schematic structural diagram of an apparatus for image processing according to an embodiment of the present disclosure;
图11为本说明书实施例提供的一种用于图像处理的设备的结构示意图。FIG. 11 is a schematic structural diagram of an apparatus for image processing according to an embodiment of the present disclosure.
具体实施方式detailed description
为使本说明书的目的、技术方案和优点更加清楚,下面将结合本说明书具体实施例及相应的附图对本申请技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于说明书中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions of the present application will be clearly and completely described in the following with reference to the specific embodiments of the specification and the accompanying drawings. It is apparent that the described embodiments are only a part of the embodiments of the present application, and not all of them. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the specification without departing from the inventive scope are the scope of the application.
以下结合附图,详细说明本申请各实施例提供的技术方案。The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
图2为说明书实施例提供的一种图像处理的过程,具体可包括以下步骤:2 is a process of image processing provided by an embodiment of the present invention, which may specifically include the following steps:
S100:确定待处理图像。S100: Determine an image to be processed.
为解决现有图像处理中二值化方法的计算量过大的问题,本说明书一个或多个实施例提供的该图像处理过程,具体为图像二值化的过程。To solve the problem that the calculation amount of the binarization method in the existing image processing is too large, the image processing process provided by one or more embodiments of the present specification is specifically a process of image binarization.
随着技术发展,移动终端等设备的性能越来越强大,使得移动终端(如,手机)也具备了进行图像处理的硬件条件,因此在本说明书中,并不限定具体由何种设备执图像处理过程。例如,可由服务器、手机、平板电脑、个人电脑等设备执行该图像处理过程。With the development of technology, the performance of devices such as mobile terminals is becoming more and more powerful, so that mobile terminals (such as mobile phones) also have hardware conditions for performing image processing. Therefore, in this specification, it is not limited to which device is responsible for images. Processing. For example, the image processing process can be performed by a server, a mobile phone, a tablet, a personal computer, or the like.
为方便描述,在本说明书中后续以终端执行该图像处理过程为例进行说明。于是,该终端首先可确定待处理的图像。本申请对于该待处理图像是该终端自身生成的,还是从其他设备获取,或者是由其他设备提供的不做限定。例如,手机拍摄图像后,将该图像确定为待处理图像,或者由网络摄像头将拍摄的图像提供给服务器,由该服务器将该图像确定为待处理图像,或者由服务器向终端发送图像获取请求后,并将终端返回的图像确定为待处理图像。For convenience of description, the image processing procedure performed by the terminal in the following description will be described as an example. Thus, the terminal can first determine the image to be processed. The present application is not limited to whether the image to be processed is generated by the terminal itself, acquired from other devices, or provided by other devices. For example, after the mobile phone takes an image, the image is determined as an image to be processed, or the captured image is provided to the server by the webcam, and the image is determined by the server as the image to be processed, or after the server sends the image acquisition request to the terminal. And determine the image returned by the terminal as the image to be processed.
另外,由于图像二值化是图像处理中的基本操作之一,在某些图像处理过程中通常作为处理步骤中的一环,因此本说明书提供的图像二值化过程可为单独使用的图像处理操作,或者也可以作为图像处理过程中的一环与其他图像处理操作共同使用。例如,常见的对二维码进行预处理时,图像处理过程如图3所示,可见二值化作为图像处理过程中的一环。In addition, since image binarization is one of the basic operations in image processing, and is usually used as a part of the processing steps in some image processing processes, the image binarization process provided in this specification can be used for image processing alone. Operation, or as part of an image processing process, can be used in conjunction with other image processing operations. For example, when the common two-dimensional code is preprocessed, the image processing process is as shown in FIG. 3, and binarization is seen as a loop in the image processing process.
S102:根据所述待处理图像的尺寸,通过等分操作,确定标准高度以及标准宽度。S102: Determine a standard height and a standard width by halving according to the size of the image to be processed.
由于在现有图像二值化处理过程中,需要确定每个像素点周围区域对应的平均灰度值,而一般来说对于相邻的两个像素点,确定出的平均灰度值之间的差异较小。于是, 在本说明书中,将待处理图像划分为多个区域,针对每个区域,将该区域的平均灰度值,作为该区域内各像素点对应的平均灰度值,以在保证二值化效果的同时,减少计算量。Since in the existing image binarization process, it is necessary to determine the average gray value corresponding to the area around each pixel point, and generally for the adjacent two pixel points, the determined average gray value is between The difference is small. Therefore, in the present specification, the image to be processed is divided into a plurality of regions, and for each region, the average gray value of the region is taken as the average gray value corresponding to each pixel in the region, so as to ensure the binary value. At the same time, the amount of calculation is reduced.
在本说明书一个或多个实施例中,当该终端确定待处理图像后,可先确定该待处理图像的尺寸,之后通过等分操作,进一步确定标准高度以及标准宽度,以便后续步骤的执行。In one or more embodiments of the present specification, after the terminal determines the image to be processed, the size of the image to be processed may be determined first, and then the standard height and the standard width are further determined by the halving operation for the execution of the subsequent steps.
具体的,以确定该标准高度为例,首先终端可确定该待处理图像的高度,之后根据预设的数值,对该待处理图像的高度进行等分计算,确定计算结果,然后,若计算结果为整数,则将该计算结果作为标准高度,而若计算结果不是整数,则将计算结果向上取整数,并将取整的结果作为标准高度。同理,终端也可通过相同的过程,确定标准宽度。Specifically, to determine the standard height as an example, first, the terminal may determine the height of the image to be processed, and then perform an equal division calculation on the height of the image to be processed according to the preset value, determine the calculation result, and then, if the calculation result If it is an integer, the calculation result is taken as the standard height, and if the calculation result is not an integer, the calculation result is taken up to an integer, and the rounded result is taken as the standard height. Similarly, the terminal can determine the standard width through the same process.
其中,预设数值可以根据需要进行设置,本说明书不做限定。例如,若想要划分出更多区域则该数值可设置的较大,反之若想划分的区域面积相对大些,则数值可设置的较小。The preset value can be set as needed, and the specification is not limited. For example, if you want to divide more areas, the value can be set larger. If the area of the area you want to divide is relatively larger, the value can be set smaller.
在本说明书中,可根据公式windW=width/a确定对待处理图像的宽度进行等分操作后的计算结果,以及根据公式windH=height/a确定对待处理图像的宽度进行等分操作后的计算结果。其中,width为待处理图像的宽度、height为待处理图像的高度、a为预设数值。In the present specification, the calculation result after the operation of the width of the image to be processed is determined according to the formula windW=width/a, and the calculation result after the operation of the width of the image to be processed is determined according to the formula windH=height/a . Where width is the width of the image to be processed, height is the height of the image to be processed, and a is a preset value.
另外,由于待处理图像的高度和宽度是整数,但却不一定会被预设的数值整除,因此等分计算结果存在是整数或者不是整数两种情况。而确定出标准高度和标准宽度,用于后续在待处理图像中确定计算平均灰度值范围,需要是整数。于是,当计算结果不是整数,则将计算结果向上取整数。In addition, since the height and width of the image to be processed are integers, but they are not necessarily divisible by the preset value, the result of the aliquot calculation is either an integer or not an integer. The standard height and the standard width are determined for subsequent determination of the calculated average gray value range in the image to be processed, which needs to be an integer. Thus, when the result of the calculation is not an integer, the result of the calculation is taken up to an integer.
例如,以该预设的数值等于8为例,假设待识别图像的宽为80个像素,待识别图像的高为79个像素,则根据上述公式,终端可确定对宽度进行等分后的计算结果为10,可确定为标准宽度,而对高度进行等分结算的结算结果为9.875,因此向上取整可确地标准高度为10。For example, taking the preset value equal to 8 as an example, assuming that the width of the image to be recognized is 80 pixels, and the height of the image to be recognized is 79 pixels, the terminal can determine the calculation after dividing the width according to the above formula. The result is 10, which can be determined as the standard width, and the settlement result of the equal division of the height is 9.875, so the upward rounding can be surely the standard height is 10.
S104:以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵。S104: Determine the standard height and the standard width as the spacing, and determine a matrix consisting of several pile points in the image to be processed.
在本说明书中,由于在步骤S102中确定的标准宽度和标准高度是通过等分操作确 定的,因此可按照标准宽度和标准高确定,在该待处理图像中确定若干由桩点组成的矩阵。使该桩点的矩阵可以均匀分布在该待处理图像中,以便后续在对各像素点进行二值化时,可以根据距离该像素点最近的桩点对应的平均灰度值,确定二值化结果,从而避免计算量过多的问题。In the present specification, since the standard width and the standard height determined in the step S102 are determined by the division operation, it is determined in accordance with the standard width and the standard height, and a matrix composed of pile points is determined in the image to be processed. The matrix of the pile points can be evenly distributed in the image to be processed, so that when binarizing each pixel point, the binarization can be determined according to the average gray value corresponding to the pile point closest to the pixel point. As a result, the problem of excessive calculation is avoided.
具体的,终端可先在该待处理图像中选择任一一个像素点,作为起始点,然后基于该起始点,以标准宽度为各桩点的宽度间距,标准高度为各桩点的高度间距,生成桩点组成的矩阵。使得桩点矩阵均匀的覆盖在该待处理图像中,如图4所示。Specifically, the terminal may first select any one of the pixels in the image to be processed as a starting point, and then based on the starting point, the standard width is the width spacing of each pile point, and the standard height is the height spacing of each pile point. , generating a matrix of pile points. The pile point matrix is uniformly covered in the image to be processed, as shown in FIG.
图4为本说明书提供的在待处理图像中确定桩点的示意图。其中,可见桩点间距为标准宽度以及标准高度,可均匀的覆盖在该待处理图像中。FIG. 4 is a schematic diagram of determining a pile point in an image to be processed provided by the present specification. Among them, it can be seen that the spacing of the pile points is a standard width and a standard height, and can be uniformly covered in the image to be processed.
另外,在本说明书中,该终端也可以将该待处理图像的任一一个顶点作为起始的桩点,之后在以该标准高度以及标准宽度为间距,在待处理图像上确定由桩点组成的矩阵。如,图5所示。In addition, in the present specification, the terminal may also use any one of the vertices of the image to be processed as the starting pile point, and then determine the pile point on the image to be processed at the standard height and the standard width. The matrix of the composition. For example, as shown in Figure 5.
需要说明的是,由于在步骤S102中,对于不是整数的计算结果,终端采用向上取整的方式确定标准高度(或者,标准宽度),因此,当待处理图像的尺寸不能整除时,确定出的矩阵可能存在如图6a和图6b所示的情况,即,在待处理图像的边界上可能不存在桩点。It should be noted that, in step S102, for a calculation result that is not an integer, the terminal determines the standard height (or the standard width) by rounding up. Therefore, when the size of the image to be processed cannot be divisible, the determined The matrix may have the situation as shown in Figures 6a and 6b, i.e. there may be no pile points on the boundary of the image to be processed.
图6a和图6b为本说明书提供的,以待处理图像的宽度为例的示意图。其中,在计算标准宽度时采用的预设数值为8,图6a中待处理图像的宽度为79,图6b中待处理图像的宽度为81,则确定出的标准宽度分别为10和11。因此,当以待处理图像的左上顶点为起始点时,会出现桩点未能与边界契合的情况。6a and 6b are schematic diagrams provided by the present specification, taking the width of an image to be processed as an example. The preset value used in calculating the standard width is 8, the width of the image to be processed in FIG. 6a is 79, and the width of the image to be processed in FIG. 6b is 81, and the determined standard widths are 10 and 11, respectively. Therefore, when the upper left vertex of the image to be processed is taken as the starting point, there is a case where the pile point fails to conform to the boundary.
S106:针对每个桩点,确定该桩点周围指定面积的区域的平均灰度值,作为该桩点对应的灰度值。S106: For each pile point, determine an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point.
在本说明书中,终端可针对步骤S104中确定出的桩点矩阵中的每个桩点,计算该桩点周围指定面积的区域对应的平均灰度值,作为该桩点对应的平均灰度值。In the present specification, the terminal may calculate an average gray value corresponding to a region of a specified area around the pile point for each pile point in the pile point matrix determined in step S104, as the average gray value corresponding to the pile point. .
该步骤与现有技术中确定像素点周围区域的平均灰度值的手段类似,具体的,该终端可以针对每个桩点,以该桩点为中心点,以标准高度和标准宽度为矩形的边长,确定该桩点周围的区域,然后计算该桩点周围的区域包含的各像素点的灰度值的平均值,作为该桩点对应的灰度值。This step is similar to the method for determining the average gray value of the area around the pixel point in the prior art. Specifically, the terminal may be centered on the pile point for each pile point, and the standard height and the standard width are rectangular. The side length determines the area around the pile point, and then calculates the average value of the gray value of each pixel point included in the area around the pile point as the gray value corresponding to the pile point.
如图7所示,图7为基于图5所示的桩点矩阵,计算各桩点对应的平均灰度值的 示意图。其中,各虚线框对应各桩点周围的区域,在计算桩点对应的灰度值时,是计算该桩点所在虚线框内包含的各像素点的灰度值的平均值。As shown in Fig. 7, Fig. 7 is a schematic diagram for calculating an average gray value corresponding to each pile point based on the pile point matrix shown in Fig. 5. The dotted line frame corresponds to the area around each pile point. When calculating the gray value corresponding to the pile point, the average value of the gray value of each pixel included in the dotted line frame of the pile point is calculated.
S108:针对所述待处理图像中的每个像素点,确定距离该像素点最近的桩点,判断该像素点的灰度值是否小于确定出的桩点对应的灰度值,是则执行步骤S110,否则执行步骤S112。S108: determining, for each pixel in the image to be processed, a pile point closest to the pixel point, determining whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point, and then performing the step S110, otherwise step S112 is performed.
在本说明书中,终端在确定出各桩点对应的平均灰度值之后,便可对待处理图像进行二值化处理。In the present specification, after determining the average gray value corresponding to each pile point, the terminal can perform binarization processing on the image to be processed.
具体的,终端可针对待处理图像中的每个像素点,从各桩点中确定距离该像素点最近的桩点,然后判断该像素点的灰度值是否小于确定出的桩点对应的灰度值,若是则执行步骤S110,若否则执行步骤S112。Specifically, the terminal may determine a pile point closest to the pixel point from each of the pile points for each pixel in the image to be processed, and then determine whether the gray value of the pixel point is smaller than the determined gray point corresponding to the pile point. The degree value, if yes, proceeds to step S110, otherwise to step S112.
另外,由于还存在与像素点的距离最近桩点存在多个的情况,如图8所示,因此在本说明书中,针对每个像素点,当确定距离该像素点距离最近的桩点有多个时,选择任一一个距离最近的桩点,并根据选择出的桩点对应的灰度值,进行判断。In addition, since there are still a plurality of pile points closest to the distance from the pixel point, as shown in FIG. 8, therefore, in the present specification, for each pixel point, when determining the distance from the pixel point is the closest to the pile point At any time, select any one of the closest pile points and judge according to the gray value corresponding to the selected pile point.
图8中,点A距离桩点1和桩点2的距离相同均为X,则可选择桩点1和桩点2中的任一一个桩点,点B距离桩点1、桩点2、桩点3和桩点4的距离相同均为Y,则可从桩点1~4中选择任一一个桩点。In Fig. 8, if point A is the same distance from pile point 1 and pile point 2, then one of pile point 1 and pile point 2 can be selected, point B is from pile point 1, pile point 2 If the distance between the pile point 3 and the pile point 4 is the same, then any one of the pile points 1 to 4 can be selected.
S110:调整该像素点的灰度值为第一数值;S110: Adjust a gray value of the pixel to a first value;
S112:调整该像素点的灰度值为第二数值。S112: Adjust the gray value of the pixel to a second value.
在本说明书中,当判断像素点的灰度值小于确定出的桩点对应的灰度值时,调整该像素点的灰度值为第一数值,当判断像素点的灰度值不小于确定出的桩点对应的灰度值时,调整该像素点的灰度值为第二数值。其中,第一数值和第二数值可根据需要设置,例如,当采用256级色彩表示图像的颜色时,灰度值也为256级灰度值,因此第一数值可为0,第二数值可为255。In the present specification, when it is determined that the gray value of the pixel point is smaller than the determined gray value corresponding to the pile point, the gray value of the pixel point is adjusted to be the first value, and when the gray value of the pixel point is determined not to be smaller than the determination When the gray value corresponding to the pile point is obtained, the gray value of the pixel is adjusted to a second value. The first value and the second value may be set as needed. For example, when the color of the image is represented by 256 colors, the gray value is also 256 gray values, so the first value may be 0, and the second value may be Is 255.
当然,具体第一数值和第二数值可根据需要设置,例如,第一数值设置为10,第二数值设置为200,等等。Of course, the specific first value and the second value can be set as needed, for example, the first value is set to 10, the second value is set to 200, and the like.
基于图2所示的图像处理过程,通过对待处理图像进行等分处理,确定出标准高度以及标准宽度,并以该标准宽度和标准高度作为桩点的间距,在该待处理图像上建立桩点矩阵,之后再计算各桩点对应的灰度值(桩点周围区域的平均灰度值),然后在对 各像素点进行二值化处理时,以距离该像素点最近的桩点对应的灰度值作为阈值,判断是将该像素点的灰度值调整为第一数值还是第二数值,完成对该待处理图像的二值化。在本说明书提供的方法中,只需计算若干桩点周围区域的平均灰度值,而无需计算每个像素点对应的平均灰度值,大大减少了二值化的计算量,提高了二值化的效率。Based on the image processing process shown in FIG. 2, the standard height and the standard width are determined by halving the image to be processed, and the standard width and the standard height are used as the pitch of the pile point, and the pile point is established on the image to be processed. Matrix, then calculate the gray value corresponding to each pile point (the average gray value of the area around the pile point), and then, when binarizing each pixel point, the gray corresponding to the pile point closest to the pixel point As the threshold value, the degree value is determined to adjust the gray value of the pixel point to the first value or the second value, and the binarization of the image to be processed is completed. In the method provided by the present specification, it is only necessary to calculate the average gray value of the area around the pile points without calculating the average gray value corresponding to each pixel point, thereby greatly reducing the calculation amount of the binarization and increasing the binary value. Efficiency.
需要说明的是,本说明书实施例所提供方法的各步骤的执行主体均可以是同一设备,或者,该方法也由不同设备作为执行主体。比如,步骤S100和步骤S102的执行主体可以为设备1,步骤S102的执行主体可以为设备2;或者,步骤S100的执行主体可以为设备1,步骤S102和步骤S104的执行主体可以为设备2;等等。上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。It should be noted that the execution bodies of the steps of the method provided in the embodiments of the present specification may all be the same device, or the method may also be performed by different devices. For example, the execution body of step S100 and step S102 may be device 1, and the execution body of step S102 may be device 2; or the execution body of step S100 may be device 1, and the execution body of step S102 and step S104 may be device 2; and many more. The foregoing description of the specific embodiments of the specification has been described. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than the embodiments and still achieve the desired results. In addition, the processes depicted in the figures are not necessarily in a particular order or in a sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
另外,在现有图像二值化技术中,当待处理图像中包含二维码时,由于二维码也是二值化的点组成的图像,因此可能出现相邻的两个灰度值一致的像素点,计算的到的阈值不同的情况出现。而当两个像素点的灰度值与计算出来的阈值较为接近,则可能出现二值化效果不佳的问题。In addition, in the existing image binarization technique, when the two-dimensional code is included in the image to be processed, since the two-dimensional code is also an image composed of binarized dots, adjacent gray values may be identical. Pixels, where the calculated thresholds are different, occur. When the gray value of two pixels is close to the calculated threshold, the problem of poor binarization may occur.
图9为二值化中出现误判的情况示意图。其中,可见A点和B点的灰度值一致,但是对应周围3×3的区域计算平均灰度值时,确定出的阈值不同:分别为38和127,因此二值化后的结果不同,使得相同灰度值的两个像素点,一个调整为白色一个调整为黑色,二值化效果不佳。Fig. 9 is a diagram showing a situation in which misjudgment occurs in binarization. Among them, it can be seen that the gray values of point A and point B are identical, but when the average gray value is calculated corresponding to the surrounding area of 3×3, the determined threshold values are different: 38 and 127, respectively, so the results after binarization are different. The two pixels of the same gray value are adjusted to white and adjusted to black, and the binarization effect is not good.
而若采用本说明书提供的方法,当A点和B点距离最近的桩点为同一个桩点时,其二值化结果相同,要么全被调整为白色,要么全被调整为黑色,可提高对二维码的二值化效果。However, if the method provided in this manual is used, when the closest pile point between point A and point B is the same pile point, the binarization result is the same, either all is adjusted to white, or all is adjusted to black, which can be improved. The binarization effect on the two-dimensional code.
基于图2所示的图像处理的方法,本说明书实施例还提供一种图像处理的装置,如图10所示。Based on the method of image processing shown in FIG. 2, the embodiment of the present specification further provides an apparatus for image processing, as shown in FIG.
图10为本说明书实施例提供的一种图像处理的装置的结构示意图,所述装置包括:FIG. 10 is a schematic structural diagram of an apparatus for image processing according to an embodiment of the present disclosure, where the apparatus includes:
确定模块200,确定待处理图像;Determining module 200, determining an image to be processed;
等分模块202,根据所述待处理图像的尺寸,通过等分操作,确定标准高度以及标 准宽度;The halving module 202 determines the standard height and the standard width by halving according to the size of the image to be processed;
桩点定位模块204,以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵;The pile point positioning module 204 determines a standard height and a standard width as a pitch, and determines a matrix composed of a plurality of pile points in the image to be processed;
灰度计算模块206,针对每个桩点,确定该桩点周围指定面积的区域的平均灰度值,作为该桩点对应的灰度值;The grayscale calculation module 206 determines, for each pile point, an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point;
判断调整模块208,针对所述待处理图像中的每个像素点,确定距离该像素点最近的桩点,判断该像素点的灰度值是否小于确定出的桩点对应的灰度值,若是,则调整该像素点的灰度值为第一数值,若否,则调整该像素点的灰度值为第二数值。The determining adjustment module 208 is configured to determine, for each pixel point in the image to be processed, a pile point closest to the pixel point, and determine whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point, and if Then, the gray value of the pixel is adjusted to be a first value, and if not, the gray value of the pixel is adjusted to a second value.
所述等分模块202,确定所述待处理图像的高度和宽度,根据预设的数值,分别对所述待处理图像的高度和宽度进行等分计算,根据计算结果分别确定标准高度以及标准宽度。The halving module 202 determines the height and width of the image to be processed, and separately calculates the height and width of the image to be processed according to a preset value, and determines the standard height and the standard width according to the calculation result. .
所述等分模块202,当对所述待处理图像的高度进行等分计算的计算结果不是整数时,将计算结果向上取整数作为所述标准高度,当对所述待处理图像的宽度进行等分计算的计算结果不是整数时,将计算结果向上取整数作为所述标准宽度。The aliquoting module 202, when the calculation result of the aliquot calculation of the height of the image to be processed is not an integer, takes the calculation result up to an integer as the standard height, when the width of the image to be processed is performed, etc. When the calculation result of the sub-calculation is not an integer, the calculation result is taken up to the integer as the standard width.
所述桩点定位模块204,将所述待处理图像的任一顶点作为起始的桩点,以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵。The pile point positioning module 204 takes any vertex of the image to be processed as a starting pile point, determines a standard height and a standard width as a pitch, and determines that the pile to be processed is composed of a plurality of pile points. Matrix.
所述灰度计算模块206,以所述标准高度和所述标准宽度为边长,该桩点为中心点,确定该桩点周围的区域,计算该桩点周围的区域包含的各像素点的灰度值的平均值,作为该桩点对应的灰度值。The gray scale calculation module 206 uses the standard height and the standard width as the side length, the pile point is a center point, determines an area around the pile point, and calculates each pixel point included in the area around the pile point. The average value of the gray value is used as the gray value corresponding to the pile point.
所述灰度值为256级灰度值,所述第一数值为0,所述第二数值为255。The gray value is a 256-level gray value, the first value is 0, and the second value is 255.
所述判断调整模块208,当与该像素点的距离最近桩点存在多个时,选择任一一个距离该像素点最近的桩点。The determining adjustment module 208 selects any one of the pile points closest to the pixel point when there are a plurality of pile points closest to the pixel point.
基于图2所述的图像处理的方法,本说明书对应提供一种用于图像处理的设备,如图11所示,其中,所述设备包括:一个或多个处理器及存储器,存储器存储有程序,并且被配置成由一个或多个处理器执行以下步骤:Based on the method of image processing described in FIG. 2, the present specification correspondingly provides an apparatus for image processing, as shown in FIG. 11, wherein the apparatus includes: one or more processors and a memory, and the memory stores a program. And configured to perform the following steps by one or more processors:
确定待处理图像;Determining the image to be processed;
根据所述待处理图像的尺寸,通过等分操作,确定标准高度以及标准宽度;Determining a standard height and a standard width by halving according to the size of the image to be processed;
以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点 组成的矩阵;Determining a standard height and a standard width as a pitch, and determining a matrix consisting of a plurality of pile points in the image to be processed;
针对每个桩点,确定该桩点周围指定面积的区域的平均灰度值,作为该桩点对应的灰度值;For each pile point, determining an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point;
针对所述待处理图像中的每个像素点,确定距离该像素点最近的桩点,判断该像素点的灰度值是否小于确定出的桩点对应的灰度值;Determining, according to each pixel point in the image to be processed, a pile point closest to the pixel point, determining whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point;
若是,则调整该像素点的灰度值为第一数值;If yes, adjusting the gray value of the pixel to a first value;
若否,则调整该像素点的灰度值为第二数值。If not, adjust the gray value of the pixel to a second value.
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, improvements to a technology could clearly distinguish between hardware improvements (eg, improvements to circuit structures such as diodes, transistors, switches, etc.) or software improvements (for process flow improvements). However, as technology advances, many of today's method flow improvements can be seen as direct improvements in hardware circuit architecture. Designers almost always get the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented by hardware entity modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is an integrated circuit whose logic function is determined by the user programming the device. Designers program themselves to "integrate" a digital system on a single PLD without having to ask the chip manufacturer to design and fabricate a dedicated integrated circuit chip. Moreover, today, instead of manually making integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in programming development, but before compiling The original code has to be written in a specific programming language. This is called the Hardware Description Language (HDL). HDL is not the only one, but there are many kinds, such as ABEL (Advanced Boolean Expression Language). AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., are currently the most commonly used VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. It should also be apparent to those skilled in the art that the hardware flow for implementing the logic method flow can be easily obtained by simply programming the method flow into the integrated circuit with a few hardware description languages.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、 可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller can be implemented in any suitable manner, for example, the controller can take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor. In the form of logic gates, switches, application specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers, examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, The Microchip PIC18F26K20 and the Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic. Those skilled in the art will also appreciate that in addition to implementing the controller in purely computer readable program code, the controller can be logically programmed by means of logic gates, switches, ASICs, programmable logic controllers, and embedding. The form of a microcontroller or the like to achieve the same function. Such a controller can therefore be considered a hardware component, and the means for implementing various functions included therein can also be considered as a structure within the hardware component. Or even a device for implementing various functions can be considered as a software module that can be both a method of implementation and a structure within a hardware component.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The system, device, module or unit illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product having a certain function. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or A combination of any of these devices.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本申请时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, the above devices are described separately by function into various units. Of course, the functions of each unit may be implemented in the same software or software and/or hardware when implementing the present application.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions specified in one or more of the flow or in a block or blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框 或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。The memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory. Memory is an example of a computer readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer readable media includes both permanent and non-persistent, removable and non-removable media. Information storage can be implemented by any method or technology. The information can be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transportable media can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary storage of computer readable media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It is also to be understood that the terms "comprises" or "comprising" or "comprising" or any other variations are intended to encompass a non-exclusive inclusion, such that a process, method, article, Other elements not explicitly listed, or elements that are inherent to such a process, method, commodity, or equipment. An element defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device including the element.
本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present application can be provided as a method, system, or computer program product. Thus, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment in combination of software and hardware. Moreover, the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
本申请可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本申请,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。The application can be described in the general context of computer-executable instructions executed by a computer, such as a program module. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types. The present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are connected through a communication network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。The various embodiments in the specification are described in a progressive manner, and the same or similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The above description is only an embodiment of the present application and is not intended to limit the application. Various changes and modifications can be made to the present application by those skilled in the art. Any modifications, equivalents, improvements, etc. made within the spirit and scope of the present application are intended to be included within the scope of the appended claims.

Claims (15)

  1. 一种图像处理的方法,包括:A method of image processing, comprising:
    确定待处理图像;Determining the image to be processed;
    根据所述待处理图像的尺寸,通过等分操作,确定标准高度以及标准宽度;Determining a standard height and a standard width by halving according to the size of the image to be processed;
    以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵;Determining a standard height and a standard width as a pitch, and determining a matrix consisting of a plurality of pile points in the image to be processed;
    针对每个桩点,确定该桩点周围指定面积的区域的平均灰度值,作为该桩点对应的灰度值;For each pile point, determining an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point;
    针对所述待处理图像中的每个像素点,确定距离该像素点最近的桩点,判断该像素点的灰度值是否小于确定出的桩点对应的灰度值;Determining, according to each pixel point in the image to be processed, a pile point closest to the pixel point, determining whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point;
    若是,则调整该像素点的灰度值为第一数值;If yes, adjusting the gray value of the pixel to a first value;
    若否,则调整该像素点的灰度值为第二数值。If not, adjust the gray value of the pixel to a second value.
  2. 如权利要求1所述的方法,根据所述待处理图像的尺寸,通过等分操作,确定标准高度以及标准宽度,具体包括:The method according to claim 1, wherein the standard height and the standard width are determined by an aliquot operation according to the size of the image to be processed, and specifically includes:
    确定所述待处理图像的高度和宽度;Determining a height and a width of the image to be processed;
    根据预设的数值,分别对所述待处理图像的高度和宽度进行等分计算,根据计算结果分别确定标准高度以及标准宽度。According to the preset value, the height and the width of the image to be processed are respectively equally calculated, and the standard height and the standard width are respectively determined according to the calculation result.
  3. 如权利要求2所述的方法,根据计算结果分别确定标准高度以及标准宽度,具体包括:The method according to claim 2, wherein the standard height and the standard width are respectively determined according to the calculation result, and specifically includes:
    当对所述待处理图像的高度进行等分计算的计算结果不是整数时,将计算结果向上取整数作为所述标准高度;When the calculation result of the aliquot calculation of the height of the image to be processed is not an integer, the calculation result is taken up to an integer as the standard height;
    当对所述待处理图像的宽度进行等分计算的计算结果不是整数时,将计算结果向上取整数作为所述标准宽度。When the calculation result of the aliquot calculation of the width of the image to be processed is not an integer, the calculation result is taken up to an integer as the standard width.
  4. 如权利要求1所述的方法,以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵,具体包括:The method of claim 1, wherein the determined standard height and the standard width are spaces, and determining a matrix consisting of a plurality of pile points in the image to be processed includes:
    将所述待处理图像的任一顶点作为起始的桩点,以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵。Taking any vertex of the image to be processed as a starting pile point, determining a standard height and a standard width as a pitch, and determining a matrix composed of a plurality of pile points in the image to be processed.
  5. 如权利要求1所述的方法,确定该桩点周围指定面积的区域的平均灰度值,作为该桩点对应的灰度值,具体包括:The method of claim 1, determining an average gray value of the area of the designated area around the pile point, as the gray value corresponding to the pile point, specifically comprising:
    以所述标准高度和所述标准宽度为边长,该桩点为中心点,确定该桩点周围的区域;The standard height and the standard width are side lengths, and the pile point is a center point, and an area around the pile point is determined;
    计算该桩点周围的区域包含的各像素点的灰度值的平均值,作为该桩点对应的灰度 值。The average value of the gradation values of the respective pixel points included in the area around the pile point is calculated as the gradation value corresponding to the pile point.
  6. 如权利要求1所述的方法,所述灰度值为256级灰度值,所述第一数值为0,所述第二数值为255。The method of claim 1 wherein said gray value is a 256 level gray value, said first value being zero and said second value being 255.
  7. 如权利要求1所述的方法,确定距离该像素点最近的桩点,具体包括:The method of claim 1, determining a pile point closest to the pixel point, specifically comprising:
    当与该像素点的距离最近桩点存在多个时,选择任一一个距离该像素点最近的桩点。When there are multiple pile points closest to the pixel point, select any one of the pile points closest to the pixel point.
  8. 一种图像处理的装置,包括:An image processing apparatus comprising:
    确定模块,确定待处理图像;Determining a module to determine an image to be processed;
    等分模块,根据所述待处理图像的尺寸,通过等分操作,确定标准高度以及标准宽度;An aliquoting module determines the standard height and the standard width by halving according to the size of the image to be processed;
    桩点定位模块,以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵;a pile positioning module to determine a standard height and a standard width as a spacing, and determine a matrix consisting of a plurality of pile points in the image to be processed;
    灰度计算模块,针对每个桩点,确定该桩点周围指定面积的区域的平均灰度值,作为该桩点对应的灰度值;a gray scale calculation module, for each pile point, determining an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point;
    判断调整模块,针对所述待处理图像中的每个像素点,确定距离该像素点最近的桩点,判断该像素点的灰度值是否小于确定出的桩点对应的灰度值,若是,则调整该像素点的灰度值为第一数值,若否,则调整该像素点的灰度值为第二数值。The determining adjustment module determines, for each pixel point in the image to be processed, a pile point closest to the pixel point, and determines whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point, and if so, Then, the gray value of the pixel is adjusted to be a first value, and if not, the gray value of the pixel is adjusted to a second value.
  9. 如权利要求8所述的装置,所述等分模块,确定所述待处理图像的高度和宽度,根据预设的数值,分别对所述待处理图像的高度和宽度进行等分计算,根据计算结果分别确定标准高度以及标准宽度。The apparatus according to claim 8, wherein the halving module determines a height and a width of the image to be processed, and separately calculates an altitude of the image to be processed according to a preset value, according to the calculation The results determine the standard height and the standard width, respectively.
  10. 如权利要求9所述的装置,所述等分模块,当对所述待处理图像的高度进行等分计算的计算结果不是整数时,将计算结果向上取整数作为所述标准高度,当对所述待处理图像的宽度进行等分计算的计算结果不是整数时,将计算结果向上取整数作为所述标准宽度。The apparatus according to claim 9, wherein the halving module, when the calculation result of the aliquot calculation of the height of the image to be processed is not an integer, takes the calculation result up to an integer as the standard height, when When the calculation result of the width of the image to be processed is not an integer, the calculation result is taken up as an integer.
  11. 如权利要求8所述的装置,所述桩点定位模块,将所述待处理图像的任一顶点作为起始的桩点,以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵。The apparatus according to claim 8, wherein the pile positioning module uses any vertex of the image to be processed as a starting pile point to determine a standard height and a standard width as a pitch, in the to-be-processed A matrix consisting of several pile points is determined in the image.
  12. 如权利要求8所述的装置,所述灰度计算模块,以所述标准高度和所述标准宽度为边长,该桩点为中心点,确定该桩点周围的区域,计算该桩点周围的区域包含的各像素点的灰度值的平均值,作为该桩点对应的灰度值。The apparatus according to claim 8, wherein the gradation calculation module defines the area around the pile point by using the standard height and the standard width as a side length, and calculating the area around the pile point. The average value of the gray value of each pixel included in the area is used as the gray value corresponding to the pile point.
  13. 如权利要求8所述的装置,所述灰度值为256级灰度值,所述第一数值为0,所述第二数值为255。The apparatus of claim 8, said gray value being a 256-level gray value, said first value being 0, and said second value being 255.
  14. 如权利要求8所述的装置,所述判断调整模块,当与该像素点的距离最近桩点存在多个时,选择任一一个距离该像素点最近的桩点。The apparatus according to claim 8, wherein the judgment adjustment module selects any one of the pile points closest to the pixel point when there are a plurality of pile points closest to the pixel point.
  15. 一种用于图像处理的设备,其中,所述设备包括:一个或多个处理器及存储器,存储器存储有程序,并且被配置成由一个或多个处理器执行以下步骤:An apparatus for image processing, wherein the apparatus comprises: one or more processors and a memory, the memory storing a program, and being configured to perform the following steps by one or more processors:
    确定待处理图像;Determining the image to be processed;
    根据所述待处理图像的尺寸,通过等分操作,确定标准高度以及标准宽度;Determining a standard height and a standard width by halving according to the size of the image to be processed;
    以确定出的标准高度以及标准宽度为间距,在所述待处理图像中确定由若干桩点组成的矩阵;Determining a standard height and a standard width as a pitch, and determining a matrix consisting of a plurality of pile points in the image to be processed;
    针对每个桩点,确定该桩点周围指定面积的区域的平均灰度值,作为该桩点对应的灰度值;For each pile point, determining an average gray value of a region of a specified area around the pile point as a gray value corresponding to the pile point;
    针对所述待处理图像中的每个像素点,确定距离该像素点最近的桩点,判断该像素点的灰度值是否小于确定出的桩点对应的灰度值;Determining, according to each pixel point in the image to be processed, a pile point closest to the pixel point, determining whether the gray value of the pixel point is smaller than a gray value corresponding to the determined pile point;
    若是,则调整该像素点的灰度值为第一数值;If yes, adjusting the gray value of the pixel to a first value;
    若否,则调整该像素点的灰度值为第二数值。If not, adjust the gray value of the pixel to a second value.
PCT/CN2019/073831 2018-04-10 2019-01-30 Image processing method and apparatus WO2019196542A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810314751.9A CN108846399A (en) 2018-04-10 2018-04-10 A kind of method and device of image procossing
CN201810314751.9 2018-04-10

Publications (1)

Publication Number Publication Date
WO2019196542A1 true WO2019196542A1 (en) 2019-10-17

Family

ID=64211982

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/073831 WO2019196542A1 (en) 2018-04-10 2019-01-30 Image processing method and apparatus

Country Status (3)

Country Link
CN (1) CN108846399A (en)
TW (1) TWI694381B (en)
WO (1) WO2019196542A1 (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110929664A (en) * 2019-11-29 2020-03-27 汉海信息技术(上海)有限公司 Image recognition method and device
CN111539962A (en) * 2020-01-10 2020-08-14 济南浪潮高新科技投资发展有限公司 Target image classification method, device and medium
CN111583157A (en) * 2020-05-13 2020-08-25 杭州睿琪软件有限公司 Image processing method, system and computer readable storage medium
CN111882565A (en) * 2020-07-28 2020-11-03 深圳市雨滴科技有限公司 Image binarization method, device, equipment and storage medium
CN112150391A (en) * 2020-09-30 2020-12-29 小狗电器互联网科技(北京)股份有限公司 Image denoising method and device, readable medium and electronic equipment
CN112750116A (en) * 2021-01-15 2021-05-04 北京市商汤科技开发有限公司 Defect detection method and device, computer equipment and storage medium
CN116342590A (en) * 2023-05-24 2023-06-27 合肥晶合集成电路股份有限公司 Method and device for detecting wafer test needle mark
CN117036175A (en) * 2023-10-08 2023-11-10 之江实验室 Linear array image splicing method, device, medium and equipment

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108846399A (en) * 2018-04-10 2018-11-20 阿里巴巴集团控股有限公司 A kind of method and device of image procossing
CN111626970B (en) * 2020-05-25 2022-11-01 天津维创微智能科技有限公司 Image binarization processing method, device, equipment and storage medium
CN113139399B (en) * 2021-05-13 2024-04-12 阳光电源股份有限公司 Image wire frame identification method and server

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103235948A (en) * 2013-04-22 2013-08-07 中山大学 Adaptive threshold binarization method for two-dimensional barcode
CN107688812A (en) * 2017-08-25 2018-02-13 重庆慧都科技有限公司 A kind of food production date ink-jet font restorative procedure based on machine vision
CN108846399A (en) * 2018-04-10 2018-11-20 阿里巴巴集团控股有限公司 A kind of method and device of image procossing

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070047790A1 (en) * 2005-08-30 2007-03-01 Agfa-Gevaert N.V. Method of Segmenting Anatomic Entities in Digital Medical Images
US8311306B2 (en) * 2008-04-30 2012-11-13 Otismed Corporation System and method for image segmentation in generating computer models of a joint to undergo arthroplasty
WO2015082332A1 (en) * 2013-12-02 2015-06-11 Leonhard Kurz Stiftung & Co. Kg Method for authenticating a security element, and optically variable security element
JP2016070800A (en) * 2014-09-30 2016-05-09 株式会社Screenホールディングス Observation support device, observation support method and program

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103235948A (en) * 2013-04-22 2013-08-07 中山大学 Adaptive threshold binarization method for two-dimensional barcode
CN107688812A (en) * 2017-08-25 2018-02-13 重庆慧都科技有限公司 A kind of food production date ink-jet font restorative procedure based on machine vision
CN108846399A (en) * 2018-04-10 2018-11-20 阿里巴巴集团控股有限公司 A kind of method and device of image procossing

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
MU, YANGQIU: "Research on Binary Code Binarization and Location Algorithm", INFORMATION & TECHNOLOGY CHINA MASTER'S, vol. 2013, no. 9, 15 September 2013 (2013-09-15) *

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110929664A (en) * 2019-11-29 2020-03-27 汉海信息技术(上海)有限公司 Image recognition method and device
CN110929664B (en) * 2019-11-29 2023-05-30 汉海信息技术(上海)有限公司 Image recognition method and device
CN111539962A (en) * 2020-01-10 2020-08-14 济南浪潮高新科技投资发展有限公司 Target image classification method, device and medium
CN111583157A (en) * 2020-05-13 2020-08-25 杭州睿琪软件有限公司 Image processing method, system and computer readable storage medium
CN111583157B (en) * 2020-05-13 2023-06-02 杭州睿琪软件有限公司 Image processing method, system and computer readable storage medium
CN111882565A (en) * 2020-07-28 2020-11-03 深圳市雨滴科技有限公司 Image binarization method, device, equipment and storage medium
CN112150391B (en) * 2020-09-30 2022-11-29 北京小狗吸尘器集团股份有限公司 Image denoising method and device, readable medium and electronic equipment
CN112150391A (en) * 2020-09-30 2020-12-29 小狗电器互联网科技(北京)股份有限公司 Image denoising method and device, readable medium and electronic equipment
CN112750116A (en) * 2021-01-15 2021-05-04 北京市商汤科技开发有限公司 Defect detection method and device, computer equipment and storage medium
CN112750116B (en) * 2021-01-15 2023-08-11 北京市商汤科技开发有限公司 Defect detection method, device, computer equipment and storage medium
CN116342590A (en) * 2023-05-24 2023-06-27 合肥晶合集成电路股份有限公司 Method and device for detecting wafer test needle mark
CN116342590B (en) * 2023-05-24 2023-11-03 合肥晶合集成电路股份有限公司 Method and device for detecting wafer test needle mark
CN117036175A (en) * 2023-10-08 2023-11-10 之江实验室 Linear array image splicing method, device, medium and equipment
CN117036175B (en) * 2023-10-08 2024-01-09 之江实验室 Linear array image splicing method, device, medium and equipment

Also Published As

Publication number Publication date
TWI694381B (en) 2020-05-21
CN108846399A (en) 2018-11-20
TW202001674A (en) 2020-01-01

Similar Documents

Publication Publication Date Title
WO2019196542A1 (en) Image processing method and apparatus
EP3605398B1 (en) Method and device for generating and identifying identification code
TWI740087B (en) Two-dimensional code reading method, device and equipment
US9305360B2 (en) Method and apparatus for image enhancement and edge verification using at least one additional image
KR102146215B1 (en) QR code positioning method and device
US20140247979A1 (en) Method and device for generating high dynamic range images
TWI690853B (en) Image recognition method, device and equipment
US11875486B2 (en) Image brightness statistical method and imaging device
WO2017067416A1 (en) Method of storing image in texture memory
CN111079793A (en) Icon similarity determining method and electronic equipment
CN111598088B (en) Target detection method, device, computer equipment and readable storage medium
CN111160242A (en) Image target detection method, system, electronic terminal and storage medium
CN110956608A (en) Remaining foodstuff detection method, device, electronic equipment and storage medium
CN111563517A (en) Image processing method, image processing device, electronic equipment and storage medium
WO2021046793A1 (en) Image acquisition method and apparatus, and storage medium
CN113506305A (en) Image enhancement method, semantic segmentation method and device for three-dimensional point cloud data
CN116342888B (en) Method and device for training segmentation model based on sparse labeling
CN115984154A (en) Image fusion method and device, storage medium and electronic equipment
TW201939346A (en) Method, apparatus, and device for recognizing bar code
CN110659343B (en) Geofence data extraction method, device and equipment
US20190180417A1 (en) Smoothed image generating device, abnormality determining device, and smoothed image generating method
CN116740114B (en) Object boundary fitting method and device based on convex hull detection
CN116363390B (en) Infrared dim target detection method and device, storage medium and electronic equipment
CN110276720B (en) Image generation method and device
CN113640823B (en) Method and device for map drawing based on laser reflectivity base map

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: 19784354

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: 19784354

Country of ref document: EP

Kind code of ref document: A1