CN110223309B - Edge detection method, edge detection device, computer equipment and storage medium - Google Patents

Edge detection method, edge detection device, computer equipment and storage medium Download PDF

Info

Publication number
CN110223309B
CN110223309B CN201910420584.0A CN201910420584A CN110223309B CN 110223309 B CN110223309 B CN 110223309B CN 201910420584 A CN201910420584 A CN 201910420584A CN 110223309 B CN110223309 B CN 110223309B
Authority
CN
China
Prior art keywords
pixel
target
row
preset
target image
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.)
Active
Application number
CN201910420584.0A
Other languages
Chinese (zh)
Other versions
CN110223309A (en
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.)
Shenzhen Xinshizhi Technology Co ltd
Original Assignee
Shenzhen Xinshizhi 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 Shenzhen Xinshizhi Technology Co ltd filed Critical Shenzhen Xinshizhi Technology Co ltd
Priority to CN201910420584.0A priority Critical patent/CN110223309B/en
Publication of CN110223309A publication Critical patent/CN110223309A/en
Application granted granted Critical
Publication of CN110223309B publication Critical patent/CN110223309B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/84Systems specially adapted for particular applications
    • G01N21/88Investigating the presence of flaws or contamination
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30108Industrial image inspection
    • G06T2207/30124Fabrics; Textile; Paper

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Chemical & Material Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Quality & Reliability (AREA)
  • Analytical Chemistry (AREA)
  • Biochemistry (AREA)
  • General Health & Medical Sciences (AREA)
  • Immunology (AREA)
  • Pathology (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

The application relates to an edge detection method, which comprises the following steps: the method comprises the steps of obtaining a target image to be detected, wherein the target image comprises a target main body, sequentially counting pixel values of pixels in the target image according to a preset sequence by using a row unit, obtaining a row pixel accumulated value obtained by counting each time, and determining the edge of the target main body in the target image according to the row pixel accumulated value and a preset row pixel threshold value. The edge detection method greatly improves the speed of edge detection. In addition, an edge detection apparatus, a computer device and a storage medium are also provided.

Description

Edge detection method, edge detection device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an edge detection method and apparatus, a computer device, and a storage medium.
Background
An image obtained by capturing an image of a target subject (i.e., an object such as cloth) by a camera is generally larger than the width of the target subject, and in order to extract the target subject from the image, it is necessary to detect the edge of the target subject. The traditional method for detecting the edge of the target subject in the image usually needs complex setting and has slow edge detection speed.
Disclosure of Invention
In view of the above, it is desirable to provide an edge detection method, an edge detection apparatus, a computer device, and a storage medium that can improve the edge detection speed without requiring complicated settings.
In a first aspect, an embodiment of the present invention provides an edge detection method, where the method includes:
acquiring a target image to be detected, wherein the target image comprises a target main body;
sequentially counting the pixel values of the pixels in the target image according to a preset sequence by using a row unit to obtain a row pixel accumulated value obtained by each counting;
and determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence to obtain a row pixel accumulated value obtained by each counting includes: counting pixel values of pixels in the target image from outside to inside in a row unit from the edge of the target image to obtain a current row pixel accumulated value corresponding to a current row; the determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value includes: and when the accumulated value of the pixels of the current row and the preset row pixel threshold value meet a preset size relationship, stopping counting, and determining the edge of the target main body of the current row.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence to obtain a row pixel accumulated value obtained by each counting includes: acquiring a preset pixel sampling proportion; determining a target pixel participating in statistics in a corresponding line according to the pixel sampling proportion; and accumulating the pixel values corresponding to the target pixels to obtain row pixel accumulated values corresponding to the corresponding rows.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence to obtain a row pixel accumulated value obtained by each counting includes: acquiring a preset pixel period; determining a plurality of target pixel areas participating in statistics in corresponding lines according to a preset first sampling proportion by taking the pixel period as a unit, wherein the size of each target pixel area is the same as the pixel period; and accumulating the area pixel values of the plurality of target pixel areas obtained by sampling to obtain corresponding row pixel accumulated values.
In one embodiment, after the obtaining of the preset pixel period, the method further includes: and determining a plurality of target line areas to be subjected to statistics in the target image according to a preset second sampling proportion by taking the pixel period as a unit, wherein the width of each target line area is the same as the pixel period.
In one embodiment, the target subject is a cloth, and the pixel period is determined according to a texture of the cloth.
In one embodiment, the determining, in the target image according to a preset second sampling ratio by using the pixel period as a unit, a plurality of target row areas to be subjected to statistics includes: determining a corresponding sampling interval according to a preset second sampling proportion; and sampling according to the sampling interval to obtain a plurality of target line areas.
In one embodiment, the method further comprises: extracting an image of the target subject from the target image according to the determined edge of the target subject; and detecting the defects of the image of the target main body, and marking the detected defects.
In a second aspect, an embodiment of the present invention provides a device for detecting an edge of a piece of cloth, where the device includes:
the acquisition module is used for acquiring a target image to be detected, wherein the target image comprises a target main body;
the pixel counting module is used for sequentially counting the pixel values of the pixels in the target image according to a preset sequence by using a row unit to obtain a row pixel accumulated value obtained by each counting;
and the determining module is used for determining the edge of the target main body in the target image according to the pixel accumulated value and a preset pixel threshold value.
In one embodiment, the pixel statistics module is further configured to count pixel values of pixels in the target image in units of rows from outside to inside from an edge of the target image to obtain an accumulated value of pixels in a current row corresponding to the current row; the determining module is further configured to stop counting and determine the edge of the target subject of the current row when the accumulated value of the pixels of the current row and the preset row pixel threshold value satisfy a preset size relationship.
In one embodiment, the pixel statistics module is further configured to obtain a preset pixel sampling ratio; determining a target pixel participating in statistics in a corresponding line according to the pixel sampling proportion; and accumulating the pixel values corresponding to the target pixels to obtain row pixel accumulated values corresponding to the corresponding rows.
In one embodiment, the pixel counting module is further configured to obtain a preset pixel period; determining a plurality of target pixel areas participating in statistics in corresponding lines according to a preset first sampling proportion by taking the pixel period as a unit, wherein the size of each target pixel area is the same as the pixel period; and accumulating the area pixel values of the plurality of target pixel areas obtained by sampling to obtain corresponding row pixel accumulated values.
In one embodiment, the pixel statistics module is further configured to determine, in the target image, a plurality of target line regions to participate in statistics according to a preset second sampling ratio by using the pixel period as a unit, where widths of the target line regions are the same as the pixel period.
In one embodiment, the target subject is a cloth, and the pixel period is determined according to a texture of the cloth.
In one embodiment, the pixel statistics module is further configured to determine a corresponding sampling interval according to a preset second sampling ratio; and sampling according to the sampling interval to obtain a plurality of target line areas.
In one embodiment, the apparatus further comprises: the extraction module is used for extracting an image of the target subject from the target image according to the determined edge of the target subject; and the defect detection module is used for carrying out defect detection on the image of the target main body and marking the detected defects.
A computer-readable storage medium storing a computer program which, when executed by a processor, causes the processor to perform the steps of:
acquiring a target image to be detected, wherein the target image comprises a target main body;
sequentially counting the pixel values of the pixels in the target image according to a preset sequence by using a row unit to obtain a row pixel accumulated value obtained by each counting;
and determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value.
A computer device comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of:
acquiring a target image to be detected, wherein the target image comprises a target main body;
sequentially counting the pixel values of the pixels in the target image according to a preset sequence by using a row unit to obtain a row pixel accumulated value obtained by each counting;
and determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value.
According to the edge detection method, the edge detection device, the computer equipment and the storage medium, the pixel values of the pixels in the target image are counted in sequence according to the preset sequence by using the line units, the line pixel accumulated value obtained by each counting is obtained, and then the edge of the target main body is determined according to the line pixel accumulated value and the preset line pixel threshold value. According to the method, only one line pixel threshold value needs to be preset, the edge of the target main body can be determined by comparing the accumulated value of the line pixels obtained through statistics with the line pixel threshold value, the method is simple and convenient, and the edge detection speed is greatly improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the structures shown in the drawings without creative efforts.
FIG. 1 is a flow diagram of a method for edge detection in one embodiment;
FIG. 2 is a schematic flow chart illustrating processing of a target image according to one embodiment;
FIG. 3 is a flow diagram of statistical derivation of accumulated pixel values, according to one embodiment;
FIG. 4 is a diagram illustrating a sampled target pixel region in one embodiment;
FIG. 5 is a schematic diagram of a sampled target row area in one embodiment;
FIG. 6 is a diagram of participating computing regions in one embodiment;
FIG. 7 is a flow chart of a method of edge detection in another embodiment;
FIG. 8A is a diagram illustrating a target image before a target subject is extracted, in one embodiment;
FIG. 8B is a diagram illustrating an example of an extracted target subject;
FIG. 9 is a block diagram showing the structure of an edge detection apparatus according to an embodiment;
FIG. 10 is a block diagram showing the structure of an edge detecting apparatus according to another embodiment;
FIG. 11 is a diagram illustrating an internal structure of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, an edge detection method is proposed, which can be applied to both a terminal and a server, and this embodiment is exemplified by being applied to a terminal. The edge detection method specifically comprises the following steps:
step 102, a target image to be detected is obtained, wherein the target image comprises a target main body.
The target main body refers to a target object of an edge to be detected in a target image. In one embodiment, the shape of the target body includes a plurality of straight sides, such as a rectangle, and the diamond shape includes four straight sides. The target image is an image to be detected including a target subject. The target image may be a color image, a gray image, or a binary image. The target body may be cloth, a film, glass, or the like. The target image can be obtained by calling a camera in the terminal to shoot a target main body in real time, or can be obtained from a stored photo album.
And step 104, sequentially counting the pixel values of the pixels in the target image according to a preset sequence by using the line units, and acquiring the row pixel accumulated value obtained by each counting.
Wherein a row is composed of pixels which can be connected in a line. The rows include horizontal rows, vertical rows, and diagonal rows, and generally, lines in the horizontal direction are referred to as horizontal rows, lines in the vertical direction are referred to as vertical rows, which may also be referred to as "columns," and lines in the diagonal direction are referred to as diagonal rows. The statistical order can be set by a user, for example, statistics can be performed from the outside to the inside from the edge of the target image, or statistics can be performed from the inside to the outside from the middle of the target image.
The row pixel accumulation value is obtained by accumulating pixel values of respective pixels included in the corresponding row. For example, suppose a row contains 100 pixels, the pixel values of the 100 pixels are accumulated to obtain the corresponding row pixel accumulated value. In order to reduce the amount of calculation, the pixel value may adopt a gray value, that is, the statistical gray value of each pixel is accumulated to obtain a corresponding row pixel accumulated value.
Since the edge of the target subject and the edge of the target image may not be in a parallel relationship, in one embodiment, the pixel values of the pixels in the target image are counted in units of lines according to a direction parallel to the edge of the target subject, and the accumulated value of the pixels of the lines counted each time is calculated. The target image may also be rotated so that the edges of the target subject coincide with the statistical row direction. The target subject generally includes a plurality of edges, and in order to extract the target subject from the target image, the position of each edge of the target subject needs to be determined, for example, if there are four edges in the target subject, the positions of the 4 edges need to be determined respectively.
The row pixel accumulated value may be obtained by accumulating pixel values of pixels in a row, or may be obtained by accumulating pixel values of pixels in a plurality of rows. For example, the pixel values of the pixels included in 2 rows may be counted each time, and then accumulated to obtain the corresponding row pixel accumulated value.
And 106, determining the edge of the target body in the target image according to the row pixel accumulated value and a preset row pixel threshold value.
And the preset line pixel threshold is used for measuring whether the counted line is the edge of the target main body. Generally, two different colors are used for the target body and the background color. For example, if the target object is white, the corresponding background color is generally black. The use of two distinct colors facilitates better detection of the edge of the target subject. The line pixel threshold value may be set in advance according to the difference in pixel value between the subject and the background color. And comparing the row pixel accumulated value obtained by each counting with a preset row pixel threshold value, and if corresponding conditions are met, indicating the edge of the corresponding behavior target main body.
The edge detection method includes the steps of sequentially counting pixel values of pixels in the target image according to a preset sequence by using a row unit to obtain a row pixel accumulated value obtained by each counting, and determining the edge of the target main body according to the row pixel accumulated value and a preset row pixel threshold value. According to the method, only one line pixel threshold value needs to be preset, the edge of the target main body can be determined by comparing the accumulated value of the line pixels obtained through statistics with the line pixel threshold value, the method is simple and convenient, and the edge detection speed is greatly improved.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence, and acquiring a row pixel accumulated value obtained by each counting, includes: counting pixel values of pixels in the target image from outside to inside in a row unit from the edge of the target image to obtain a current row pixel accumulated value corresponding to a current row; the determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value includes: and when the accumulated value of the pixels of the current row and the preset row pixel threshold value meet a preset size relationship, stopping counting, and determining the edge of the target main body of the current row.
The current row refers to a current statistical row, and the current row pixel accumulated value refers to a row pixel accumulated value corresponding to the current row. In one embodiment, the pixel values of the pixels in the target image are counted row by row, counting is performed from the outside to the inside from the edge of the target image, and each row is counted, and the row pixel accumulated value corresponding to the corresponding row is calculated. When the accumulated value of the pixels of the current row corresponding to the current row and the preset row pixel threshold value meet the preset size relationship, the edge of the target body of the current row is illustrated, and statistics does not need to be continued. In another embodiment, to increase the detection speed, the statistics may be performed at intervals in rows, and the statistics may be performed every preset row, for example, 1 row may be counted every 5 rows.
In one embodiment, it is assumed that the target object is white and the background color is black, that is, the pixel value of the target object is larger and the pixel value of the background color is smaller. Counting from outside to inside, and when the accumulated value of the current pixel obtained by counting is not greater than a preset pixel threshold value, indicating that the current row corresponds to the background color, and continuously counting the next row; and when the current pixel accumulated value obtained by statistics is larger than a preset pixel threshold value, indicating the edge of the current behavior target main body, stopping statistics, and performing edge marking, so that the target main body can be extracted according to the edge marking in the follow-up process.
As shown in fig. 2, in one embodiment, when the target subject is a piece of cloth, a flow chart of processing the target image is shown. Because the cloth to be detected is very long, after the picture is taken on the cloth, extra gaps exist at the left side and the right side of the target image containing the cloth, and if no extra gaps exist at the upper part and the lower part of the cloth, the left edge and the right edge of the image containing the cloth only need to be detected. And counting the target image line by line from the left side to the inside, counting to obtain a current line pixel accumulated value corresponding to a current line, and when the current line pixel accumulated value and a preset line pixel threshold value meet a preset size relationship, indicating that the current line is the left edge of the cloth. Similarly, counting the target image line by line from the right side from outside to inside to obtain a current line pixel accumulated value corresponding to the current line, and when the current line pixel accumulated value and a preset line pixel threshold value meet a preset size relationship, indicating the right edge of the current line cloth. And after the left edge and the right edge of the cloth are detected, the cloth is extracted, namely, extra gaps in the target image are removed.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence, and acquiring a row pixel accumulated value obtained by each counting, includes: acquiring a preset pixel sampling proportion; determining a target pixel participating in statistics in a corresponding line according to the pixel sampling proportion; and accumulating the pixel values corresponding to the target pixels to obtain row pixel accumulated values corresponding to the corresponding rows.
The target pixel refers to a pixel participating in statistics. In order to increase the speed of edge detection, the pixels in a row are divided into target pixels and non-target pixels according to a set pixel sampling ratio. The determination of the target pixel and the non-target pixel may be randomly determined according to a pixel sampling ratio, for example, a pixel with a preset pixel ratio is randomly selected as the target pixel, and the rest are the non-target pixels. The selection may also be performed according to a certain rule, for example, one pixel is selected every other pixel with a preset number, for example, if the sampling ratio of the pixels is 1:2, one pixel may be selected every other pixel. After the target pixels and the non-target pixels are determined, only the pixel values of all the target pixels need to be accumulated, so that the calculation amount is greatly reduced. For example, assuming that the pixel sampling ratio is set to 1:2, i.e. the target pixel occupies half of the total number of pixels, and assuming that the rows collectively include 100 pixels, the number of target pixels participating in the statistical calculation is only 50, the calculation amount is correspondingly reduced by half, and the corresponding calculation speed is doubled.
As shown in fig. 3, the sequentially counting the pixel values of the pixels in the target image in a row unit according to a preset sequence to obtain a row pixel accumulated value obtained by each counting includes:
and 104A, acquiring a preset pixel period.
Wherein, the pixel period refers to the set window size for collecting pixels. For example, 10 pixels may be regarded as one pixel period. If the target object is a piece of cloth, the corresponding pixel period may be set according to the texture of the piece of cloth, for example, the pixel period may be set to an integer multiple of the texture of the piece of cloth.
Step 104B, determining a plurality of target pixel areas participating in statistics in corresponding lines according to a preset first sampling proportion by taking a pixel period as a unit, wherein the size of each target pixel area is the same as the pixel period;
each row may be divided into a plurality of pixel regions in units of pixel periods, and the size of the pixel regions is the same as the size of the pixel periods. For example, if the pixel period is 10 pixels, each pixel region includes 10 pixels. The pixel region that participates in the statistical calculation is referred to as a "target pixel region", and the pixel region that does not participate in the statistical calculation is referred to as a "non-target pixel region". As shown in fig. 4, which is a schematic diagram of a target pixel region and a non-target pixel region included in a corresponding row in one embodiment, each lattice represents one pixel period, a black lattice represents the target pixel region, and a white lattice represents the non-target pixel region.
The first sampling proportion is used for determining the proportion of the corresponding line to the calculated target pixel area. The ratio between the target pixel region participating in the calculation and the non-target pixel region not participating in the calculation may be used, or the ratio between the target pixel region and the total pixel region may be used.
In order to increase the speed of edge detection, only part of pixels in each row are selected to participate in calculation when the accumulated value of the pixels in the row is calculated. The first sampling ratio defines a ratio of the target pixel area and the non-target pixel area. A plurality of target pixel regions are selected from the pixel regions according to a first sampling ratio. Only the selected target pixel region participates in the calculation of the corresponding row pixel accumulated value. For example, assuming that there are 100 pixels in a row and the pixel period is 10 pixels, the pixel area is divided into 10 pixel areas accordingly. If the ratio between the target pixel region and the non-target pixel region is 1:1, only 5 participating row pixel accumulation values need to be selected from the 10 pixel regions for calculation. During sampling, the sampling may be performed randomly according to a pixel period and a sampling ratio, or may be performed according to a certain rule, for example, according to a preset interval.
In one embodiment, a corresponding sampling interval is determined according to a preset first sampling proportion, and a plurality of target pixel regions are obtained by sampling according to the sampling interval. I.e., the target pixel region and the non-target pixel region, are arranged to intersect as shown with reference to fig. 4.
And step 104C, accumulating the area pixel values of the plurality of target pixel areas obtained by sampling to obtain corresponding row pixel accumulated values.
In this case, the area pixel value of each target pixel area is calculated, that is, the sum of the pixel values of the pixels included in the target pixel area is calculated. Assuming that the target pixel area contains 10 pixels, the pixel values of the 10 pixels are respectively calculated, then the pixel values are accumulated to obtain the area pixel value of the target pixel area, and then the area pixel values of a plurality of target pixel areas are accumulated to obtain the corresponding row pixel accumulated value.
In one embodiment, after the obtaining of the preset pixel period, the method further includes: and determining a plurality of target line areas to be subjected to statistics in the target image according to a preset second sampling proportion by taking the pixel period as a unit, wherein the width of each target line area is the same as the pixel period.
Among others, to further increase the speed of edge detection. The target image may be divided into line regions in units of a pixel period, and each line region has the same width as the pixel period. For example, if the pixel period is 10 pixels, the width of each row area is 10 pixels. The line region participating in the statistical calculation is referred to as a "target line region", and the line region not participating in the statistical calculation is referred to as a "non-target line region". As shown in fig. 5, which is a schematic diagram of a target line region and a non-target line region included in a target image in an embodiment, a width of the line region is the same as a size of a pixel period, in the diagram, the target line region is a black region, and the non-target line region is a white region.
In one embodiment, the target subject is a cloth, and the pixel period is determined according to a texture of the cloth.
The target body is cloth, and the pixel period is determined according to the texture of the cloth. The cloth is composed of the same texture, and the corresponding pixel periods of the cloth with different textures are different. One or more textures can be used as a pixel period, so that sampling can be performed according to the pixel period conveniently, and the edge detection speed is improved.
In one embodiment, the determining, in the target image according to a preset second sampling ratio by taking the pixel period as a unit, a plurality of target row areas to be subjected to statistics includes: determining a corresponding sampling interval according to a preset second sampling proportion; and sampling according to the sampling interval to obtain a plurality of target line areas.
In order to improve the speed of edge detection and ensure the accuracy of edge detection, after the second sampling proportion is obtained, a corresponding sampling interval is determined, and then a corresponding target row area is determined according to the sampling interval. Namely, the target row area and the non-target row area are arranged in a crossed mode. Fig. 6 is a schematic diagram of the line regions participating in the calculation and the target pixel region participating in the calculation in each line determined at the first sampling ratio (e.g., 1:1) and the second sampling ratio (e.g., 1:1) in one embodiment. In the figure, the horizontal direction represents that pixel statistics is performed from the right edge from the outside to the inside, and the vertical direction represents the direction of pixel accumulation of the corresponding row, i.e. the row direction. Black boxes represent pixel regions that participate in the computation, and white boxes represent pixel regions that do not participate in the computation.
As shown in fig. 7, in an embodiment, the edge detection method further includes:
and 108, extracting the image of the target subject from the target image according to the determined edge of the target subject.
After the edge of the target subject is detected, extracting the image of the target subject from the target image according to the position of the edge of the target subject, namely removing the image of the non-target subject in the target image. As shown in fig. 8A, in one embodiment, the target image is before the target subject is extracted, and as shown in fig. 8B, the image of the extracted target subject is shown.
And 110, detecting the defects of the image of the target main body, and marking the detected defects.
After the image of the target subject is obtained, the image of the target subject can be subjected to defect detection, and then the detected defect is marked. In one embodiment, the target main body is the cloth, and the defects in the cloth are detected, so that the defects of the cloth can be repaired conveniently and timely in the follow-up process, and the quality of the cloth is improved.
As shown in fig. 9, in one embodiment, an edge detection apparatus is provided, the apparatus including:
an obtaining module 902, configured to obtain a target image to be detected, where the target image includes a target subject;
a pixel counting module 904, configured to count pixel values of pixels in the target image in a row unit in sequence according to a preset sequence, and obtain a row pixel accumulated value obtained by each counting;
a determining module 906, configured to determine an edge of a target subject in the target image according to the pixel accumulated value and a preset pixel threshold.
In one embodiment, the pixel statistics module is further configured to count pixel values of pixels in the target image in units of rows from outside to inside from an edge of the target image to obtain a current row pixel accumulated value corresponding to a current row; the determining module is further configured to stop counting and determine the edge of the target subject of the current row when the accumulated value of the pixels of the current row and the preset row pixel threshold value satisfy a preset size relationship.
In one embodiment, the pixel statistics module is further configured to obtain a preset pixel sampling ratio; determining a target pixel participating in statistics in a corresponding line according to the pixel sampling proportion; and accumulating the pixel values corresponding to the target pixels to obtain row pixel accumulated values corresponding to the corresponding rows.
In one embodiment, the pixel statistics module is further configured to obtain a preset pixel period; determining a plurality of target pixel areas participating in statistics in corresponding lines according to a preset first sampling proportion by taking the pixel period as a unit, wherein the size of each target pixel area is the same as the pixel period; and accumulating the area pixel values of the plurality of target pixel areas obtained by sampling to obtain corresponding row pixel accumulated values.
In one embodiment, the pixel counting module is further configured to determine a plurality of target line regions to participate in counting in the target image according to a preset second sampling ratio by taking the pixel period as a unit, where the width of the target line region is the same as the pixel period.
In one embodiment, the target subject is a cloth, and the pixel period is determined according to a texture of the cloth.
In one embodiment, the pixel statistics module is further configured to determine a corresponding sampling interval according to a preset second sampling ratio; and sampling according to the sampling interval to obtain a plurality of target line areas.
As shown in fig. 10, in an embodiment, the edge detecting apparatus further includes:
an extracting module 908, configured to extract an image of the target subject from the target image according to the determined edge of the target subject;
a defect detecting module 910, configured to perform defect detection on the image of the target main body, and mark the detected defect.
FIG. 11 is a diagram illustrating an internal structure of a computer device in one embodiment. The computer device may specifically be a server or a terminal. As shown in fig. 11, the computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program that, when executed by the processor, causes the processor to implement the edge detection method. The internal memory may also have a computer program stored therein, which when executed by the processor, causes the processor to perform the edge detection method. Those skilled in the art will appreciate that the architecture shown in fig. 11 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, the edge detection method provided by the present application may be implemented in the form of a computer program that is executable on a computer device as shown in fig. 11. The memory of the computer device may store various program modules constituting the edge detection apparatus. Such as an acquisition module 902, a pixel statistics module 904, and a determination module 906.
In one embodiment, a computer device is proposed, comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to perform the steps of: acquiring a target image to be detected, wherein the target image comprises a target main body; sequentially counting the pixel values of the pixels in the target image according to a preset sequence by using a row unit to obtain a row pixel accumulated value obtained by each counting; and determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence, and acquiring a row pixel accumulated value obtained by each counting, includes: counting pixel values of pixels in the target image from outside to inside in a row unit from the edge of the target image to obtain a current row pixel accumulated value corresponding to a current row; the determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value includes: and when the accumulated value of the pixels of the current row and the preset row pixel threshold value meet a preset size relationship, stopping counting, and determining the edge of the target main body of the current row.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence, and acquiring a row pixel accumulated value obtained by each counting, includes: acquiring a preset pixel sampling proportion; determining a target pixel participating in statistics in a corresponding line according to the pixel sampling proportion; and accumulating the pixel values corresponding to the target pixels to obtain row pixel accumulated values corresponding to the corresponding rows.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence, and acquiring a row pixel accumulated value obtained by each counting, includes: acquiring a preset pixel period; determining a plurality of target pixel areas participating in statistics in corresponding lines according to a preset first sampling proportion by taking the pixel period as a unit, wherein the size of each target pixel area is the same as the pixel period; and accumulating the area pixel values of the plurality of target pixel areas obtained by sampling to obtain corresponding row pixel accumulated values.
In one embodiment, after the obtaining of the preset pixel period, the method further includes: and determining a plurality of target line areas to be subjected to statistics in the target image according to a preset second sampling proportion by taking the pixel period as a unit, wherein the width of each target line area is the same as the pixel period.
In one embodiment, the target subject is a cloth, and the pixel period is determined according to a texture of the cloth.
In one embodiment, the determining, in the target image according to a preset second sampling ratio by taking the pixel period as a unit, a plurality of target row areas to be subjected to statistics includes: determining a corresponding sampling interval according to a preset second sampling proportion; and sampling according to the sampling interval to obtain a plurality of target line areas.
In one embodiment, the computer program, when executed by the processor, is further adapted to perform the steps of: extracting an image of the target subject from the target image according to the determined edge of the target subject; and detecting the defects of the image of the target main body, and marking the detected defects.
In one embodiment, a computer-readable storage medium is proposed, in which a computer program is stored which, when executed by a processor, causes the processor to carry out the steps of: acquiring a target image to be detected, wherein the target image comprises a target main body; sequentially counting the pixel values of the pixels in the target image according to a preset sequence by using a row unit to obtain a row pixel accumulated value obtained by each counting; and determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence, and acquiring a row pixel accumulated value obtained by each counting, includes: counting pixel values of pixels in the target image from outside to inside in a row unit from the edge of the target image to obtain a current row pixel accumulated value corresponding to a current row; the determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value includes: and when the accumulated value of the pixels of the current row and the preset row pixel threshold value meet a preset size relationship, stopping counting, and determining the edge of the target main body of the current row.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence, and acquiring a row pixel accumulated value obtained by each counting, includes: acquiring a preset pixel sampling proportion; determining a target pixel participating in statistics in a corresponding line according to the pixel sampling proportion; and accumulating the pixel values corresponding to the target pixels to obtain row pixel accumulated values corresponding to the corresponding rows.
In one embodiment, the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence, and acquiring a row pixel accumulated value obtained by each counting, includes: acquiring a preset pixel period; determining a plurality of target pixel areas participating in statistics in corresponding lines according to a preset first sampling proportion by taking the pixel period as a unit, wherein the size of each target pixel area is the same as the pixel period; and accumulating the area pixel values of the plurality of target pixel areas obtained by sampling to obtain corresponding row pixel accumulated values.
In one embodiment, after the obtaining of the preset pixel period, the method further includes: and determining a plurality of target line areas to be subjected to statistics in the target image according to a preset second sampling proportion by taking the pixel period as a unit, wherein the width of each target line area is the same as the pixel period.
In one embodiment, the target subject is a cloth, and the pixel period is determined according to a texture of the cloth.
In one embodiment, the determining, in the target image according to a preset second sampling ratio by taking the pixel period as a unit, a plurality of target row areas to be subjected to statistics includes: determining a corresponding sampling interval according to a preset second sampling proportion; and sampling according to the sampling interval to obtain a plurality of target line areas.
In one embodiment, the computer program, when executed by the processor, is further adapted to perform the steps of: extracting an image of the target subject from the target image according to the determined edge of the target subject; and detecting the defects of the image of the target main body, and marking the detected defects.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a non-volatile computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the program is executed. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (9)

1. An edge detection method, characterized in that the method comprises:
acquiring a target image to be detected, wherein the target image comprises a target main body, and the target main body refers to a target object at the edge to be detected in the target image, and is specifically cloth, a film or glass;
according to the direction parallel to the edge of the target main body, sequentially counting the pixel values of the pixels in the target image according to a preset sequence by using a row unit, and acquiring a row pixel accumulated value obtained by each counting, wherein the method comprises the following steps:
acquiring a preset pixel period;
determining a plurality of target pixel areas participating in statistics in corresponding lines according to a preset first sampling proportion by taking the pixel period as a unit, wherein the size of each target pixel area is the same as the pixel period;
accumulating the area pixel values of the plurality of target pixel areas obtained by sampling to obtain corresponding row pixel accumulated values;
and determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value.
2. The method according to claim 1, wherein the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence to obtain a row pixel accumulated value obtained by each counting comprises:
counting pixel values of pixels in the target image from outside to inside in a row unit from the edge of the target image to obtain a current row pixel accumulated value corresponding to a current row;
the determining the edge of the target subject in the target image according to the row pixel accumulated value and a preset row pixel threshold value includes:
and when the accumulated value of the pixels of the current row and the preset row pixel threshold value meet a preset size relationship, stopping counting, and determining the edge of the target main body of the current row.
3. The method according to claim 1, wherein the sequentially counting pixel values of pixels in the target image in a row unit according to a preset sequence to obtain a row pixel accumulated value obtained by each counting comprises:
acquiring a preset pixel sampling proportion;
determining a target pixel participating in statistics in a corresponding line according to the pixel sampling proportion;
and accumulating the pixel values corresponding to the target pixels to obtain row pixel accumulated values corresponding to the corresponding rows.
4. The method of claim 1, further comprising, after said obtaining a preset pixel period:
and determining a plurality of target line areas to be subjected to statistics in the target image according to a preset second sampling proportion by taking the pixel period as a unit, wherein the width of each target line area is the same as the pixel period.
5. The method according to claim 1 or 4, wherein the target subject is a cloth and the pixel period is determined according to a texture of the cloth.
6. The method according to claim 4, wherein the determining a plurality of target row areas to participate in statistics in the target image according to a preset second sampling ratio in the unit of the pixel period comprises:
determining a corresponding sampling interval according to a preset second sampling proportion;
and sampling according to the sampling interval to obtain a plurality of target line areas.
7. An edge detection apparatus, characterized in that the apparatus comprises:
the device comprises an acquisition module, a detection module and a processing module, wherein the acquisition module is used for acquiring a target image to be detected, and the target image comprises a target main body, wherein the target main body refers to a target object at the edge to be detected in the target image, and is specifically cloth, a film or glass;
the pixel counting module is used for sequentially counting the pixel values of the pixels in the target image according to a direction parallel to the edge of the target main body and a preset sequence by using a row unit, and acquiring a row pixel accumulated value obtained by each counting, and comprises:
the device comprises an acquisition unit, a processing unit and a control unit, wherein the acquisition unit is used for acquiring a preset pixel period;
the sampling unit is used for determining a plurality of target pixel areas participating in statistics in corresponding lines according to a preset first sampling proportion by taking the pixel period as a unit, and the size of each target pixel area is the same as the pixel period;
the accumulation unit is used for accumulating the area pixel values of the plurality of target pixel areas obtained by sampling to obtain corresponding row pixel accumulated values;
and the determining module is used for determining the edge of the target main body in the target image according to the pixel accumulated value and a preset pixel threshold value.
8. A computer-readable storage medium, storing a computer program which, when executed by a processor, causes the processor to carry out the steps of the method according to any one of claims 1 to 6.
9. A computer device comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1 to 6.
CN201910420584.0A 2019-05-20 2019-05-20 Edge detection method, edge detection device, computer equipment and storage medium Active CN110223309B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910420584.0A CN110223309B (en) 2019-05-20 2019-05-20 Edge detection method, edge detection device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910420584.0A CN110223309B (en) 2019-05-20 2019-05-20 Edge detection method, edge detection device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110223309A CN110223309A (en) 2019-09-10
CN110223309B true CN110223309B (en) 2021-07-06

Family

ID=67821458

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910420584.0A Active CN110223309B (en) 2019-05-20 2019-05-20 Edge detection method, edge detection device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110223309B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113034524B (en) * 2019-12-25 2024-06-14 深圳怡化电脑股份有限公司 Image edge detection method and device
CN112669227B (en) * 2020-12-16 2023-10-17 Tcl华星光电技术有限公司 Icon edge processing method, icon edge processing device and computer readable storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104933719A (en) * 2015-06-24 2015-09-23 辽宁工程技术大学 Method for detecting image edge by integral image interblock distance
CN105894521A (en) * 2016-04-25 2016-08-24 中国电子科技集团公司第二十八研究所 Sub-pixel edge detection method based on Gaussian fitting

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7903899B2 (en) * 2007-05-23 2011-03-08 Videosurf, Inc. Method of geometric coarsening and segmenting of still images
CN101996322B (en) * 2010-11-09 2012-11-14 东华大学 Method for extracting fractal detail feature for representing fabric texture
CN102497488A (en) * 2011-11-30 2012-06-13 广东威创视讯科技股份有限公司 Method and device for removing image black margins
CN103729856B (en) * 2014-01-24 2016-08-17 浙江师范大学 A kind of Fabric Defects Inspection detection method utilizing S-transformation signal extraction
CN104778713B (en) * 2015-04-27 2017-07-07 清华大学深圳研究生院 A kind of image processing method
CN104794998B (en) * 2015-05-12 2016-03-02 京东方科技集团股份有限公司 A kind of display drive method, device and display device
CN105184290B (en) * 2015-08-25 2021-04-16 深圳怡化电脑股份有限公司 Target area extraction method and system
CN105740861A (en) * 2016-02-02 2016-07-06 大连楼兰科技股份有限公司 Method for quickly making statistics on labeled connected domains in image
CN108734161B (en) * 2017-04-13 2022-01-25 深圳怡化电脑股份有限公司 Method, device and equipment for identifying prefix number area and storage medium
CN107808397B (en) * 2017-11-10 2020-04-24 京东方科技集团股份有限公司 Pupil positioning device, pupil positioning method and sight tracking equipment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104933719A (en) * 2015-06-24 2015-09-23 辽宁工程技术大学 Method for detecting image edge by integral image interblock distance
CN105894521A (en) * 2016-04-25 2016-08-24 中国电子科技集团公司第二十八研究所 Sub-pixel edge detection method based on Gaussian fitting

Also Published As

Publication number Publication date
CN110223309A (en) 2019-09-10

Similar Documents

Publication Publication Date Title
CN110414507B (en) License plate recognition method and device, computer equipment and storage medium
CN111242128B (en) Object detection method, device, computer readable storage medium and computer equipment
CN109308460B (en) Article detection method, system and computer readable storage medium
CN110223309B (en) Edge detection method, edge detection device, computer equipment and storage medium
CN110516517B (en) Target identification method, device and equipment based on multi-frame image
CN109740533A (en) Masking ratio determines method, apparatus and electronic system
CN108961316B (en) Image processing method and device and server
CN108710837A (en) Cigarette smoking recognition methods, device, computer equipment and storage medium
CN110728659A (en) Defect merging method and device, computer equipment and storage medium
CN111368638A (en) Spreadsheet creation method and device, computer equipment and storage medium
CN109308704B (en) Background eliminating method, device, computer equipment and storage medium
CN111914926B (en) Sliding window-based video plagiarism detection method, device, equipment and medium
CN108055486B (en) Brightness correction method and device
CN109996063B (en) Video image screen splash detection method and device, computer equipment and storage medium
CN114078127A (en) Object defect detection and counting method, device, equipment and storage medium
CN111445487A (en) Image segmentation method and device, computer equipment and storage medium
CN112073713B (en) Video leakage test method, device, equipment and storage medium
CN116431857B (en) Video processing method and system for unmanned scene
CN111291716A (en) Sperm cell recognition method, device, computer equipment and storage medium
CN107403429B (en) Method for quickly and automatically acquiring parameters of periodic sequence image model
CN108831004B (en) Method and device for determining paper currency crown word number area and automatic deposit and withdrawal equipment
CN110349133B (en) Object surface defect detection method and device
CN113421282B (en) Motion detection method, apparatus, and medium
CN108389167B (en) Image processing method, image processing device, computer equipment and storage medium
CN108010020B (en) Silicon wafer slide detection method and 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
GR01 Patent grant
GR01 Patent grant