CN110736688B - Crude oil emulsion particle size detection method and device and readable storage medium - Google Patents

Crude oil emulsion particle size detection method and device and readable storage medium Download PDF

Info

Publication number
CN110736688B
CN110736688B CN201911024998.8A CN201911024998A CN110736688B CN 110736688 B CN110736688 B CN 110736688B CN 201911024998 A CN201911024998 A CN 201911024998A CN 110736688 B CN110736688 B CN 110736688B
Authority
CN
China
Prior art keywords
pixel
emulsion
connected domain
crude oil
particle size
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
CN201911024998.8A
Other languages
Chinese (zh)
Other versions
CN110736688A (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.)
Xi'an Zhonghuixin Quality Testing Technology Co ltd
Original Assignee
Shaanxi University of Science and Technology
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 Shaanxi University of Science and Technology filed Critical Shaanxi University of Science and Technology
Priority to CN201911024998.8A priority Critical patent/CN110736688B/en
Publication of CN110736688A publication Critical patent/CN110736688A/en
Application granted granted Critical
Publication of CN110736688B publication Critical patent/CN110736688B/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
    • G01N15/00Investigating characteristics of particles; Investigating permeability, pore-volume or surface-area of porous materials
    • G01N15/02Investigating particle size or size distribution
    • G01N15/0205Investigating particle size or size distribution by optical means
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • 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
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/194Segmentation; Edge detection involving foreground-background segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/62Analysis of geometric attributes of area, perimeter, diameter or volume
    • 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/10056Microscopic image
    • G06T2207/10061Microscopic image from scanning electron microscope
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20024Filtering details
    • G06T2207/20032Median filtering
    • 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
    • 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/30242Counting objects in image

Landscapes

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

Abstract

The invention discloses a method and a device for detecting the particle size of a crude oil emulsion and a readable storage medium, comprising the following steps: s1: filtering and binarizing the crude oil emulsion micrograph to obtain an emulsion binary image; s2: marking all connected domains in the emulsion binary image by a connected domain marking method, wherein one connected domain corresponds to one liquid drop; s3: and obtaining the area and the perimeter of the liquid drop corresponding to the connected domain through the connected domain, and obtaining the particle size of the liquid drop through the area and the perimeter of the liquid drop. Marking all connected domains in the emulsion binary image by a connected domain marking method, wherein one connected domain corresponds to one liquid drop, and the particle size of the liquid drop is conveniently and quickly counted; the area and the perimeter of the liquid drop are calculated by counting the number of pixels inside and at the edge of the connected domain, the particle size of the liquid drop is obtained by the area and the perimeter of the liquid drop, the calculation process is visual and convenient, the method is much quicker than other methods, and the occupied memory space is smaller.

Description

