CN116709020A - Focusing method and device based on Sobel operator - Google Patents

Focusing method and device based on Sobel operator Download PDF

Info

Publication number
CN116709020A
CN116709020A CN202310672466.5A CN202310672466A CN116709020A CN 116709020 A CN116709020 A CN 116709020A CN 202310672466 A CN202310672466 A CN 202310672466A CN 116709020 A CN116709020 A CN 116709020A
Authority
CN
China
Prior art keywords
detected
region
weighted average
order intensity
pixel point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310672466.5A
Other languages
Chinese (zh)
Inventor
彭瑞豪
杨盛
彭振伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Shimai Digital Technology Co ltd
Original Assignee
Shanghai Shimai Digital Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Shimai Digital Technology Co ltd filed Critical Shanghai Shimai Digital Technology Co ltd
Priority to CN202310672466.5A priority Critical patent/CN116709020A/en
Publication of CN116709020A publication Critical patent/CN116709020A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G03PHOTOGRAPHY; CINEMATOGRAPHY; ANALOGOUS TECHNIQUES USING WAVES OTHER THAN OPTICAL WAVES; ELECTROGRAPHY; HOLOGRAPHY
    • G03BAPPARATUS OR ARRANGEMENTS FOR TAKING PHOTOGRAPHS OR FOR PROJECTING OR VIEWING THEM; APPARATUS OR ARRANGEMENTS EMPLOYING ANALOGOUS TECHNIQUES USING WAVES OTHER THAN OPTICAL WAVES; ACCESSORIES THEREFOR
    • G03B13/00Viewfinders; Focusing aids for cameras; Means for focusing for cameras; Autofocus systems for cameras
    • G03B13/32Means for focusing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/15Correlation function computation including computation of convolution operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/18Complex mathematical operations for evaluating statistical data, e.g. average values, frequency distributions, probability functions, regression analysis
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/67Focus control based on electronic image sensor signals
    • H04N23/673Focus control based on electronic image sensor signals based on contrast or high frequency components of image signals, e.g. hill climbing method

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Mathematical Physics (AREA)
  • General Engineering & Computer Science (AREA)
  • Algebra (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Signal Processing (AREA)
  • Multimedia (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Biology (AREA)
  • Operations Research (AREA)
  • Probability & Statistics with Applications (AREA)
  • Automatic Focus Adjustment (AREA)

Abstract

The application aims to provide a focusing method and device based on a Sobel operator, wherein the method and device acquire an object image and RGB values of all pixel points in the object image through a focusing lens module and respectively convert the RGB values of each pixel point into brightness values; selecting at least one region to be detected in the target image, and respectively convolving the brightness value of each pixel point in the region to be detected with a Sobel operator to obtain first-order intensity of each pixel point; calculating to obtain a first-order intensity weighted average value of the region to be detected based on the first-order intensities of all the pixel points in the region to be detected; if the first-order intensity weighted average value exceeds a preset weighted average threshold value, the focusing of the lens module is determined to be qualified, the data processing is simple and convenient, the definition of the finally qualified lens module is high, and the manpower and material resources are saved.

Description

Focusing method and device based on Sobel operator
Technical Field
The application relates to the technical field of computers, in particular to a focusing method and device based on a Sobel operator.
Background
In the prior art, in order to make a recorder shoot an accurate image, it is generally required to determine whether a lens module of the recorder is in focus, and a conventional focus checking means mainly uses an MTF (Modulation Transfer Function ) algorithm, specifically, an MTF calculation software principle and a calculation formula are as follows:
the MTF is used to automatically reflect the contrast and resolving power of the lens module, and the difference between the brightest white line and the darkest black line in the black-and-white stripe to be measured reflects the contrast (or referred to as contrast) of the pattern to be measured. Let white line maximum luminance be lmax, black line minimum luminance be lmin, and the contrast size be expressed by a Modulation degree (Modulation), the Modulation degree M being defined as: m= (max-lmin)/(lmax+lmin); also, the contrast of the imaged pattern, i.e., the contrast, is reflected by the difference between the brightest white line and the darkest black line imaged by the lens. Let white line maximum brightness/max, black line minimum brightness 1 min. Modulation M is defined as: m= (1 x max-l min)/(l x max+l min), if the modulation M of the original image and the modulation M of the imaging after lens pass, the MTF value is: mtf=m×m.
M can be assumed to be ideal: black and white lines on char, when lmax=1.0 and lmin=0.0, m= (1.0-0.0)/(1.0+0.0) =1.0, mtf=m/m=m/1.0=m= (1×max-l×min)/(l×max+l×min), l×max is the maximum white line brightness, l×min is the minimum black line brightness, i.e., MTF is calculated by lens imaging pattern black and white line modulation m×min.
Specifically, as shown in fig. 1, the MTF algorithm graph in different black and white stripes in the prior art is shown, where when the line width is wider, the resolution is not very sensitive, so that the chart with smaller line width is replaced with the resolution that is more sensitive, which is very inconvenient, and it is difficult to distinguish the clear and unclear boundaries. Meanwhile, the conventional isp (Image Signal Processing ) process is actually edge detection to increase sharpening, and different edge intensities give different sharpening enhancements.
Disclosure of Invention
The application aims to provide a focusing method and device based on a Sobel operator, which solve the problems of insensitivity and low definition of an MTF algorithm and realize that a lens module can be quickly and accurately focused and inspected by the Sobel operator.
According to an aspect of the present application, there is provided a focusing method based on a sobel operator, wherein the method includes:
obtaining an object image and RGB values of all pixel points in the object image through a focusing lens module, and respectively converting the RGB values of each pixel point into brightness values;
selecting at least one region to be detected in the target image, and respectively convolving the brightness value of each pixel point in the region to be detected with a Sobel operator to obtain first-order intensity of each pixel point;
calculating to obtain a first-order intensity weighted average value of the region to be detected based on the first-order intensities of all the pixel points in the region to be detected;
and if the first-order intensity weighted average value exceeds a preset weighted average threshold value, determining that the focusing of the lens module is qualified.
Further, in the above method, the convolving the brightness value of each pixel point in the to-be-detected area with the sobel operator to obtain the first-order intensity of each pixel point includes:
respectively carrying out convolution on the brightness value of each pixel point in the region to be detected and the Sobel operator in the x-axis direction to obtain first-order intensity of each pixel point in the x-axis direction;
respectively carrying out convolution on the brightness value of each pixel point in the region to be detected and the Sobel operator in the y-axis direction to obtain first-order intensity of each pixel point in the y-axis direction;
and obtaining the first-order intensity of each pixel point based on the first-order intensity of the x direction and the first-order intensity of the y direction of each pixel point.
Further, in the above method, the calculating, based on the first-order intensities of all the pixel points in the to-be-detected area, a weighted average of the first-order intensities of the to-be-detected area includes:
selecting a preset number of pixels from all the pixels in the region to be detected according to the order of the first-order intensity of the pixels from high to low;
carrying out weighted average calculation on the first-order intensity of the preset number of pixel points in the x direction to obtain a first-order intensity weighted average of the region to be detected in the x direction;
carrying out weighted average calculation on the first-order intensity of the preset number of pixel points in the x direction to obtain a first-order intensity weighted average of the region to be detected in the y direction;
and averaging the first-order intensity weighted average value of the region to be detected in the x direction and the first-order intensity weighted average value of the region to be detected in the y direction to obtain the first-order intensity weighted average value of the region to be detected.
Further, in the above method, the focusing method based on the sobel operator further includes:
acquiring a verification image through a lens module with qualified focusing, and calculating a first-order intensity weighted average value of the verification image;
and updating the preset weighted average threshold value to be a first-order intensity weighted average value of the verification image.
According to another aspect of the present application, there is also provided a non-volatile storage medium having stored thereon computer readable instructions which, when executed by a processor, cause the processor to implement a focusing method based on the sobel operator as described above.
According to another aspect of the present application, there is also provided a focusing apparatus based on a sobel operator, wherein the apparatus includes:
one or more processors;
a computer readable medium for storing one or more computer readable instructions,
the one or more computer-readable instructions, when executed by the one or more processors, cause the one or more processors to implement a sobel operator based focusing method as described above.
Compared with the prior art, the application obtains the target image and the RGB values of all the pixel points in the target image through the focusing lens module, and converts the RGB value of each pixel point into a brightness value respectively; selecting at least one region to be detected in the target image, and respectively convolving the brightness value of each pixel point in the region to be detected with a Sobel operator to obtain first-order intensity of each pixel point; calculating to obtain a first-order intensity weighted average value of the region to be detected based on the first-order intensities of all the pixel points in the region to be detected; if the first-order intensity weighted average value exceeds a preset weighted average threshold value, the focusing of the lens module is determined to be qualified, the data processing of the RGB values of the pixel points is realized, the first-order intensity weighted average value of the pixel points in the region to be detected is extracted based on the Sobel operator, the lens module corresponding to the target image qualified in focusing is accurately obtained when the lens module is dynamically adjusted, the operation is quick and convenient, the data processing is simple and convenient, the definition of the finally qualified lens module is high, and the manpower and material resources are saved.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the accompanying drawings in which:
FIG. 1 shows a graph of MTF algorithm in different black and white stripes in the prior art;
fig. 2 illustrates a flow diagram of a sobel operator-based focusing method according to an aspect of the present application.
The same or similar reference numbers in the drawings refer to the same or similar parts.
Detailed Description
The application is described in further detail below with reference to the accompanying drawings.
In one exemplary configuration of the application, the terminal, the device of the service network, and the trusted party each include one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer 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 disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer readable media, as defined herein, does not include non-transitory computer readable media (transmission media), such as modulated data signals and carrier waves.
As shown in fig. 1, one aspect of the present application proposes a flow chart of a focusing method based on a sobel operator, where the method includes steps S11, S12, S13 and S14, and specifically includes the following steps:
step S11, obtaining an object image and RGB values of all pixel points in the object image through a focusing lens module, and respectively converting the RGB values of each pixel point into brightness values; here, each pixel point has not only a corresponding RGB value, but also a corresponding three-channel value (i.e., a Y value, a U value, and a V value), where the Y value is the brightness value representing brightness of an image, reflecting a gray scale value of the image, and specifically, in an actual application scenario of the present application, a calculation formula of the brightness value is as follows:
Y=0.2990R+0.5870G+0.1140B;
wherein Y is a brightness value, R is an R value in RGB data, G is a G value in RGB data and B is a B value in RGB data, so that the RGB data conversion processing operation is simple and convenient, and the brightness domain calculation in three channel values is only performed, the brightness value calculation with small error and high precision on a dynamically acquired target image is realized, the effective data information in the three-color values of the pixel point is extracted at high efficiency, and the preparation is made for the subsequent data processing.
Step S12, selecting at least one region to be detected in the target image, and respectively convolving the brightness value of each pixel point in the region to be detected with a Sobel operator to obtain first-order intensity of each pixel point; here, the Sobel operator (Sobel operator) is mainly used to obtain a first-order gradient of a digital image; the region to be detected can be selected according to a computer algorithm, wherein the region to be detected is a region determined according to actual requirements, the region to be detected is high in selectivity, wide in applicability in application scenes, and each pixel point in the region to be detected is convolved by utilizing a Sobel operator, so that targeted pixel point convolution is completed, and resource waste is avoided.
Step S13, calculating to obtain a first-order intensity weighted average value of the region to be detected based on the first-order intensities of all the pixel points in the region to be detected; when the first-order intensity weighted average value is calculated, the first-order intensities of the pixel points are arranged in sequence from high to low, and then the pixel points with a preset number are evaluated, so that the accuracy of the first-order intensity weighted average value of the region to be detected is improved, and the sensitivity is enhanced.
Step S14, if the first-order intensity weighted average exceeds a preset weighted average threshold, determining that the focusing of the lens module is qualified.
Through the steps S11 to S14, the rapid and clear brightness value calculation is performed on each pixel point in the dynamic acquisition target image, and then the first-order intensity weighted average value of the region to be detected is obtained with high sensitivity based on the Sobel operator, so that the simple, clear and efficient qualified lens module is finally obtained, and the problems of low definition and insensitivity caused by the MTF algorithm are effectively avoided.
In a preferred embodiment of the present application, a target image 1 is obtained through a focusing lens module, RGB values corresponding to all pixels in the target image 1 are obtained, and a brightness value calculation formula is utilized: y=0.2990r+0.5870g+0.1140b to obtain brightness values of the pixels; the method comprises the steps that an area 11 to be detected is set and selected in a target image 1 through a computer algorithm, and the brightness value of a pixel 111, the brightness value of a pixel 112, … …, the brightness value of a pixel (11 (n-1)) and the brightness value of a pixel (11 n) in the area 11 to be detected are respectively convolved with a Sobel operator to respectively obtain first-order intensity of the pixel 111, first-order intensity of the pixel 112, … …, first-order intensity of the pixel (11 (n-1)) and first-order intensity of the pixel (11 n); according to N pixel points in the region 11 to be detected and corresponding first-order intensity values thereof, obtaining N of the N pixel points from high to low for weighted average, and calculating to obtain a first-order intensity weighted average value N of the region 11 to be detected; when the first-order intensity weighted average N of the to-be-detected area 11 exceeds the preset weighted average threshold, the lens module corresponding to the to-be-detected area 11 is a qualified lens module.
Meanwhile, in an actual application scene, after the qualified lens module is obtained, the qualified lens module is subjected to focus checking, and the steps from the step S11 to the step S14 are also used for judging whether the area to be detected obtained by the qualified lens module is still qualified or not, so that the certainty of the qualified lens module is improved.
In the above embodiment of the present application, in the step S12, the convolution is performed on the brightness value of each pixel point in the to-be-detected area and the sobel operator to obtain the first-order intensity of each pixel point, including:
respectively carrying out convolution on the brightness value of each pixel point in the region to be detected and the Sobel operator in the x-axis direction to obtain first-order intensity of each pixel point in the x-axis direction;
respectively carrying out convolution on the brightness value of each pixel point in the region to be detected and the Sobel operator in the y-axis direction to obtain first-order intensity of each pixel point in the y-axis direction;
the first-order intensity of each pixel point is obtained based on the first-order intensity of the x direction and the first-order intensity of the y direction of each pixel point, the brightness value of the pixel point is directly convolved with the Sobel operator, calculation is carried out by utilizing different algorithms of the Sobel operator in the x-axis direction and the y-axis direction, and the calculation accuracy of the final first-order intensity value of each pixel point is improved.
In a preferred embodiment of the present application, the RGB values corresponding to the target image 1 and all the pixels in the target image 1 are obtained, and the brightness value corresponding to each pixel is obtained; selecting a region to be detected 11 in the target image 1, wherein the luminance value 1 of the pixel point 111, the luminance values 2 and … … of the pixel point 112, the luminance value (n-1) of the pixel point (11 (n-1)) and the luminance value n of the pixel point (11 n) in the region to be detected 11; convolving the brightness value 1 of the pixel 111 with the sobel operator in the x-axis direction to obtain a first-order intensity value of the pixel 111, convolving the brightness value 1 of the pixel 111 with the sobel operator in the y-axis direction to obtain a first-order intensity value of the pixel 111, and convolving the first-order intensity value 1 of the pixel based on the first-order intensity value of the pixel 111 in the x-axis direction and the first-order intensity value of the pixel 111 in the y-axis direction; similarly, the first-order intensity values in the x direction and the first-order intensity values in the y direction are calculated for the pixel points 112 and … …, the pixel point (11 (n-1)) and the pixel point (11 n), respectively, and the corresponding first-order intensity values are obtained based on the first-order intensity values in the x direction and the first-order intensity values in the y direction of each pixel point, that is, the first-order intensity value 2 of the pixel point 112, the first-order intensity values 3 and … … of the pixel point 113, the first-order intensity value (n-1) of the pixel point (11 (n-1)) and the first-order intensity value n of the pixel point (11 n) are obtained, and the calculation of the first-order intensity values of all the pixel points in the region to be detected 11 is completed.
Next, in the above embodiment of the present application, the step S13 calculates a weighted average of first-order intensities of the to-be-detected area based on the first-order intensities of all the pixel points in the to-be-detected area, including:
selecting a preset number of pixels from all the pixels in the region to be detected according to the order of the first-order intensity of the pixels from high to low; the number of specifically selected pixels in the to-be-detected area is determined by the requirement of the actual application scene, and when the number of the selected pixels is smaller, the first-order strength of the to-be-detected area is finally obtained to be more standard, and meanwhile, in the actual application scene, the number of the preset number of pixels can be selected and set in the process of selecting/setting the to-be-detected area.
Carrying out weighted average calculation on the first-order intensity of the preset number of pixel points in the x direction to obtain a first-order intensity weighted average of the region to be detected in the x direction;
carrying out weighted average calculation on the first-order intensity of the preset number of pixel points in the x direction to obtain a first-order intensity weighted average of the region to be detected in the y direction;
and averaging the first-order intensity weighted average value of the region to be detected in the x direction and the first-order intensity weighted average value of the region to be detected in the y direction to obtain the first-order intensity weighted average value of the region to be detected, screening the data with high first-order intensity, carrying out weighted average on the data with high first-order intensity in the x direction and the y direction, obtaining the first-order intensity weighted average value finally representing the region to be detected, and carrying out data processing in two directions to ensure that the data has higher accuracy and representativeness.
For example, an area to be detected (m pixels in total in the area) is set in the target image, the definition of n blocks is expected to be calculated, the brightness value of each pixel in the area to be detected is calculated through a computer algorithm, then the brightness value of each pixel and an x-direction Sobel operator are convolved, the first-order intensity of the pixel 1 in the x-direction, the first-order intensity of the pixel 2 in the x-direction, … …, the first-order intensity of the pixel (m-1) in the x-direction and the first-order intensity of the pixel m in the x-direction are calculated, the first-order intensities in the x-direction calculated by all the pixels in the detection area 11 are ordered from high to low, and n blocks are obtained from high to low;
the brightness value of each pixel point in the y direction is calculated in a similar way, convolution is carried out on the brightness value of each pixel point and a Sobel operator in the y direction, first-order intensity of a pixel point 1 in the y direction, first-order intensity of a pixel point 2 in the y direction, … …, first-order intensity of a pixel point (m-1) in the y direction and first-order intensity of a pixel point m in the y direction are calculated, the first-order intensities in the y direction calculated by all the pixel points in the detection area 11 are sequenced from high to low, and n blocks are obtained from high to low to obtain weighted average a_v;
and averaging the first-order intensity weighted average value a_h of the region to be detected in the x direction and the first-order intensity weighted average value a_v of the region to be detected in the y direction, namely (a_h+a_v)/2, to obtain the first-order intensity weighted average value a_avg of the region to be detected.
Next to the above embodiment of the present application, the focusing method based on the sobel operator further includes:
acquiring a verification image through a lens module with qualified focusing, and calculating a first-order intensity weighted average value of the verification image;
and updating the preset weighted average threshold value into a first-order intensity weighted average value of the verification image, so as to realize the determination of a standard threshold value and facilitate the judgment of whether the lens module is qualified or not in the focusing and focusing process.
For example, firstly, a verification image is obtained through a lens module with qualified focusing, a first-order intensity weighted average value of the verification image is calculated, and a preset weighted average threshold value is updated to be the first-order intensity weighted average value M of the verification image.
Then, by rotating the lens module, obtaining a target image and RGB data of all pixel points in the target image, and converting the RGB data of each pixel point into Y data through Y=0.2990R+0.5870G+0.1140B; and selecting an area to be detected (namely, an area to be detected), carrying out convolution on each pixel point in the x-axis direction and the y-axis direction in the area to be detected to obtain the first-order intensity of the x-direction and the first-order intensity of the y-direction of each pixel point, and obtaining the first-order intensity a of the pixel point based on the first-order intensity of the x-direction and the first-order intensity of the y-direction of each pixel point.
And secondly, sorting the first-order intensity values calculated by each pixel point, taking n values from top to bottom, performing weighted average to obtain a first-order intensity weighted average a_h in the x direction and a first-order intensity weighted average a_v in the y direction, and calculating the first-order intensity weighted average of the region to be detected for a_h and a_v, namely a_avg= (a_h+a_v)/2.
Finally, if the avg value of the to-be-detected area exceeds a preset weighted average threshold M, the to-be-detected area passing the standard is obtained.
Meanwhile, in an actual application scene, when an MTF algorithm is used, and when the region to be detected is selected, the operation accuracy of the MTF algorithm of the selected region to be detected is caused due to different bottom drawings in a target image, and in the application, the bottom drawings are not required to be replaced, so that the problem of different results caused by different drawings is effectively avoided.
According to another aspect of the present application, there is also provided a non-volatile storage medium having stored thereon computer readable instructions which, when executed by a processor, cause the processor to implement a focusing method based on the sobel operator as described above.
According to another aspect of the present application, there is also provided a device for focusing based on a sobel operator, wherein the device includes:
one or more processors;
a computer readable medium for storing one or more computer readable instructions,
the one or more computer-readable instructions, when executed by the one or more processors, cause the one or more processors to implement a sobel operator based focusing method as described above.
For details of each embodiment of the apparatus for focusing based on the sobel operator, reference may be made to the corresponding portion of the embodiment of the focusing method based on the sobel operator, and details thereof are not repeated herein.
In summary, the application obtains the RGB values of the target image and all the pixels therein through the focusing lens module, and converts the RGB values of each pixel into a luminance value; selecting at least one region to be detected in the target image, and respectively convolving the brightness value of each pixel point in the region to be detected with a Sobel operator to obtain first-order intensity of each pixel point; calculating to obtain a first-order intensity weighted average value of the region to be detected based on the first-order intensities of all the pixel points in the region to be detected; if the first-order intensity weighted average value exceeds a preset weighted average threshold value, the focusing of the lens module is determined to be qualified, the data processing of the RGB values of the pixel points is realized, the first-order intensity weighted average value of the pixel points in the region to be detected is extracted based on the Sobel operator, the lens module corresponding to the target image qualified in focusing is accurately obtained when the lens module is dynamically adjusted, the operation is quick and convenient, the data processing is simple and convenient, the definition of the finally qualified lens module is high, and the manpower and material resources are saved.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, e.g., using Application Specific Integrated Circuits (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present application may be executed by a processor to perform the steps or functions described above. Likewise, the software programs of the present application (including associated data structures) may be stored on a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. In addition, some steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
Furthermore, portions of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application by way of operation of the computer. Program instructions for invoking the inventive methods may be stored in fixed or removable recording media and/or transmitted via a data stream in a broadcast or other signal bearing medium and/or stored within a working memory of a computer device operating according to the program instructions. An embodiment according to the application comprises an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to operate a method and/or a solution according to the embodiments of the application as described above.
It will be evident to those skilled in the art that the application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units or means recited in the apparatus claims can also be implemented by means of one unit or means in software or hardware. The terms first, second, etc. are used to denote a name, but not any particular order.

Claims (6)

1. A focusing method based on a sobel operator, wherein the method comprises:
obtaining an object image and RGB values of all pixel points in the object image through a focusing lens module, and respectively converting the RGB values of each pixel point into brightness values;
selecting at least one region to be detected in the target image, and respectively convolving the brightness value of each pixel point in the region to be detected with a Sobel operator to obtain first-order intensity of each pixel point;
calculating to obtain a first-order intensity weighted average value of the region to be detected based on the first-order intensities of all the pixel points in the region to be detected;
and if the first-order intensity weighted average value exceeds a preset weighted average threshold value, determining that the focusing of the lens module is qualified.
2. The method of claim 1, wherein the convolving the luminance value of each pixel point in the to-be-detected area with the sobel operator to obtain the first-order intensity of each pixel point, respectively, includes:
respectively carrying out convolution on the brightness value of each pixel point in the region to be detected and the Sobel operator in the x-axis direction to obtain first-order intensity of each pixel point in the x-axis direction;
respectively carrying out convolution on the brightness value of each pixel point in the region to be detected and the Sobel operator in the y-axis direction to obtain first-order intensity of each pixel point in the y-axis direction;
and obtaining the first-order intensity of each pixel point based on the first-order intensity of the x direction and the first-order intensity of the y direction of each pixel point.
3. The method according to claim 2, wherein the calculating a weighted average of the first-order intensities of the region to be detected based on the first-order intensities of all the pixel points in the region to be detected includes:
selecting a preset number of pixels from all the pixels in the region to be detected according to the order of the first-order intensity of the pixels from high to low;
carrying out weighted average calculation on the first-order intensity of the preset number of pixel points in the x direction to obtain a first-order intensity weighted average of the region to be detected in the x direction;
carrying out weighted average calculation on the first-order intensity of the preset number of pixel points in the x direction to obtain a first-order intensity weighted average of the region to be detected in the y direction;
and averaging the first-order intensity weighted average value of the region to be detected in the x direction and the first-order intensity weighted average value of the region to be detected in the y direction to obtain the first-order intensity weighted average value of the region to be detected.
4. The method of claim 1, wherein the method further comprises:
acquiring a verification image through a lens module with qualified focusing, and calculating a first-order intensity weighted average value of the verification image;
and updating the preset weighted average threshold value to be a first-order intensity weighted average value of the verification image.
5. A non-volatile storage medium having stored thereon computer readable instructions which, when executed by a processor, cause the processor to implement the method of any of claims 1 to 4.
6. A sobel operator-based focusing apparatus, wherein the apparatus comprises:
one or more processors;
a computer readable medium for storing one or more computer readable instructions,
the one or more computer-readable instructions, when executed by the one or more processors, cause the one or more processors to implement the method of claims 1-4.
CN202310672466.5A 2023-06-07 2023-06-07 Focusing method and device based on Sobel operator Pending CN116709020A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310672466.5A CN116709020A (en) 2023-06-07 2023-06-07 Focusing method and device based on Sobel operator

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310672466.5A CN116709020A (en) 2023-06-07 2023-06-07 Focusing method and device based on Sobel operator

Publications (1)

Publication Number Publication Date
CN116709020A true CN116709020A (en) 2023-09-05

Family

ID=87825220

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310672466.5A Pending CN116709020A (en) 2023-06-07 2023-06-07 Focusing method and device based on Sobel operator

Country Status (1)

Country Link
CN (1) CN116709020A (en)

Similar Documents

Publication Publication Date Title
JP3137561B2 (en) Method and apparatus for determining image quality, method and apparatus for monitoring performance of an image capture device
US20120013760A1 (en) Characterization of image sensors
CN101326549B (en) Method for detecting streaks in digital images
CN111325717B (en) Mobile phone defect position identification method and equipment
CN112689100B (en) Image detection method, device, equipment and storage medium
CN115225820A (en) Automatic shooting parameter adjusting method and device, storage medium and industrial camera
CN109489560B (en) Linear dimension measuring method and device and intelligent terminal
CN111556311B (en) Quality detection method and device for fixed-focus camera module and computer storage medium
CN113902697A (en) Defect detection method and related device
CN107392948B (en) Image registration method of amplitude-division real-time polarization imaging system
CN116709020A (en) Focusing method and device based on Sobel operator
CN113228099A (en) Method and system for computing point spread function of digital image detector system based on quantum noise measurement of MTF modulation
JP2020193957A (en) Distance image generator which corrects abnormal distance measurement
KR20040017838A (en) Autothresholding of noisy images
CN113012121B (en) Method and device for processing bare chip scanning result, electronic equipment and storage medium
WO2021189460A1 (en) Image processing method and apparatus, and movable platform
CN111161211B (en) Image detection method and device
CN107687815B (en) Method and system for measuring thickness of light-transmitting film and terminal equipment
CN112801987A (en) Mobile phone part abnormity detection method and equipment
JP2004134861A (en) Resolution evaluation method, resolution evaluation program, and optical apparatus
US7193196B2 (en) Methods and systems for evaluating optical systems
Hwang et al. Source camera identification based on interpolation via lens distortion correction
JP3031577B2 (en) Surface measuring method and surface measuring device for device under test
CN115914018A (en) Bevel MTF test optimization method and equipment
US20240203091A1 (en) External parameter determination method and image processing device

Legal Events

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