改进型马尔科夫链蒙特卡洛二维岩石切片重构方法及系统Improved Markov chain Monte Carlo two-dimensional rock slice reconstruction method and system
本申请要求于2020年05月28日提交中国专利局、申请号为202010468814.3、发明名称为“改进型马尔科夫链蒙特卡洛二维岩石切片重构方法及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on May 28, 2020, the application number is 202010468814.3, and the invention title is "Improved Markov Chain Monte Carlo 2D Rock Slice Reconstruction Method and System" , Its entire content is incorporated into this application by reference.
技术领域Technical field
本发明属于计算机图像处理技术领域,涉及一种改进型马尔科夫链蒙特卡洛二维岩石切片重构方法及系统。The invention belongs to the technical field of computer image processing, and relates to an improved Markov chain Monte Carlo two-dimensional rock slice reconstruction method and system.
背景技术Background technique
图像重构因高便利和低成本广泛应用于医学、地质等各领域,其目的是对未知区域进行特征预判和结构分析。为了使重构图像的特性更贴合实际,选择合适的成像方法是影响重构效果的直接因素。Image reconstruction is widely used in various fields such as medicine and geology due to its high convenience and low cost, and its purpose is to perform feature prediction and structural analysis of unknown areas. In order to make the characteristics of the reconstructed image more suitable for reality, choosing a suitable imaging method is a direct factor that affects the reconstruction effect.
现有技术中,Kejian Wu的文章“An Efficient Markov Chain Model for the Simulation of Heterogeneous Soil Structure”对MCMC方法进行了系统的阐述,利用马尔科夫链的思想,选取合适的邻域系统从某一固定方向遍历扫描岩石电镜切片图像,对其分布规律进行统计分析得条件概率,再利用蒙特卡洛算法,求取随机数解决计算问题,通过变差函数的拟合来判断重构结果的优劣。但是,路径会在重构过程中不断变换方向,而且为了让结果更贴合原图,会为条件概率设置权重,直接改变了统计信息,并且变差函数的拟合效果无法定量判断。因此,在岩石图像的各向异性普遍存在的情况下,本发明提到的改进方法更合理。In the prior art, Kejian Wu’s article "An Efficient Markov Chain Model for the Simulation of Heterogeneous Soil Structure" systematically explained the MCMC method, using the idea of Markov chain to select an appropriate neighborhood system from a fixed The direction traverse scans the rock electron microscope slice image, the distribution law is statistically analyzed to obtain the conditional probability, and then the Monte Carlo algorithm is used to calculate the random number to solve the calculation problem, and the quality of the reconstruction result is judged by the fitting of the variogram function. However, the path will continue to change directions during the reconstruction process, and in order to make the result more closely fit the original image, weights are set for the conditional probability, which directly changes the statistical information, and the fitting effect of the variogram cannot be quantitatively judged. Therefore, when the anisotropy of the rock image is widespread, the improved method mentioned in the present invention is more reasonable.
发明内容Summary of the invention
针对现有技术中的缺陷和不足,本发明提供了一种改进型马尔科夫链蒙特卡洛二维岩石切片重构方法及系统,目的是针对岩石图像的各向异性这一广泛存在的特征,以及目前现有的技术未考虑由这一特性导致的条件概率也存在各向异性的问题。Aiming at the defects and deficiencies in the prior art, the present invention provides an improved Markov chain Monte Carlo two-dimensional rock slice reconstruction method and system, aiming at the widespread feature of rock image anisotropy , And the current existing technology does not consider the conditional probability caused by this feature and there is also an anisotropy problem.
为达到上述目的,本发明采取如下的技术方案:In order to achieve the above objectives, the present invention adopts the following technical solutions:
一种改进型马尔科夫链蒙特卡洛二维岩石切片重构方法,包括以下步骤:An improved Markov chain Monte Carlo 2D rock slice reconstruction method, including the following steps:
步骤一,对原图进行二值化,计算孔隙度:Step 1: Binarize the original image to calculate the porosity:
针对大小为m*n的原图,通过最大类间方差求得图像的阈值,根据阈值将原图二值化,统计不同像素值像素点总数,计算孔隙度如下:For the original image with a size of m*n, the threshold of the image is obtained by the maximum variance between classes, and the original image is binarized according to the threshold, and the total number of pixels with different pixel values is counted. The porosity is calculated as follows:
二值化图像中像素值为0的代表骨架,像素值为1的代表孔隙;上式中,num
1是像素值为1的像素点的总个数,num
0是像素值为0的像素点的总个数;
In the binarized image, a skeleton with a pixel value of 0 represents a skeleton, and a pore with a pixel value of 1 is represented; in the above formula, num 1 is the total number of pixels with a pixel value of 1, and num 0 is a pixel with a pixel value of 0 The total number of;
步骤二:确定邻域系统和条件概率计算公式:Step 2: Determine the neighborhood system and conditional probability calculation formula:
在步骤一得到的二值化图像基础上确定要用到的邻域系统,列出邻域系统所有可能出现的组合,并求每个组合条件下当前所求像素点分别为0或1的概率;条件概率计算公式为:Determine the neighborhood system to be used on the basis of the binarized image obtained in step 1, list all possible combinations of the neighborhood system, and find the probability that the current pixel is 0 or 1 under each combination condition ; The conditional probability calculation formula is:
该邻域条件下所求像素点为0的概率:Probability that the pixel is 0 under the neighborhood condition:
该邻域条件下所求像素点为1的概率:The probability that the pixel is 1 under the neighborhood condition:
上式中,N是领域系统中的某个组合,x
r是该组合中的像素点,x
(i,j)是当前所求像素点,num
r→0是在该组合条件下x
(i,j)为0的次数,num
r→1是x
(i,j)为1的次数;
In the above formula, N is a certain combination in the domain system, x r is the pixel in the combination, x (i,j) is the pixel currently sought, and num r→0 is the combination of x (i ,j) is the number of times that is 0, num r→1 is the number of times that x (i,j) is 1;
步骤三:确定重构路径及条件概率扫描方向:Step 3: Determine the reconstruction path and the conditional probability scan direction:
设置一张与原图大小相同的空图像,空图像中,在偶数行从右向左迭代求值,奇数行从左向右迭代求值,每行的第一个和最后一个像素点由它的上一行的同列像素点通过竖向二邻域求得,得到重构路径;根据重构路径,扫描步骤一得到的二值化图像各方向的条件概率;Set an empty image with the same size as the original image. In the empty image, iteratively evaluate from right to left on even-numbered rows, and iteratively evaluate from left to right on odd-numbered rows. The first and last pixels of each row are determined by it The pixel points in the same column in the previous row are obtained through the vertical two neighborhoods to obtain the reconstruction path; according to the reconstruction path, scan the conditional probability of each direction of the binarized image obtained in step 1;
步骤四:利用蒙特卡洛计算赋值:Step 4: Use Monte Carlo calculation and assignment:
把二值化图像中第一个像素点赋值空图像的第一个像素点,之后对第一行从左向右使用横向二邻域进行计算赋值,之后第二行最后一个像素值通过竖向二邻域,将第一行最后一个像素点作为条件,计算像素值,然后从第二行第n-1个像素点开始,用左向四邻域进行匹配计算,第三行从左向右迭代,之后的换行重复之前操作,直到最后一个像素点被确定;Assign the first pixel in the binarized image to the first pixel of the empty image, and then use the horizontal two-neighbors to calculate and assign the first row from left to right, and then the last pixel in the second row through the vertical Two-neighborhood, the last pixel in the first row is used as a condition to calculate the pixel value, and then starting from the n-1th pixel in the second row, the left-to-four-neighborhood is used for matching calculation, and the third row is iterated from left to right , Repeat the previous operation for the following line breaks, until the last pixel is determined;
步骤五:孔隙度满足条件停止循环,得到重构图像;Step 5: The porosity satisfies the condition to stop the loop, and the reconstructed image is obtained;
将孔隙度作为循环结束的条件,当重构图像的孔隙度P
KXD与原图孔隙度p
kxd满足下式,停止循环,得到重构图像;
Regarding the porosity as the condition for the end of the cycle, when the porosity P KXD of the reconstructed image and the original image porosity p kxd satisfy the following formula, the cycle is stopped, and the reconstructed image is obtained;
p
kxd-0.05≤P
KXD≤p
kxd+0.05(4)
p kxd -0.05≤P KXD ≤p kxd +0.05 (4)
否则,重新设置空图像重复步骤四和步骤五直至满足公式(4),最终得到重构图像。Otherwise, reset the empty image and repeat steps 4 and 5 until formula (4) is satisfied, and finally a reconstructed image is obtained.
本发明还包括如下技术特征:The invention also includes the following technical features:
具体的,对步骤五得到的重构图像进行评价,方法如下:分别计算二值化图像和重构图像的变差值;Specifically, the method for evaluating the reconstructed image obtained in step 5 is as follows: respectively calculating the variation value of the binarized image and the reconstructed image;
变差值计算公式如下:The calculation formula of the variation value is as follows:
其中,a是步长,即两点间距,在这里选取为1到50,N(a)是距离为a的两点的个数,x是像素值,i表示像素点坐标;Among them, a is the step length, that is, the distance between two points, which is selected from 1 to 50 here, N(a) is the number of two points with a distance of a, x is the pixel value, and i is the pixel point coordinate;
计算二值化图像和重构图像的变差函数曲线之间的距离平均值,计算公式如下:Calculate the average distance between the variogram of the binarized image and the reconstructed image. The calculation formula is as follows:
式中,R(a)是重构图像的变差值,r(a)为二值化图像的变差值;通过数据表征二值化图像和重构图像的变差曲线的拟合度,取重构图像与二值化图像在同一步长下变差值的差值,将不同步长下的差值累加取平均值,越小越拟合。In the formula, R(a) is the variation value of the reconstructed image, r(a) is the variation value of the binarized image; the data represents the fit of the variation curve of the binarized image and the reconstructed image, Take the difference between the reconstructed image and the binarized image at the same step length, and accumulate the difference under the non-synchronization length to get the average value, the smaller the value, the better the fit.
本发明还提供一种基于马尔科夫链蒙特卡洛的岩石切片重构系统,包括:The present invention also provides a rock slice reconstruction system based on Markov chain Monte Carlo, including:
孔隙度计算模块,用于通过最大类间方差求得原图的阈值,根据阈值将原图二值化,二值化后的图片中像素值为0的代表骨架,像素值为1的代表孔隙,统计像素值分别为0和1的像素点的总数,计算得到孔隙度;The porosity calculation module is used to obtain the threshold of the original image based on the maximum variance between clusters, and binarize the original image according to the threshold. The binarized image represents the skeleton with a pixel value of 0 and the pore with a pixel value of 1 , Count the total number of pixels with pixel values of 0 and 1, and calculate the porosity;
领域系统及条件概率确定模块,用于在二值化图像基础上确定邻域系统,列出邻域系统所有可能出现的组合,并求每个组合条件下像素值分别为0或1的概率;The domain system and conditional probability determination module is used to determine the neighborhood system based on the binary image, list all possible combinations of the neighborhood system, and find the probability that the pixel value is 0 or 1 under each combination condition;
重构路径及各方向条件概率确定模块,用于在空图像中,在偶数行是从右向左迭代求值,奇数行是从左向右迭代求值,每行的第一个和最后一个像素点由它的上一行的同列像素点通过竖向二邻域求得,确定重构路径;根据重构路径,扫描步骤一得到的二值化图像各方向的条件概率;Reconstruction path and conditional probability determination module in each direction. It is used to evaluate iteratively from right to left in even rows in an empty image, and iteratively evaluate from left to right in odd rows, the first and last of each row The pixel point is obtained from the pixel point in the same column of its previous row through the vertical two neighborhoods to determine the reconstruction path; according to the reconstruction path, scan the conditional probability of each direction of the binarized image obtained in step 1;
计算赋值模块,用于利用蒙特卡洛依次迭代计算空图像中的每一个像素值;The calculation and assignment module is used to iteratively calculate the value of each pixel in the empty image using Monte Carlo;
获取重构图像模块,用于将孔隙度作为循环结束的条件,得到重构图像;Obtain a reconstructed image module, which is used to use porosity as a condition for the end of the cycle to obtain a reconstructed image;
结果拟合度评价模块,用于通过数据表征二值化图像和重构图像的变差曲线的拟合度,取重构图像与二值化图像在同一步长下变差值的差值,将不同步长下的差值累加取平均值,越小越拟合。The result fit evaluation module is used to characterize the fit of the variation curve of the binarized image and the reconstructed image through data, and take the difference between the reconstructed image and the binarized image at the same step size, Accumulate the difference values under non-synchronization length to get the average value, the smaller the value, the better the fit.
本发明与现有技术相比,有益的技术效果是:Compared with the prior art, the present invention has the following beneficial technical effects:
本发明提出的MCMC重构方法,依据岩石图像的各向异性,考虑条件概率也存在各向异性的特征,从不同方向扫描得该方向的条件概率,在迭代求值过程中,使条件概率扫描方向与重构路径相匹配,并选取随机数重构图像,把各方向的影响作用均衡化,在表征各向异性的同时,提高重构图像与原图像的变差函数的拟合度。The MCMC reconstruction method proposed by the present invention, based on the anisotropy of the rock image, considers that the conditional probability also has the characteristics of anisotropy. The conditional probability of this direction is scanned from different directions. In the iterative evaluation process, the conditional probability is scanned The direction is matched with the reconstruction path, and random numbers are selected to reconstruct the image, and the influence of each direction is equalized. While characterizing the anisotropy, it improves the fit of the variogram between the reconstructed image and the original image.
说明书附图Attached drawings
图1是岩石电镜扫描原图像A与二值化示意图B;Figure 1 is a schematic diagram B of original image A and binarization scanned by a rock electron microscope;
图2是横向和竖向二邻域示意图;(灰色为邻域系统像素点)Figure 2 is a schematic diagram of the horizontal and vertical two neighborhoods; (gray is the neighborhood system pixels)
图3是左向和右向四邻域示意图;(灰色为邻域系统像素点)Figure 3 is a schematic diagram of the left and right four neighborhoods; (gray is the pixels of the neighborhood system)
图4是蛇形重构路径示意图;Figure 4 is a schematic diagram of a serpentine reconstruction path;
图5是现有技术方法和本发明成像结果示意图;Figure 5 is a schematic diagram of the prior art method and the imaging result of the present invention;
图6是变差函数拟合曲线示意图;Figure 6 is a schematic diagram of a variogram fitting curve;
图7是本发明流程图。Figure 7 is a flow chart of the present invention.
以下对本发明的具体实施方式进行详细说明。应当理解的是,此处所描述的具体实施方式仅用于说明和解释本发明,并不用于限制本发明。The specific embodiments of the present invention will be described in detail below. It should be understood that the specific embodiments described here are only used to illustrate and explain the present invention, and are not used to limit the present invention.
具体实施方式Detailed ways
本发明针对岩石切片电镜扫描图像表现的各向异性的特征,利用马尔科夫链思想和蒙特卡洛采样方法,考虑到了因岩石图像的特征信息导致在不同方向条件概率表现出的各向异性,并利用迭代计算的方式进行成像显示。The present invention aims at the characteristics of anisotropy in the scanning images of rock slices by electron microscopy, uses Markov chain ideas and Monte Carlo sampling methods, and takes into account the anisotropy shown in conditional probabilities in different directions due to the characteristic information of the rock image. And use iterative calculation method for imaging display.
实施例1:Example 1:
如图1至图7所示,本实施例提供一种改进型马尔科夫链蒙特卡洛二维岩石切片重构方法,图7为本发明的流程图,本方法对条件概率的扫描方式进行各向异性的考量,使条件概率扫描方向与重构路径相匹配,并选取随机数重构图像,把各方向的影响作用均衡化,表征各向异性的同时提高重构图像与原图的变差函数的拟合度;具体包括以下步骤:As shown in Figures 1 to 7, this embodiment provides an improved Markov chain Monte Carlo two-dimensional rock slice reconstruction method. Figure 7 is a flowchart of the present invention. This method performs conditional probability scanning. Considering the anisotropy, match the conditional probability scanning direction with the reconstruction path, and select random numbers to reconstruct the image, equalize the influence of each direction, and characterize the anisotropy while improving the change between the reconstructed image and the original image. The degree of fit of the difference function; specifically includes the following steps:
步骤一,对原图进行二值化,计算孔隙度:Step 1: Binarize the original image to calculate the porosity:
图1左A为原图,针对大小为m*n的原图,通过最大类间方差求得图像的阈值,根据阈值将原图二值化,图1右B是二值化岩石图像,统计不同像素值像素点总数,计算孔隙度如下:The left A of Figure 1 is the original image. For the original image of size m*n, the threshold of the image is obtained by the maximum inter-class variance, and the original image is binarized according to the threshold. The right B of Figure 1 is the binarized rock image. Statistics The total number of pixels with different pixel values, and the porosity is calculated as follows:
二值化图像中像素值为0的代表骨架,像素值为1的代表孔隙;上式中,num
1是像素值为1的像素点的总个数,num
0是像素值为0的像素点 的总个数;具体的,在本实施例中,图1右B二值化岩石图像计算其孔隙率为17.68%;
In the binarized image, a skeleton with a pixel value of 0 represents a skeleton, and a pore with a pixel value of 1 is represented; in the above formula, num 1 is the total number of pixels with a pixel value of 1, and num 0 is a pixel with a pixel value of 0 Specifically, in this embodiment, the porosity of the binarized rock image calculated from the right B of Figure 1 is 17.68%;
步骤二:确定邻域系统和条件概率计算公式:Step 2: Determine the neighborhood system and conditional probability calculation formula:
在步骤一得到的二值化图像基础上确定要用到的邻域系统,列出邻域系统所有可能出现的组合,并求每个组合条件下当前所求像素点分别为0或1的概率;条件概率计算公式为:Determine the neighborhood system to be used on the basis of the binarized image obtained in step 1, list all possible combinations of the neighborhood system, and find the probability that the current pixel is 0 or 1 under each combination condition ; The conditional probability calculation formula is:
该邻域条件下所求像素点为0的概率:The probability that the pixel is zero under the neighborhood condition:
该邻域条件下所求像素点为1的概率:The probability that the pixel is 1 under the neighborhood condition:
上式中,N是领域系统中的某个组合,x
r是该组合中的像素点,x
(i,j)是当前所求像素点,num
r→0是在该组合条件下x
(i,j)为0的次数,num
r→1是x
(i,j)为1的次数;
In the above formula, N is a certain combination in the domain system, x r is the pixel in the combination, x (i,j) is the pixel currently sought, and num r→0 is the combination of x (i ,j) is the number of times that is 0, num r→1 is the number of times that x (i,j) is 1;
本实施例中,图2分别为横向和竖向二邻域,它的条件概率计算公式为:In this embodiment, Figure 2 shows the horizontal and vertical two neighborhoods respectively, and its conditional probability calculation formula is:
其中,N
2是二邻域的某个组合,x
r是该组合中的像素点,x
(i,j)是当前所求像素点,num
r→0是在该组合条件下x
(i,j)为0的次数,num
r→1是x
(i,j)为1的次数;左边表达式计算该邻域条件下所求像素点为0的概率,右边表达式计算该邻域条件下所求像素点为1的概率;
Among them, N 2 is a certain combination of two neighborhoods, x r is the pixel in the combination, x (i,j) is the pixel currently sought, and num r→0 is x (i, j) is the number of times 0, num r→1 is the number of times x (i, j) is 1; the expression on the left calculates the probability that the pixel is 0 under the condition of the neighborhood, and the expression on the right calculates the probability of the pixel under the condition of the neighborhood The probability that the pixel is 1;
图3为左向和右向四邻域,它的条件概率计算公式为:Figure 3 shows the left and right four neighborhoods, and its conditional probability calculation formula is:
其中,N
4是二邻域的某个组合,x
r是该组合中的像素点,x
(i,j)是当前所求像素点,num
r→0是在该组合条件下x
(i,j)为0的次数,num
r→1是x
(i,j)为1的次数;左边表达式计算该邻域条件下所求像素点为0的概率,右边表达式计算该邻域条件下所求像素点为1的概率;相关解释与二邻域类似;
Among them, N 4 is a certain combination of two neighborhoods, x r is the pixel in the combination, x (i,j) is the pixel currently sought, and num r→0 is x (i, j) is the number of times 0, num r→1 is the number of times x (i, j) is 1; the expression on the left calculates the probability that the pixel is 0 under the condition of the neighborhood, and the expression on the right calculates the probability of the pixel under the condition of the neighborhood The probability that the pixel is 1; the related explanation is similar to the second neighborhood;
步骤三:确定重构路径及条件概率扫描方向:Step 3: Determine the reconstruction path and the conditional probability scan direction:
图4为蛇形路径的原理图,设置一张与原图大小相同的空图像,空图像中,在偶数行是从右向左迭代求值,奇数行是从左向右迭代求值,每行的第一个和最后一个像素点由它的上一行的同列像素点通过竖向二邻域求得,得到重构路径;根据重构路径,扫描步骤一得到的二值化图像各方向的条件概率;Figure 4 is the principle diagram of the serpentine path. An empty image with the same size as the original image is set. In the empty image, the even rows are evaluated iteratively from right to left, and the odd rows are evaluated iteratively from left to right. The first and last pixel of the row are obtained from the pixels in the same column of the previous row through the vertical two neighborhoods to obtain the reconstruction path; according to the reconstruction path, scan the binarized image obtained in step 1 for each direction Conditional Probability;
步骤四:利用蒙特卡洛计算赋值:Step 4: Use Monte Carlo calculation and assignment:
把二值化图像中第一个像素点赋值空图像的第一个像素点,之后对第一行从左向右使用横向二邻域进行计算赋值,之后第二行最后一个像素值通过竖向二邻域,将第一行最后一个像素点作为条件,计算像素值,然后从第二行第n-1个像素点开始,用左向四邻域进行匹配计算,第三行从左向右迭代,之后的换行重复之前操作,直到最后一个像素点被确定;Assign the first pixel in the binarized image to the first pixel of the empty image, and then use the horizontal two-neighbors to calculate and assign the first row from left to right, and then the last pixel in the second row through the vertical Two-neighborhood, the last pixel in the first row is used as a condition to calculate the pixel value, and then starting from the n-1th pixel in the second row, the left-to-four-neighborhood is used for matching calculation, and the third row is iterated from left to right , Repeat the previous operation for the following line breaks, until the last pixel is determined;
步骤五:孔隙度满足条件停止循环,得到重构图像;Step 5: The porosity satisfies the condition to stop the loop, and the reconstructed image is obtained;
将孔隙度作为循环结束的条件,当重构图像的孔隙度P
KXD与原图孔隙度p
kxd满足下式,停止循环,否则,重新设置空图像重复步骤四和步骤五;
Regarding the porosity as the condition for the end of the cycle, when the porosity P KXD of the reconstructed image and the original image porosity p kxd meet the following formula, stop the cycle, otherwise, reset the empty image and repeat steps 4 and 5;
p
kxd-0.05≤P
KXD≤p
kxd+0.05(4)
p kxd -0.05≤P KXD ≤p kxd +0.05 (4)
具体的,图5A是现有技术中使用对二值化图像扫描一次得到的条件概率的重构图像;图5B是本实施例中使用与重构方向相同的条件概率的 重构图像;这两张图像的孔隙度分别为14.21%和19.36%,都达到了循环结束的条件。Specifically, FIG. 5A is a reconstructed image using the conditional probability obtained by scanning the binarized image once in the prior art; FIG. 5B is a reconstructed image using the same conditional probability as the reconstruction direction in this embodiment; both The porosity of the image is 14.21% and 19.36%, both of which have reached the condition for the end of the cycle.
步骤六:分别计算二值化图像和重构图像的变差值;Step 6: Calculate the variation values of the binarized image and the reconstructed image respectively;
变差值计算公式如下:The calculation formula of the variation value is as follows:
其中,a是步长,即两点间距,在这里选取为1到50,N(a)是距离为a的两点的个数,x是像素值,i表示像素点坐标;Among them, a is the step length, that is, the distance between two points, which is selected from 1 to 50 here, N(a) is the number of two points with a distance of a, x is the pixel value, and i is the pixel point coordinate;
计算二值化图像和重构图像的变差函数曲线之间的距离平均值,计算公式如下:Calculate the average distance between the variogram of the binarized image and the reconstructed image. The calculation formula is as follows:
式中,R(a)是重构图像的变差值,r(a)为二值化图像的变差值;通过数据表征二值化图像和重构图像的变差曲线的拟合度,取重构图像与二值化图像在同一步长下变差值的差值,将不同步长下的差值累加取平均值,越小越拟合。In the formula, R(a) is the variation value of the reconstructed image, r(a) is the variation value of the binarized image; the data represents the fit of the variation curve of the binarized image and the reconstructed image, Take the difference between the reconstructed image and the binarized image at the same step length, and accumulate the difference under the non-synchronization length to get the average value, the smaller the value, the better the fit.
图6是三张图像的变差函数,标点是原图变差值,红线是现有技术图5A,蓝线是本实施例图5B,可以看到蓝线更加拟合标点,它们与标点之间的平均距离分别为0.0208(图5A)和0.0073(图5B),在重构过程中使用与重构路径同方向的条件概率,即使用本发明方法的成像效果更好。Figure 6 is the variogram of the three images, the punctuation is the original image variability, the red line is the prior art Figure 5A, the blue line is the embodiment of Figure 5B, you can see that the blue line is more fitted to the punctuation, they are different from the punctuation The average distance between the two is 0.0208 (FIG. 5A) and 0.0073 (FIG. 5B), respectively. In the reconstruction process, the conditional probability in the same direction as the reconstruction path is used, that is, the imaging effect of the method of the present invention is better.
实施例2:Example 2:
本实施例提供一种基于马尔科夫链蒙特卡洛的岩石切片重构系统,包括:This embodiment provides a rock slice reconstruction system based on Markov chain Monte Carlo, including:
孔隙度计算模块,用于通过最大类间方差求得原图的阈值,根据阈值将原图二值化,二值化后的图片中像素值为0的代表骨架,像素值为1的代表孔隙,统计像素值分别为0和1的像素点的总数,计算得到孔隙度;The porosity calculation module is used to obtain the threshold of the original image based on the maximum variance between clusters, and binarize the original image according to the threshold. The binarized image represents the skeleton with a pixel value of 0 and the pore with a pixel value of 1 , Count the total number of pixels with pixel values of 0 and 1, and calculate the porosity;
领域系统及条件概率确定模块,用于在二值化图像基础上确定邻域系统,列出邻域系统所有可能出现的组合,并求每个组合条件下像素值分别 为0或1的概率;The domain system and conditional probability determination module is used to determine the neighborhood system based on the binarized image, list all possible combinations of the neighborhood system, and calculate the probability that the pixel value is 0 or 1 under each combination condition;
重构路径及各方向条件概率确定模块,用于在空图像中,在偶数行是从右向左迭代求值,奇数行是从左向右迭代求值,每行的第一个和最后一个像素点由它的上一行的同列像素点通过竖向二邻域求得,确定重构路径;根据重构路径,扫描步骤一得到的二值化图像各方向的条件概率;Reconstruction path and conditional probability determination module for each direction. It is used to evaluate iteratively from right to left in even rows in an empty image, and iteratively evaluate from left to right in odd rows, the first and last of each row The pixel point is obtained from the pixel point in the same column of its previous row through the vertical two neighborhoods to determine the reconstruction path; according to the reconstruction path, scan the conditional probability of each direction of the binarized image obtained in step 1;
计算赋值模块,用于利用蒙特卡洛依次迭代计算确定空图像的每个点的像素值;The calculation and assignment module is used to use Monte Carlo to iteratively calculate and determine the pixel value of each point of the empty image;
获取重构图像模块,用于将孔隙度作为循环结束的条件,得到重构图像;Obtain a reconstructed image module, which is used to use porosity as a condition for the end of the cycle to obtain a reconstructed image;
结果拟合度评价模块,用于通过数据表征二值化图像和重构图像的变差曲线的拟合度,取重构图像与二值化图像在同一步长下变差值的差值,将不同步长下的差值累加取平均值,越小越拟合。The result fit evaluation module is used to characterize the fit of the variation curve of the binarized image and the reconstructed image through data, and take the difference between the reconstructed image and the binarized image at the same step size, Accumulate the difference values under non-synchronization length to get the average value, the smaller the value, the better the fit.