Crude oil emulsion particle size detection method and device and readable storage medium
Technical Field
The invention belongs to the field of microscopic detection of crude oil emulsion, and relates to a method and a device for detecting the particle size of crude oil emulsion and a readable storage medium.
Background
In the petroleum industry, the crude oil produced is a mixed solution of oil, water and emulsion, and contains a small amount of impurities such as silt. In order to obtain relatively pure petroleum, crude oil needs to be sent to an oil field united station, stored in a crude oil storage tank, and subjected to multiple processes of sedimentation, emulsion breaking, separation and the like in sequence to separate the petroleum meeting the smelting standard, and the series of processes are very important in petroleum storage and transportation. The crude oil waiting for oil-water separation in the settling tank has the characteristics of emulsion droplet size, distribution and the like which can be changed at any time along with the changes of factors such as settling time, demulsification reaction and the like, and the changes can directly influence the change of the demulsification method and the effect of oil-water separation. In addition, in the actual production and research process, many researchers think that the research of the crude oil emulsion is a very complicated and deep-going problem, and has an important influence on the understanding of emulsion stability, emulsion viscosity and the like. Therefore, the research on the micro distribution of the crude oil emulsion has very important significance for understanding the essence of the emulsion, and provides important basis for guiding a crude oil demulsification method and oil-water separation besides being very important for developing multiphase flow treatment and pipe transportation devices.
Crude oil emulsions are multiphase dispersions in which the liquid phase is dispersed in another immiscible liquid phase, referred to as the dispersed phase, into small droplets, and the continuous phase, which contains these droplets. There are two main types of emulsions: one is oil-in-water emulsion (O/W), i.e. the water phase is the continuous phase and the oil phase is the dispersed phase; another type is water-in-oil emulsions, i.e., the oil phase is the continuous phase and the aqueous phase is the dispersed phase. In addition to this, there are two types of multiple emulsions: one is water-in-oil-in-water (W/O/W), i.e., oil is dispersed in water phase, and droplets are also present in oil droplets; another type is oil-in-water-in-oil emulsion (O/W/O), i.e., water dispersed in the oil phase, and droplets of oil in the water droplets. Statistically, 80% of crude oil in the world is collected in the form of emulsion, and the majority of crude oil emulsion is water-in-oil type. The invention takes the water-in-oil type crude oil emulsion image as an example to illustrate the process.
At present, methods for detecting the particle size of crude oil emulsion droplets mainly include a direct measurement method and an indirect measurement method. The indirect measurement method is to determine the moving speed of particles through the change of phase thickness along with time on the premise of using a dispersion stability analyzer, thereby calculating the average diameter of the particles; the direct measurement method is to take a picture of the crude oil emulsion and identify the liquid drops in the picture by using an artificial measurement or image processing technology on the premise of using an electron microscope, so as to analyze the particle size and the distribution of the liquid drops. The two methods can achieve the purpose of measuring the particle size of the crude oil emulsion liquid drop and obtain good experimental effect. However, the indirect measurement method of the droplet particle size based on the average migration rate of the droplets can only calculate the average particle size, but cannot calculate the particle size of a single droplet, and the application has certain limitations and cannot analyze the distribution of all droplets. The direct measurement method for the droplet particle size based on image processing can measure the particle size of a single droplet and can also calculate the average particle size, and is functionally superior to an indirect measurement method for the droplet particle size based on the average migration rate of the droplet, however, a specific implementation process is not given, the measurement speed is relatively slow, the system development environment is relatively old, and the compatibility is insufficient.
Disclosure of Invention
The present invention is directed to overcome the above-mentioned shortcomings of the prior art, and provides a method and an apparatus for detecting a particle size of a crude oil emulsion, and a readable storage medium.
In order to achieve the purpose, the invention adopts the following technical scheme to realize the purpose:
a method for detecting the particle size of a crude oil emulsion comprises the following steps:
s1: filtering and binarizing the crude oil emulsion micrograph to obtain an emulsion binary image;
s2: marking all connected domains in the emulsion binary image by a connected domain marking method, wherein one connected domain corresponds to one liquid drop;
s3: the area and the perimeter of the liquid drop corresponding to each connected domain are respectively obtained by counting the number of pixels contained in the interior and the edge of each marked connected domain, and the particle size of the liquid drop is obtained through the area and the perimeter of the liquid drop.
The method for detecting the particle size of the crude oil emulsion is further improved in that:
the specific method of S1 is as follows:
and filtering the crude oil emulsion micrograph through a median filtering algorithm, and then performing binarization processing through an overall threshold Otsu algorithm to obtain an emulsion binary image.
The specific method of S2 is as follows:
s201: adding a circle of background pixels with the width of one pixel to the emulsion binary image;
s202: and scanning each pixel of the emulsion binary image line by line, and marking each connected domain of the emulsion binary image by adopting different marking values through a connected domain marking method, wherein one connected domain corresponds to one liquid drop.
The specific method of S202 is:
s202-1: scanning each pixel of the emulsion binary image line by line, and detecting the pixel type of the current pixel; the initialization flag value is 1;
s202-2: when the current pixel is a foreground pixel, marking the current pixel by adopting a current marking value, adding 1 to the marking value, and detecting the pixel types of a left pixel, an upper right pixel and an upper right pixel of the current pixel; otherwise, S202-7 is carried out;
s202-3: when the upper pixel of the current pixel is a background pixel and the left pixel and the upper right pixel are foreground pixels, taking the minimum mark value of the mark values of the left pixel and the upper right pixel of the current pixel to mark the current pixel again; the tag value is decremented by 1; otherwise, S202-4 is carried out;
s202-4: when the upper pixel of the current pixel is a background pixel and the upper left pixel and the upper right pixel are foreground pixels, taking the minimum mark value of the mark values of the upper left pixel and the upper right pixel of the current pixel to mark the current pixel again; the tag value is decremented by 1; otherwise, S202-5 is carried out;
s202-5: when at least one of the left pixel, the upper left pixel and the upper right pixel of the current pixel is a foreground pixel, taking the minimum mark value of the mark values of the left pixel, the upper left pixel and the upper right pixel of the current pixel to re-mark the current pixel; the tag value is decremented by 1;
s202-6: traversing the scanned pixels again every time one pixel is marked;
s202-7: when the current pixel is a background pixel, marking the current pixel by adopting 0;
s202-8: all pixels with the same mark value form a connected domain, and one connected domain corresponds to one liquid drop.
The specific method of S3 is as follows:
obtaining the area and the perimeter of the liquid drop corresponding to the connected domain through the connected domain, and obtaining the image particle size of the liquid drop through the formula (1):
Figure BDA0002248365170000041
wherein, D [ i ] is the image grain size of the liquid drop; ai is the area of the droplet; pi is the perimeter of the drop;
the particle diameter d [ i ] of the droplet is obtained by the formula (2):
Figure BDA0002248365170000042
wherein H is the image height; w is the image width; DPIHVertical resolution of crude oil emulsion micrographs; DPIWHorizontal resolution of crude oil emulsion micrographs; m is1Is the microscope objective magnification; m is2The magnification of the microscope eyepiece.
Further comprising:
s4: the average particle diameter of the droplets is obtained by the formula (3) according to the particle diameter of each droplet:
Figure BDA0002248365170000043
wherein L is the total number of droplets;
the particle size distribution of all the droplets is counted and represented in the form of a bar chart or a graph.
In another aspect of the present invention, a crude oil emulsion particle size detection apparatus includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the crude oil emulsion particle size detection method when executing the computer program.
In still another aspect of the present invention, a computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the crude oil emulsion particle size detection method.
Compared with the prior art, the invention has the following beneficial effects:
filtering and binarizing a crude oil emulsion micrograph to obtain an emulsion binary image, and preparing for a connected domain mark in an early stage; marking all connected domains in the emulsion binary image by a connected domain marking method, wherein one connected domain corresponds to one liquid drop, and the particle size of the liquid drop is conveniently and quickly counted; the area and the perimeter of the liquid drop are calculated by counting the number of pixels inside and at the edge of the connected domain, the area and the perimeter of the liquid drop corresponding to the connected domain are obtained through the connected domain, the particle size of the liquid drop is obtained through the area and the perimeter of the liquid drop, and the calculation process is visual and convenient. Generally speaking, the method for detecting the particle size of the crude oil emulsion based on the connected domain mark can be completed by scanning an image for one time when counting the area and the number of the droplets (connected domains) of the crude oil emulsion, so that the method is much faster than other methods mentioned in the background and occupies a smaller memory space.
Further, filtering the crude oil emulsion micrograph through a median filtering algorithm, then carrying out binarization processing through a global threshold Otsu algorithm to obtain an emulsion binary image, and preparing early-stage preparation for marking crude oil emulsion liquid drops, namely, connected domain marking, so as to mark the crude oil emulsion liquid drops and improve marking precision.
Further, adding a circle of background pixels with the width of one pixel to the emulsion binary image to ensure that the first pixel of the emulsion binary image is taken as the first current pixel by the working surface when scanning starts; and scanning each pixel of the emulsion binary image line by line, and marking each connected domain of the emulsion binary image by adopting different marking values through a connected domain marking method, so that different connected domains, namely crude oil emulsion liquid drops, can be distinguished.
Furthermore, the number of times of scanning the image is less when the connected domain is marked, the image only needs to be scanned for 1 time, the number of times of scanning is more than that of the indirect method mentioned in the background, the number of times of scanning is at least 4 times smaller, the calculation speed is obviously improved, and the memory occupancy rate is smaller; on the other hand, the equivalent labeling of the connected domain is realized through the steps S202-3 to S202-5, the adopted equivalent labeling method can greatly reduce the code amount, and only 2 cases of 16 cases are analyzed during the exchange of the equivalent labels, namely only 2 cases of whether the upper right and the upper left or the upper right and the upper left in the working surface are foreground pixels need to be analyzed, other 14 cases in the working surface are not concerned, the code writing amount is reduced, and the cost is reduced.
Drawings
FIG. 1 is a flow chart of a method for detecting particle size of crude oil emulsion according to the present invention;
FIG. 2 is a schematic diagram of an 8-neighborhood target pixel of the present invention;
FIG. 3 is a schematic diagram of a connected domain of the present invention;
FIG. 4 is a schematic representation of a connected domain marking work surface of the present invention;
FIG. 5 is a schematic working surface view of one aspect of the present invention in which equivalence signatures are present;
FIG. 6 is a schematic working surface view of another aspect of the present invention in which equivalence signatures are present;
FIG. 7 is a micrograph of a crude oil emulsion according to the present invention;
FIG. 8 is a micrograph of a filtered crude oil emulsion according to the present invention;
FIG. 9 is a micrograph of a crude oil emulsion after binarization treatment according to the present invention;
FIG. 10 is a histogram of the droplet size distribution of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "comprises" and "comprising," and any variations thereof, in the description and claims of the present invention and the above-described drawings, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The invention is described in further detail below with reference to the accompanying drawings:
referring to fig. 1, the method for detecting the particle size of the crude oil emulsion of the present invention comprises the following steps:
s1: filtering and binarizing the crude oil emulsion micrograph to obtain an emulsion binary image; the specific method comprises the following steps:
and filtering the crude oil emulsion micrograph through a median filtering algorithm, and then performing binarization processing through an overall threshold Otsu algorithm to obtain an emulsion binary image.
S2: marking all connected domains in the emulsion binary image by a connected domain marking method, wherein one connected domain corresponds to one liquid drop; the specific method comprises the following steps:
s201: adding a circle of background pixels with the width of one pixel to the emulsion binary image; ensuring that the first pixel of the emulsion binary image is taken as the first current pixel by the working surface when scanning starts;
s202: scanning each pixel of the emulsion binary image line by line, and marking each connected domain of the emulsion binary image by adopting different marking values through a connected domain marking method; the specific method comprises the following steps:
s202-1: scanning each pixel of the emulsion binary image line by line, and detecting the pixel type of the current pixel; the initialization flag value is 1;
s202-2: when the current pixel is a foreground pixel, marking the current pixel by adopting a current marking value, adding 1 to the marking value, and detecting the pixel types of a left pixel, an upper right pixel and an upper right pixel of the current pixel; otherwise, proceed to S202-7
S202-3: when the upper pixel of the current pixel is a background pixel and the left pixel and the upper right pixel are foreground pixels, taking the minimum mark value of the mark values of the left pixel and the upper right pixel of the current pixel to mark the current pixel again; at this point, the two labels are equivalent labels; the tag value is decremented by 1; otherwise, S202-4 is carried out;
s202-4: when the upper pixel of the current pixel is a background pixel and the upper left pixel and the upper right pixel are foreground pixels, taking the minimum mark value of the mark values of the upper left pixel and the upper right pixel of the current pixel to mark the current pixel again; at this point, the two labels are equivalent labels; the tag value is decremented by 1; otherwise, S202-5 is carried out;
s202-5: when at least one of the left pixel, the upper left pixel and the upper right pixel of the current pixel is a foreground pixel, taking the minimum mark value of the mark values of the left pixel, the upper left pixel and the upper right pixel of the current pixel to re-mark the current pixel; the tag value is decremented by 1;
s202-6: for the marking phenomena existing in S202-3 and S202-4, after the current pixel is marked, all scanned pixels need to be traversed again to carry out equivalent marking replacement of the connected domain, namely, all the pixels with large equivalent marking values in the connected domain are replaced with small equivalent marking values;
s202-7: when the current pixel is a background pixel, marking the current pixel by adopting 0;
s202-8: all pixels with the same mark value form a connected domain, and one connected domain corresponds to one liquid drop.
S3: obtaining the area and the perimeter of the liquid drop corresponding to the connected domain through the connected domain, and obtaining the particle size of the liquid drop through the area and the perimeter of the liquid drop; wherein the image particle diameter of the droplet is obtained by the formula (1):
Figure BDA0002248365170000081
wherein, D [ i ] is the image grain size of the liquid drop; ai is the area of the droplet; pi is the perimeter of the drop;
the particle diameter d [ i ] of the droplet is obtained by the formula (2):
Figure BDA0002248365170000091
wherein H is the image height; w is the image width; DPIHVertical resolution of crude oil emulsion micrographs; DPIWHorizontal resolution of crude oil emulsion micrographs; m is1Is the microscope objective magnification; m is2The magnification of the microscope eyepiece.
S4: the average particle diameter of the droplets is obtained by the formula (3) according to the particle diameter of each droplet:
Figure BDA0002248365170000092
wherein L is the total number of droplets;
the particle size distribution of all the droplets is counted and represented in the form of a bar chart or a graph.
The principles of the present invention are described in detail below:
in order to explain the crude oil emulsion particle size detection method more clearly, it is first necessary to know what the image connected domain and the connected domain mark are. For a binary image of size N x M pixels, a pixel value at coordinate (x, y) is represented by b (x, y), where 0. ltoreq. x.ltoreq.N-1, 0. ltoreq. y.ltoreq.M-1. Each pixel in the binary image represents the value of the pixel with 1 and 0 to distinguish between foreground and background pixels. Not specifically described, it is generally assumed that the foreground pixel has a value of 1 and the background pixel has a value of 0, and the foreground pixel is also referred to as a target pixel. Furthermore, for analytical convenience, it is generally assumed that all pixels on the image boundary are background pixels. As shown in fig. 1, the pixels represented by the gray boxes are foreground pixels and the pixels represented by the white boxes are background pixels.
For a pixel b (x, y), its surrounding pixels b (x-1, y), b (x, y-1), b (x +1, y) and b (x, y +1) are called 4-neighborhood pixels, and the 4-neighborhood pixels plus b (x-1, y-1), b (x-1, y-1), b (x +1, y-1) and b (x-1, y +1) are called 8-neighborhood pixels. Assuming that there is a path that contains the target pixels a1, a2, …, an, where a1 is pixel p, an is pixel q, and all ai and ai +1 are 8 neighborhood pixels from each other, we call the target pixels p and q 8 connected pixels from each other. One 8-connected domain in a binary image is the set of all 8-connected pixels in the image. A connected component is also referred to as an object, for example, in the binary image shown in FIG. 2, there are 4 8 connected components (objects).
In order to distinguish different objects in a binary image, connected component labeling is an indispensable operation. The connected component marking is to mark the pixels of each connected component in the binary image with a unique marking value so as to distinguish other connected components in the image. Through the connected component marking processing, a binary image is converted into a marking image. For example, fig. 2 is the marker image of fig. 1. Therefore, after the connected domain labeling, we can extract each object in the labeled image by the labeling value, and then further calculate the shape feature of the object. For emulsion images, the number of droplets can be counted, and the droplet area, droplet size, etc. can be calculated.
The method for detecting the particle size of the crude oil emulsion comprises three steps. Firstly, filtering an obtained crude oil emulsion microscopic picture, removing noise, and binarizing a filtered image; secondly, marking all liquid drops in the crude oil emulsion image by a connected domain marking algorithm; and thirdly, analyzing the marked image, counting the number of the liquid drops, and calculating the particle size of the liquid drops, the average particle size and the distribution of the average particle size. Referring to FIG. 6, a flow chart of the detection method of the present invention is shown, and the detection method is described in detail as follows.
Step 1: and acquiring a crude oil emulsion microscopic image, as shown in fig. 7, performing filtering processing on the emulsion image by adopting a median filtering algorithm, as shown in fig. 8, performing binarization processing on the emulsion image by adopting a global threshold Otsu algorithm, as shown in fig. 9, and acquiring an emulsion binary image.
Step 2: after the emulsion binary image is obtained, 0 represents a background pixel, 1 represents a foreground pixel (a target pixel), an array is used for storing a crude oil emulsion binary image of which 0 and 1 represent pixel types, a circle of background pixels are added around the emulsion binary image obtained in the step 1, and all the pixels are marked as background pixels.
And step 3: scanning the emulsion binary image line by line, detecting the values of four pixels around the current pixel b (x, y), namely, the left b (x-1, y), the upper left b (x-1, y-1), the upper b (x, y-1) and the upper right b (x +1, y-1), and referring the area where the 5 pixels are located as a working surface, as shown in fig. 3.
And 4, step 4: if the current pixel is a foreground pixel, marking the current pixel with a value larger than 0 as a marking value of the pixel, wherein the marking value cannot be repeated with other marked connected domain marking values; if the current pixel is a background pixel, the mark is not used, and 0 is used instead in the mark array.
And 5: if the current pixel is a foreground pixel, when marking, if the pixel above the pixel is '0', the pixel on the left and the pixel on the right above are '1', as shown in fig. 4, or the pixel on the left and the pixel on the right above are '1', as shown in fig. 5, the smaller marking value on the left, the upper right, or the upper left and the upper right of the current pixel is taken to mark the current pixel, and the scanned pixels are traversed again, the marking values of the pixels with the marking values equal to the larger marking value in all the scanned pixels are all replaced by the smaller marking values, and the process is the replacement process of the equivalent marking of the crude oil emulsion connected domain marking and the connected domain.
Step 6: if it is not the case in step 4 and step 5, that is, at least one pixel of the four pixels of the left, upper right and upper right of the current pixel is "1", the number with the minimum marking value among the four pixels is taken as the marking value of the current pixel.
And 7: and after the emulsion binary image is scanned and marked, counting and storing an array of connected domain mark values to obtain a marked image and the number L of objects (liquid drops) in the image. The area and the perimeter of each droplet Y [ i ] (i ═ 1,2,3, …, L) in the marker image were obtained by calculation. Since the droplets are substantially circular, the particle diameter of the droplets Y [ i ] can be calculated by the following formula (1).
Figure BDA0002248365170000111
Wherein, D [ i ] is the particle size of the liquid drop Y [ i ]; ai is the area of the drop Y [ i ]; pi is the perimeter of the drop Y [ i ].
And 8: the actual particle diameter of the droplet Y [ i ] can be calculated from the following equation (2) in units of μm (micrometer) according to the resolution (resolution) of the crude oil emulsion image and the magnification of a microscope.
Figure BDA0002248365170000121
Wherein d [ i ] is the actual particle size of the droplets Y [ i ]; h is the image height; w is the image width; DPIH is the vertical resolution of the image; DPIW is the image horizontal resolution; n is the number of pixels contained in a single droplet in the image; n is the total number of pixels in the image; m1 is the microscope objective magnification; m2 is the microscope eyepiece magnification.
And step 9: the average particle diameter of the droplets in the crude oil emulsion can be calculated by the following formula (3).
Figure BDA0002248365170000122
Wherein d is the average droplet size; d [ i ] is the actual particle size of the ith droplet; l is the total number of droplets.
Step 10: the distribution of the droplet size can be counted and expressed in the form of a bar chart or a graph according to the sorting of the actual droplet size.
The results obtained by the above method are: the emulsion image shown in FIG. 5 had a total of 117 droplets, an average particle size of 2.2 μm, and a droplet size distribution as shown in FIG. 10.
In an exemplary embodiment, a computer readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of the crude oil emulsion particle size detection method. The computer storage medium may be any available medium or data storage device that can be accessed by a computer, including but not limited to magnetic memory (e.g., floppy disk, hard disk, magnetic tape, magneto-optical disk (MO), etc.), optical memory (e.g., CD, DVD, BD, HVD, etc.), and semiconductor memory (e.g., ROM, EPROM, EEPROM, nonvolatile memory (NANDFLASH), Solid State Disk (SSD)), etc.
In an exemplary embodiment, a crude oil emulsion particle size detection apparatus is further provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the steps of the crude oil emulsion particle size detection method are implemented. The processor may be a Central Processing Unit (CPU), other general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc.
The indirect liquid drop particle size calculation method provided in the background has the advantages that the accuracy is high and low, the liquid drop migration speed has a great relation, the migration speed calculation accuracy is high, the average particle size calculation accuracy is high, and otherwise, the accuracy is low. Although the direct method does not give concrete implementation processes and pseudo codes, the accuracy of the method is not high by writing programs according to the simple thought of the given method and finding through comparison. Because the droplets are not all of a standard circular shape due to the shape of the emulsion droplets or the deviation of the photographing process, other situations may occur besides the situation to which the droplets belong, such as 2 or more than 2 pixels may occur at the leftmost position, the rightmost position, the uppermost position and the lowermost position of one droplet, and the droplets are arranged and combined to form various situations. Therefore, the accuracy is not high if it is determined whether the droplet is a liquid droplet only by one of the above-described cases. The method for detecting the particle size of the crude oil emulsion provided by the invention can be used for identifying the liquid drops from another angle, the method accuracy is obviously improved, the average particle size can be calculated, the particle size of each liquid drop can be calculated, the liquid drop distribution can be counted, and the like.
The detection method provided by the invention isAn N x N binary image of the emulsion with an algorithm having a worst case time complexity of O (N)2) (ii) a Because 2 NXN/4 arrays are required to be created for recording each connected domain mark value and each connected domain pixel number respectively, the size of the memory space requires N2/2. The method described in the background has a worst-case time complexity of O (n)2) The same as the present invention; since 4 azimuth positions per droplet need to be recorded and the number of droplets and the number of pixels contained in each droplet need to be counted, the size of the memory space needs to be 3 × N2And 2, the memory space is 3 times more occupied than that of the invention. The indirect measurement method of the droplet particle size based on the droplet migration speed does not need to write a program and does not need to analyze the complexity. Therefore, the crude oil emulsion particle size detection method provided by the invention can provide an accurate calculation result and occupies a smaller memory space.
The above-mentioned contents are only for illustrating the technical idea of the present invention, and the protection scope of the present invention is not limited thereby, and any modification made on the basis of the technical idea of the present invention falls within the protection scope of the claims of the present invention.

Claims (6)

1. A method for detecting the particle size of a crude oil emulsion is characterized by comprising the following steps:
s1: filtering and binarizing the crude oil emulsion micrograph to obtain an emulsion binary image;
s2: marking all connected domains in the emulsion binary image by a connected domain marking method, wherein one connected domain corresponds to one liquid drop; the specific method comprises the following steps:
s201: adding a circle of background pixels with the width of one pixel to the emulsion binary image;
s202: scanning each pixel of the emulsion binary image line by line, and marking each connected domain of the emulsion binary image by adopting different marking values through a connected domain marking method, wherein one connected domain corresponds to one liquid drop; the specific method comprises the following steps:
s202-1: scanning each pixel of the emulsion binary image line by line, and detecting the pixel type of the current pixel; the initialization flag value is 1;
s202-2: when the current pixel is a foreground pixel, marking the current pixel by adopting a current marking value, adding 1 to the marking value, and detecting the pixel types of a left pixel, an upper right pixel and an upper right pixel of the current pixel; otherwise, S202-7 is carried out;
s202-3: when the upper pixel of the current pixel is a background pixel and the left pixel and the upper right pixel are foreground pixels, taking the minimum mark value of the mark values of the left pixel and the upper right pixel of the current pixel to mark the current pixel again; the tag value is decremented by 1; otherwise, S202-4 is carried out;
s202-4: when the upper pixel of the current pixel is a background pixel and the upper left pixel and the upper right pixel are foreground pixels, taking the minimum mark value of the mark values of the upper left pixel and the upper right pixel of the current pixel to mark the current pixel again; the tag value is decremented by 1; otherwise, S202-5 is carried out;
s202-5: when at least one of the left pixel, the upper left pixel and the upper right pixel of the current pixel is a foreground pixel, taking the minimum mark value of the mark values of the left pixel, the upper left pixel and the upper right pixel of the current pixel to re-mark the current pixel; the tag value is decremented by 1;
s202-6: traversing the scanned pixels again every time one pixel is marked;
s202-7: when the current pixel is a background pixel, marking the current pixel by adopting 0;
s202-8: all pixels with the same mark value form a connected domain, and one connected domain corresponds to one liquid drop;
s3: the area and the perimeter of the liquid drop corresponding to each connected domain are respectively obtained by counting the number of pixels contained in the interior and the edge of each marked connected domain, and the particle size of the liquid drop is obtained through the area and the perimeter of the liquid drop.
2. The method for detecting the particle size of the crude oil emulsion according to claim 1, wherein the specific method of S1 is as follows:
and filtering the crude oil emulsion micrograph through a median filtering algorithm, and then performing binarization processing through an overall threshold Otsu algorithm to obtain an emulsion binary image.
3. The method for detecting the particle size of the crude oil emulsion according to claim 1, wherein the specific method of S3 is as follows:
obtaining the area and the perimeter of the liquid drop corresponding to the connected domain through the connected domain, and obtaining the image particle size of the liquid drop through the formula (1):
Figure FDA0003355586360000021
wherein, D [ i ] is the image grain size of the liquid drop; ai is the area of the droplet; pi is the perimeter of the drop;
the particle diameter d [ i ] of the droplet is obtained by the formula (2):
Figure FDA0003355586360000022
wherein H is the image height; w is the image width; DPIHVertical resolution of crude oil emulsion micrographs; DPIWHorizontal resolution of crude oil emulsion micrographs; m is1Is the microscope objective magnification; m is2The magnification of the microscope eyepiece.
4. The method for detecting particle size of crude oil emulsion according to claim 1, further comprising:
s4: the average particle diameter of the droplets is obtained by the formula (3) according to the particle diameter of each droplet:
Figure FDA0003355586360000031
wherein L is the total number of droplets;
the particle size distribution of all the droplets is counted and represented in the form of a bar chart or a graph.
5. A crude oil emulsion particle size detection apparatus comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 4 when executing the computer program.
6. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 4.
CN201911024998.8A 2019-10-25 2019-10-25 Crude oil emulsion particle size detection method and device and readable storage medium Active CN110736688B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911024998.8A CN110736688B (en) 2019-10-25 2019-10-25 Crude oil emulsion particle size detection method and device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911024998.8A CN110736688B (en) 2019-10-25 2019-10-25 Crude oil emulsion particle size detection method and device and readable storage medium

Publications (2)

Publication Number Publication Date
CN110736688A CN110736688A (en) 2020-01-31
CN110736688B true CN110736688B (en) 2022-04-01

Family

ID=69271441

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911024998.8A Active CN110736688B (en) 2019-10-25 2019-10-25 Crude oil emulsion particle size detection method and device and readable storage medium

Country Status (1)

Country Link
CN (1) CN110736688B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112945963A (en) * 2021-02-01 2021-06-11 中国石油大学(北京) Observation sample and observation method
CN115375685B (en) * 2022-10-25 2023-03-24 临沂天元混凝土工程有限公司 Method for detecting sand and stone particle size abnormity in concrete raw material
CN115715994B (en) * 2022-11-18 2023-11-21 深圳大学 Image excitation ultramicro injection method, system and equipment

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101620060A (en) * 2009-08-13 2010-01-06 上海交通大学 Automatic detection method of particle size distribution
CN103065314A (en) * 2012-12-28 2013-04-24 中国电子科技集团公司第五十四研究所 Image communicated domain rapid marking method based on linear description
CN104034637A (en) * 2014-06-26 2014-09-10 芜湖哈特机器人产业技术研究院有限公司 Diamond wire particle online quality inspection device based on machine vision
CN104089857A (en) * 2014-07-03 2014-10-08 天津大学 Measuring method of oil drop size
CN105261049A (en) * 2015-09-15 2016-01-20 重庆飞洲光电技术研究院 Quick detection method of image connection area
CN105404869A (en) * 2015-11-20 2016-03-16 陕西科技大学 Computer vision based fruit shape grading method
CN107067400A (en) * 2016-11-30 2017-08-18 南京航空航天大学 A kind of bianry image method for marking connected region based on the distance of swimming
CN109146908A (en) * 2018-07-25 2019-01-04 安徽师范大学 A kind of bianry image stream quick region identification algorithm
CN109598715A (en) * 2018-12-05 2019-04-09 山西镭谱光电科技有限公司 Material size online test method based on machine vision
US10430943B2 (en) * 2016-10-07 2019-10-01 Sony Corporation Automated nuclei area/number estimation for IHC image analysis

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101620060A (en) * 2009-08-13 2010-01-06 上海交通大学 Automatic detection method of particle size distribution
CN103065314A (en) * 2012-12-28 2013-04-24 中国电子科技集团公司第五十四研究所 Image communicated domain rapid marking method based on linear description
CN104034637A (en) * 2014-06-26 2014-09-10 芜湖哈特机器人产业技术研究院有限公司 Diamond wire particle online quality inspection device based on machine vision
CN104089857A (en) * 2014-07-03 2014-10-08 天津大学 Measuring method of oil drop size
CN105261049A (en) * 2015-09-15 2016-01-20 重庆飞洲光电技术研究院 Quick detection method of image connection area
CN105404869A (en) * 2015-11-20 2016-03-16 陕西科技大学 Computer vision based fruit shape grading method
US10430943B2 (en) * 2016-10-07 2019-10-01 Sony Corporation Automated nuclei area/number estimation for IHC image analysis
CN107067400A (en) * 2016-11-30 2017-08-18 南京航空航天大学 A kind of bianry image method for marking connected region based on the distance of swimming
CN109146908A (en) * 2018-07-25 2019-01-04 安徽师范大学 A kind of bianry image stream quick region identification algorithm
CN109598715A (en) * 2018-12-05 2019-04-09 山西镭谱光电科技有限公司 Material size online test method based on machine vision

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
The connected-component labeling problem_ A review of state-of-the-art algorithms;Lifeng He;《J Real-Time Image Proc》;20160802;1277–1287 *
基于计算机视觉的纸张填料粒径分析方法;姚斌 等;《中国造纸》;20190831;第38卷(第8期);46-50 *
基于连通域算法的区域测量;李仪芳;《科学技术与工程》;20080531;2492-2494 *

Also Published As

Publication number Publication date
CN110736688A (en) 2020-01-31

Similar Documents

Publication Publication Date Title
CN110736688B (en) Crude oil emulsion particle size detection method and device and readable storage medium
Wu et al. Automatic classification of ovarian cancer types from cytological images using deep convolutional neural networks
Vogt et al. Mapping spatial patterns with morphological image processing
EP3624053B1 (en) Image analysis device
Lindblad et al. Image analysis for automatic segmentation of cytoplasms and classification of Rac1 activation
JP2017521779A (en) Detection of nuclear edges using image analysis
JP2017107543A (en) Method and system for automated analysis of cell images
Koyuncu et al. Iterative h‐minima‐based marker‐controlled watershed for cell nucleus segmentation
Paulik et al. An optimized image analysis algorithm for detecting nuclear signals in digital whole slides for histopathology
CN108038481A (en) A kind of combination maximum extreme value stability region and the text positioning method of stroke width change
CN111145209A (en) Medical image segmentation method, device, equipment and storage medium
US8582861B2 (en) Method and apparatus for segmenting biological cells in a picture
CN112734729B (en) Water gauge water level line image detection method and device suitable for night light supplement condition and storage medium
WO2021000948A1 (en) Counterweight weight detection method and system, and acquisition method and system, and crane
Lim et al. Color and morphological based techniques on white blood cells segmentation
CN107369149B (en) Target object detection device and method
Shah et al. Automatic detection and classification of tuberculosis bacilli from ZN-stained sputum smear images using watershed segmentation
Ganapathy et al. A Malaysian vehicle license plate localization and recognition system
CN116868226A (en) Detection of annotated regions of interest in images
EP2875488B1 (en) Biological unit segmentation with ranking based on similarity applying a shape and scale descriptor
Khan et al. Segmentation approach towards phase-contrast microscopic images of activated sludge to monitor the wastewater treatment
CN116452809A (en) Line object extraction method based on semantic segmentation
Elter et al. Maximum-intensity-linking for segmentation of fluorescence-stained cells
Vasilopoulos et al. Automatic text extraction from arabic newspapers
CN117392691B (en) Chemical structural formula extraction method, system, equipment and storage medium

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
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230524

Address after: 710000 Room 1314, Block D, Haibo Plaza, Fengcheng 9th Road, Xi'an Economic and Technological Development Zone, Shaanxi Province

Patentee after: Xi'an Zhonghuixin Quality Testing Technology Co.,Ltd.

Address before: 710021 Shaanxi province Xi'an Weiyang University Park

Patentee before: SHAANXI University OF SCIENCE & TECHNOLOGY