水平集分割

2023-11-02

基于距离正则的水平集分割MATLAB代码,无需初始化

%  This Matlab code demonstrates an edge-based active contour model as an application of 
%  the Distance Regularized Level Set Evolution (DRLSE) formulation in the following paper:
%
%  C. Li, C. Xu, C. Gui, M. D. Fox, "Distance Regularized Level Set Evolution and Its Application to Image Segmentation", 
%     IEEE Trans. Image Processing, vol. 19 (12), pp. 3243-3254, 2010.
%
% Author: Chunming Li, all rights reserved
% E-mail: lchunming@gmail.com   
%         li_chunming@hotmail.com 
% URL:  http://www.imagecomputing.org/~cmli//
clear all;
close all;
Img=imread('gourd.bmp');
Img=double(Img(:,:,1));
%% parameter setting
timestep=1;  % time step
mu=0.2/timestep;  % coefficient of the distance regularization term R(phi)
iter_inner=5;
iter_outer=20;
lambda=5; % coefficient of the weighted length term L(phi)
alfa=-3;  % coefficient of the weighted area term A(phi)
epsilon=1.5; % papramater that specifies the width of the DiracDelta function
sigma=.8;    % scale parameter in Gaussian kernel
G=fspecial('gaussian',15,sigma); % Caussian kernel
Img_smooth=conv2(Img,G,'same');  % smooth image by Gaussiin convolution
[Ix,Iy]=gradient(Img_smooth);
f=Ix.^2+Iy.^2;
g=1./(1+f);  % edge indicator function.
% initialize LSF as binary step function
c0=2;
initialLSF = c0*ones(size(Img));
% generate the initial region R0 as two rectangles
initialLSF(25:35,20:25)=-c0; 
initialLSF(25:35,40:50)=-c0;
phi=initialLSF;
figure(1);
mesh(-phi);   % for a better view, the LSF is displayed upside down
hold on;  contour(phi, [0,0], 'r','LineWidth',2);
title('Initial level set function');
view([-80 35]);
figure(2);
imagesc(Img,[0, 255]); axis off; axis equal; colormap(gray); hold on;  contour(phi, [0,0], 'r');
title('Initial zero level contour');
pause(0.5);
potential=2;  
if potential ==1
    potentialFunction = 'single-well';  % use single well potential p1(s)=0.5*(s-1)^2, which is good for region-based model 
elseif potential == 2
    potentialFunction = 'double-well';  % use double-well potential in Eq. (16), which is good for both edge and region based models
else
    potentialFunction = 'double-well';  % default choice of potential function
end  
% start level set evolution
for n=1:iter_outer
    phi = drlse_edge(phi, g, lambda, mu, alfa, epsilon, timestep, iter_inner, potentialFunction);    
    if mod(n,2)==0
        figure(2);
        imagesc(Img,[0, 255]); axis off; axis equal; colormap(gray); hold on;  contour(phi, [0,0], 'r');
    end
end
% refine the zero level contour by further level set evolution with alfa=0
alfa=0;
iter_refine = 10;
phi = drlse_edge(phi, g, lambda, mu, alfa, epsilon, timestep, iter_inner, potentialFunction);
finalLSF=phi;
figure(2);
imagesc(Img,[0, 255]); axis off; axis equal; colormap(gray); hold on;  contour(phi, [0,0], 'r');
hold on;  contour(phi, [0,0], 'r');
str=['Final zero level contour, ', num2str(iter_outer*iter_inner+iter_refine), ' iterations'];
title(str);
figure;
mesh(-finalLSF); % for a better view, the LSF is displayed upside down
hold on;  contour(phi, [0,0], 'r','LineWidth',2);
view([-80 35]);
str=['Final level set function, ', num2str(iter_outer*iter_inner+iter_refine), ' iterations'];
title(str);
axis on;
[nrow, ncol]=size(Img);
axis([1 ncol 1 nrow -5 5]);
set(gca,'ZTick',[-3:1:3]);
set(gca,'FontSize',14)
%  This Matlab code demonstrates an edge-based active contour model as an application of 
%  the Distance Regularized Level Set Evolution (DRLSE) formulation in the following paper:
%
%  C. Li, C. Xu, C. Gui, M. D. Fox, "Distance Regularized Level Set Evolution and Its Application to Image Segmentation", 
%     IEEE Trans. Image Processing, vol. 19 (12), pp. 3243-3254, 2010.
%
% Author: Chunming Li, all rights reserved
% E-mail: lchunming@gmail.com   
%         li_chunming@hotmail.com 
% URL:  http://www.imagecomputing.org/~cmli//
clear all;
close all;
Img=imread('gourd.bmp');
Img=double(Img(:,:,1));
%% parameter setting
timestep=1;  % time step
mu=0.2/timestep;  % coefficient of the distance regularization term R(phi)
iter_inner=5;
iter_outer=20;
lambda=5; % coefficient of the weighted length term L(phi)
alfa=-3;  % coefficient of the weighted area term A(phi)
epsilon=1.5; % papramater that specifies the width of the DiracDelta function
sigma=.8;    % scale parameter in Gaussian kernel
G=fspecial('gaussian',15,sigma); % Caussian kernel
Img_smooth=conv2(Img,G,'same');  % smooth image by Gaussiin convolution
[Ix,Iy]=gradient(Img_smooth);
f=Ix.^2+Iy.^2;
g=1./(1+f);  % edge indicator function.
% initialize LSF as binary step function
c0=2;
initialLSF = c0*ones(size(Img));
% generate the initial region R0 as two rectangles
initialLSF(25:35,20:25)=-c0; 
initialLSF(25:35,40:50)=-c0;
phi=initialLSF;
figure(1);
mesh(-phi);   % for a better view, the LSF is displayed upside down
hold on;  contour(phi, [0,0], 'r','LineWidth',2);
title('Initial level set function');
view([-80 35]);
figure(2);
imagesc(Img,[0, 255]); axis off; axis equal; colormap(gray); hold on;  contour(phi, [0,0], 'r');
title('Initial zero level contour');
pause(0.5);
potential=2;  
if potential ==1
    potentialFunction = 'single-well';  % use single well potential p1(s)=0.5*(s-1)^2, which is good for region-based model 
elseif potential == 2
    potentialFunction = 'double-well';  % use double-well potential in Eq. (16), which is good for both edge and region based models
else
    potentialFunction = 'double-well';  % default choice of potential function
end  
% start level set evolution
for n=1:iter_outer
    phi = drlse_edge(phi, g, lambda, mu, alfa, epsilon, timestep, iter_inner, potentialFunction);    
    if mod(n,2)==0
        figure(2);
        imagesc(Img,[0, 255]); axis off; axis equal; colormap(gray); hold on;  contour(phi, [0,0], 'r');
    end
end
% refine the zero level contour by further level set evolution with alfa=0
alfa=0;
iter_refine = 10;
phi = drlse_edge(phi, g, lambda, mu, alfa, epsilon, timestep, iter_inner, potentialFunction);
finalLSF=phi;
figure(2);
imagesc(Img,[0, 255]); axis off; axis equal; colormap(gray); hold on;  contour(phi, [0,0], 'r');
hold on;  contour(phi, [0,0], 'r');
str=['Final zero level contour, ', num2str(iter_outer*iter_inner+iter_refine), ' iterations'];
title(str);
figure;
mesh(-finalLSF); % for a better view, the LSF is displayed upside down
hold on;  contour(phi, [0,0], 'r','LineWidth',2);
view([-80 35]);
str=['Final level set function, ', num2str(iter_outer*iter_inner+iter_refine), ' iterations'];
title(str);
axis on;
[nrow, ncol]=size(Img);
axis([1 ncol 1 nrow -5 5]);
set(gca,'ZTick',[-3:1:3]);
set(gca,'FontSize',14)
function phi = drlse_edge(phi_0, g, lambda,mu, alfa, epsilon, timestep, iter, potentialFunction)
%  This Matlab code implements an edge-based active contour model as an
%  application of the Distance Regularized Level Set Evolution (DRLSE) formulation in Li et al's paper:
%
%      C. Li, C. Xu, C. Gui, M. D. Fox, "Distance Regularized Level Set Evolution and Its Application to Image Segmentation", 
%        IEEE Trans. Image Processing, vol. 19 (12), pp.3243-3254, 2010.
%
%  Input:
%      phi_0: level set function to be updated by level set evolution
%      g: edge indicator function
%      mu: weight of distance regularization term
%      timestep: time step
%      lambda: weight of the weighted length term
%      alfa:   weight of the weighted area term
%      epsilon: width of Dirac Delta function
%      iter: number of iterations
%      potentialFunction: choice of potential function in distance regularization term. 
%              As mentioned in the above paper, two choices are provided: potentialFunction='single-well' or
%              potentialFunction='double-well', which correspond to the potential functions p1 (single-well) 
%              and p2 (double-well), respectively.%
%  Output:
%      phi: updated level set function after level set evolution
%
% Author: Chunming Li, all rights reserved
% E-mail: lchunming@gmail.com   
%         li_chunming@hotmail.com 
% URL:  http://www.imagecomputing.org/~cmli/
phi=phi_0;
[vx, vy]=gradient(g);
for k=1:iter
    phi=NeumannBoundCond(phi);
    [phi_x,phi_y]=gradient(phi);
    s=sqrt(phi_x.^2 + phi_y.^2);
    smallNumber=1e-10;  
    Nx=phi_x./(s+smallNumber); % add a small positive number to avoid division by zero
    Ny=phi_y./(s+smallNumber);
    curvature=div(Nx,Ny);
    if strcmp(potentialFunction,'single-well')
        distRegTerm = 4*del2(phi)-curvature;  % compute distance regularization term in equation (13) with the single-well potential p1.
    elseif strcmp(potentialFunction,'double-well');
        distRegTerm=distReg_p2(phi);  % compute the distance regularization term in eqaution (13) with the double-well potential p2.
    else
        disp('Error: Wrong choice of potential function. Please input the string "single-well" or "double-well" in the drlse_edge function.');
    end        
    diracPhi=Dirac(phi,epsilon);
    areaTerm=diracPhi.*g; % balloon/pressure force
    edgeTerm=diracPhi.*(vx.*Nx+vy.*Ny) + diracPhi.*g.*curvature;
    phi=phi + timestep*(mu*distRegTerm + lambda*edgeTerm + alfa*areaTerm);
end
function f = distReg_p2(phi)
% compute the distance regularization term with the double-well potential p2 in eqaution (16)
[phi_x,phi_y]=gradient(phi);
s=sqrt(phi_x.^2 + phi_y.^2);
a=(s>=0) & (s<=1);
b=(s>1);
ps=a.*sin(2*pi*s)/(2*pi)+b.*(s-1);  % compute first order derivative of the double-well potential p2 in eqaution (16)
dps=((ps~=0).*ps+(ps==0))./((s~=0).*s+(s==0));  % compute d_p(s)=p'(s)/s in equation (10). As s-->0, we have d_p(s)-->1 according to equation (18)
f = div(dps.*phi_x - phi_x, dps.*phi_y - phi_y) + 4*del2(phi);  
function f = div(nx,ny)
[nxx,junk]=gradient(nx);  
[junk,nyy]=gradient(ny);
f=nxx+nyy;
function f = Dirac(x, sigma)
f=(1/2/sigma)*(1+cos(pi*x/sigma));
b = (x<=sigma) & (x>=-sigma);
f = f.*b;
function g = NeumannBoundCond(f)
% Make a function satisfy Neumann boundary condition
[nrow,ncol] = size(f);
g = f;
g([1 nrow],[1 ncol]) = g([3 nrow-2],[3 ncol-2]);  
g([1 nrow],2:end-1) = g([3 nrow-2],2:end-1);          
g(2:end-1,[1 ncol]) = g(2:end-1,[3 ncol-2]);  

LeveSet 水平集方法主要的思想是利用三维(高维)曲面的演化来表示二维曲线的演化过程。在计算机视觉领域,利用水平集方法可以实现很好的图像分割效果。

1.数学原理

根据维基百科的定义,在数学上一个包含n个变量的实值函数其水平集可以表示为下面的公式:
L c ( f ) = ( x 1 , x 2 , . . . , x n ) ∣ f ( x 1 , x 2 , . . . , x n ) = c L c ( f ) = ( x 1 , x 2 , . . . , x n ) ∣ f ( x 1 , x 2 , . . . , x n ) = c L c ​ ( f ) = ( x 1 ​ , x 2 ​ , . . . , x n ​ ) ∣ f ( x 1 ​ , x 2 ​ , . . . , x n ​ ) = c Lc(f)=(x1,x2,...,xn)∣f(x1,x2,...,xn)=cL_c(f) = {(x_1,x_2,...,x_n)|f(x_1,x_2,...,x_n) = c}Lc​(f)=(x1​,x2​,...,xn​)∣f(x1​,x2​,...,xn​)=c Lc(f)=(x1,x2,...,xn)f(x1,x2,...,xn)=cLc(f)=(x1,x2,...,xn)f(x1,x2,...,xn)=cLc(f)=(x1,x2,...,xn)f(x1,x2,...,xn)=c
可以看出,水平集指的是这个函数的取值为一个给定的常数c.那么当变量个数为2时,这个函数的水平集就变味了一条曲线,也可以成为等高线。这时函数f就可以描述一个曲面。(同样,三个变量时就能得到一个等值面,大于3的就是水平超面了)
下面来看一个简单的曲面的水平集(等值线的例子):

上图中,左边是Himmelblau方程所描述的曲面即 z = f ( x , y ) z = f ( x , y ) z = f ( x , y ) z=f(x,y)z=f(x,y)z=f(x,y) z=f(x,y)z=f(x,y)z=f(x,y),右边就是这个曲面的等高线集合,其中每一条就对应着一个常数c的水平集。

2.水平集方法

在计算机视觉中,利用水平集方法的优势在于,可以利用这种方法在固定的坐标系中,计算曲线、曲面的演化,而无需知道曲线曲面的参数,所以这种方法又称为几何法。
具体来讲,在图像分割任务中如果要得到每个物体准确的包络曲线,就需要对去描述这个曲线在xy坐标系下的演化。最初曲线在二维图像平面上是这样的:
y = g ( x ) y = g ( x ) y = g ( x ) y=g(x)y=g(x)y=g(x) y=g(x)y=g(x)y=g(x)
图割过程就是要找出一条比较好的曲面来包围物体。
但是这个函数求解和计算比较困难,那么就可以用水平集的思想和方法来解决:

1.首先将这个曲线看成是某个三维曲面下的某一条等高线:
z = f ( x , y ) z = f ( x , y ) z = f ( x , y ) z=f(x,y)z = f(x,y)z=f(x,y) z=f(x,y)z=f(x,y)z=f(x,y)
f ( x , y ) f ( x , y ) f ( x , y ) f(x,y)f(x,y)f(x,y) f(x,y)f(x,y)f(x,y)就可以看做是一个xy的隐函数方程。

2.特别的,在二维图像领域一般将上面讲到的函数 z = f ( x , y ) z = f ( x , y ) z = f ( x , y ) z=f(x,y)z=f(x,y)z=f(x,y) z=f(x,y)z=f(x,y)z=f(x,y)设置为0,刚刚所说的曲面的零水平集就是图像上的边缘包络
z = f ( x , y ) = 0 z = f ( x , y ) = 0 z = f ( x , y ) = 0 z=f(x,y)=0z=f(x,y)=0z=f(x,y)=0 z=f(x,y)=0z=f(x,y)=0z=f(x,y)=0
或者更为标准的形式如下:
Γ = ( x , y ) ∣ z ( x , y ) = 0 Γ = ( x , y ) ∣ z ( x , y ) = 0 Γ = ( x , y ) ∣ z ( x , y ) = 0 Γ=(x,y)∣z(x,y)=0\Gamma = {(x,y)| z(x,y)=0}Γ=(x,y)∣z(x,y)=0 Γ=(x,y)z(x,y)=0Γ=(x,y)z(x,y)=0Γ=(x,y)z(x,y)=0
这时,z(x,y)=f(x,y)就是辅助函数,用三维的曲面来辅助表示二维的曲线。
在这里插入图片描述
这里还有一个假设, Γ Γ Γ Γ\GammaΓ ΓΓΓ零水平集内部的(包络内的)为正外面为负。

这里有个重要的性质,基于高维曲面水平集方法得到的这个零水平集曲线是封闭的、连续的、处处可导的,这就为后面的图像分割提供了基础。

3.零水平集演化

为了获得与图像边缘相适应的结果,z需要进行演化才能使得其0水平集所描述的曲线很好的包裹住需要分割的物体,那么此时就涉及到方程的演化:
Γ ( t ) = ( x , y ) ∣ z ( x , y ) = 0 Γ ( t ) = ( x , y ) ∣ z ( x , y ) = 0 Γ ( t ) = ( x , y ) ∣ z ( x , y ) = 0 Γ(t)=(x,y)∣z(x,y)=0\Gamma(t) = {(x,y)| z(x,y)=0}Γ(t)=(x,y)∣z(x,y)=0 Γ(t)=(x,y)z(x,y)=0Γ(t)=(x,y)z(x,y)=0Γ(t)=(x,y)z(x,y)=0
∂ z ∂ t = v ∣ Δ z ∣ ∂ z ∂ t = v ∣ Δ z ∣ ∂ t ∂ z ​ = v ∣ Δ z ∣ ∂z∂t=v∣Δz∣\dfrac{\partial z}{\partial t} = v |\Delta z|∂t∂z​=v∣Δz∣ zt=vΔztz=vΔztz=vΔz
这里是一个曲面演化后,其零水平集演化的过程:
在这里插入图片描述
要促使边缘演化成包络object的形式,需要一个所谓的图像力来促使其变化,这时候就需要利用图像中的梯度来作为这个图像力的组成部分驱动曲线去靠近边缘。下图是一个例子,作图是原图,右图是梯度图。
在这里插入图片描述
<font color=dodgerblue<那么这个图像力就需要在原理边缘的时候大,靠近边缘的时候缩小,直到贴合边缘。
在这里插入图片描述
在梯度的驱动下,其演化过程如上图所示。

4.如何求解最小值

上面的问题在数学中可以归结为能量泛函问题,求解边缘的过程就是这个水平集能量泛函最小化的过程。
著名的方法来自于下面这篇文章:
Level Set Evolution Without Re-initialization: A New Variational Formulation
作者(李明纯)通过引入了内部能量项来惩罚由信号距离函数造成的水平集函数的偏差,以及外部能量项来驱动零水平集向期望的图像特征运动,实现了很好的分割效果。
在这里插入图片描述

5.Demo

下图是matlab 中,稍作修改运行作者给出的工具函数demo
原图和分割效果图:
在这里插入图片描述在这里插入图片描述


pics contenx ref from:
https://profs.etsmtl.ca/hlombaert/algorithms.php
https://math.berkeley.edu/~sethian/2006/Explanations/level_set_explain.html
https://www.zhihu.com/question/22608763
https://blog.csdn.net/github_35768306/article/details/64129197
https://blog.csdn.net/songzitea/article/details/46385271
李明纯:http://www.engr.uconn.edu/~cmli/
paper:http://www.imagecomputing.org/~cmli/paper/levelset_cvpr05.pdf
matlab:https://www.mathworks.com/matlabcentral/profile/authors/870631-chunming-li
https://blog.csdn.net/yutianxin123/article/details/69802364
cells: https://www.histology.leeds.ac.uk/blood/blood_wbc.php

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

水平集分割 的相关文章

  • MASK R-CNN网络介绍

    目录 前言 一 MASK R CNN网络 1 1 RoIPool和RoIAlign 1 2 MASK分支 二 损失函数 三 Mask分支预测 前言 在介绍MASK R CNN之前 建议先看下FPN网络 Faster R CNN和FCN的介绍
  • 开源SOLOv2,让动态实例分割更快更强更精准

    作者 介绍 作者建立一个性能强大的简单 通过动态学习对象分割器的蒙版头 使蒙版头以位置为条件 进一步提升性能 具体来说 将遮罩分支解耦为遮罩内核分支和遮罩特征分支 分别负责学习卷积内核和卷积特征 利用矩阵NMS 非最大抑制 以显着减少由于掩
  • 【计算机视觉

    文章目录 一 分割 语义相关 6篇 1 1 Consistency guided Meta Learning for Bootstrapping Semi Supervised Medical Image Segmentation 1 2
  • 【计算机视觉

    文章目录 一 检测相关 8篇 1 1 Explainable Cost Sensitive Deep Neural Networks for Brain Tumor Detection from Brain MRI Images consi
  • 上/下采样的方法

    下采样方式一般使用池化 pooling 操作 上采样 upsampling 的三种方式 插值法 Interpolation 插值就是在周围像素色彩的基础上用数学公式计算补充插入像素点的色彩 但必须注意的是插值并不能增加图像信息 如双线性插值
  • anylabeling安装与使用说明

    文章目录 一 anylabeling说明 二 安装教程 1 可执行程序方式 2 python程序 一 anylabeling说明 官网 https anylabeling nrl ai docs 该工具作为一个具有Segment Anyth
  • 解决libtorch安装编译链接时出错

    cmake build config Release Scanning dependencies of target example app 50 Building CXX object CMakeFiles example app dir
  • YoloV7目标检测(Pytorch版)【详解】

    文章目录 一 网络结构 1 总体网络结构 2 主干网络介绍 backbone 2 1 多分支模块堆叠 2 2 下采样网络结构 2 3 整个backbone代码 3 FPN特征金字塔 二 预测结果的解码 1 获得预测框 置信度 种类的数值 2
  • 深度学习图像分割算法—FCN代码实现

    FCN 全卷积网络 原论文链接 https arxiv org pdf 1411 4038 pdf 官方源代码 https github com shelhamer fcn berkeleyvision org截图如下 data文件夹 官方
  • 基于深度学习的图像分割总结

    一 图像分割类别 随着深度学习的发展 在分割任务中出现了许多优秀的网络 根据实际分割应用任务的不同 可以大致将分割分为三个研究方向 语义分割 实例分割 全景分割 这三种分割在某种意义上是具有一定的联系的 语义分割 像素级别的语义分割 对图像
  • 全卷积网络(FCN)与图像分割

    从图像分类到图像分割 卷积神经网络 CNN 自2012年以来 在图像分类和图像检测等方面取得了巨大的成就和广泛的应用 CNN的强大之处在于它的多层结构能自动学习特征 并且可以学习到多个层次的特征 较浅的卷积层感知域较小 学习到一些局部区域的
  • 图像分割高铁扣件

    图像分割 针对高铁扣件 在对图像的研究和应用中 人们往往仅对图像中的某些部分感兴趣 这些部分通常被称为前景或目标 其余部分则称为背景 目标一般对应于图像中特定的 具有独特性质的区域 独特性质可以是像素的灰度值 物体轮廓曲线 颜色和纹理等 为
  • 深度对抗学习在图像分割和超分辨率中的应用

    深度学习已经在图像分类 检测 分割 高分辨率图像生成等诸多领域取得了突破性的成绩 但是它也存在一些问题 首先 它与传统的机器学习方法一样 通常假设训练数据与测试数据服从同样的分布 或者是在训练数据上的预测结果与在测试数据上的预测结果服从同样
  • 图像分割的衡量指标详解

    转载自 http m blog csdn net u011771047 article details 72777349 http blog csdn net u014593748 article details 71698246 fps
  • 【语义分割】分层多尺度注意力 Hierarchical multi-scale attention for semantic segmentation

    文章目录 1 摘要 2 引言 3 本文相关方法 3 1 Multi scale context methods 3 2 Relational context methods 3 3 Multi scale inference 3 4 Aut
  • 【Semantic Segmentation】语义分割综述

    Semantic Segmentation 语义分割综述 metric 为mIOU year method PASCAL VOC 2012 PASCAL Context Cityscapes ADE20K 2019 HRNet 54 0 8
  • Pyramid Scene Parsing Network

    Pyramid Scene Parsing Network Keras实现代码链接 https github com BBuf Keras Semantic Segmentation Contribution 提出了金字塔场景解析网络 以将
  • Opencv系列1_opencv对单张DCM文件的读取并显示

    实例1 opencv对单张DCM文件的读取并显示 include
  • 【MATLAB教程案例23】基于MATLAB图像分割算法仿真——阈值分割法、Otsu阈值分割法、K均值聚类分割法等

    FPGA教程目录 MATLAB教程目录 目录 1 软件版本 2 通过二值图实现图像分割 3 通过Otsu阈值分割实现图像分割
  • 积分图像(Integral Image)和积分直方图

    积分图像文章推荐 http blog sina com cn s blog 4cb0b54301017wwo html https blog csdn net u010807846 article details 50354000 参考文献

随机推荐

  • Python Utils

    在Python开发中 将常用功能封装成为接口 并放入Utils工具类中 直接调用 可以提升效率 常用的函数有 文件夹遍历 文件夹创建 文件读取 时间可读 时间统计 安全除法 双列表排序 配置读取 脚本路径 Numpy判空 文件夹遍历 遍历文
  • logistic_regression---python实现

    logistic regression 用python实现 一 理论知识 logistic 回归 虽然名字里有 回归 二字 但实际上是解决分类问题的一类线性模型 在某些文献中 logistic 回归又被称作 logit 回归 maximum
  • C语言——ASCII 码表及分类

    目录 一 分类 1 0 31 127 删除键 是控制字符 2 空白字符 3 可显示字符 二 ASCII 表 ASCII 定义了 128 个字符 一 分类 1 0 31 127 删除键 是控制字符 2 空白字符 空格 32 制表符 垂直制表符
  • javascript字符串操作常用方法

    一 操作方法 我们也可将字符串常用的操作方法归纳为增 删 改 查 增 增的意思并不是直接增添内容 而是创建字符串的一个副本 再进行操作 除了常用 以及 进行字符串拼接之外 还可通过concat concat 用于将一个或多个字符串拼接成一个
  • 关于centos7桥接模式上不了网的配置

    我在vmware里装了一下CentOS7 然后选桥接模式竟然连不上网了 我以前装完系统之后直接设置一下模式为桥接模式就可以上外网了 究竟是怎么回事 我查了一下资料之后才发现有个地方忘记配置了 那就是编辑里面的虚拟网络编辑器 接下来我们就重开
  • Python实现异方差检验(statsmodels)

    什么是异方差 摘自知乎https www zhihu com question 354637231 一句话 就是当随机扰动项和模型中的解释变量 自变量 存在某种相关性 就会出现异方差 即对于不同的样本点 随机误差项的方差不再是常数 而互不相
  • RequiredFieldValidator控件验证不能为空时报错多种解决方法以及问题分析

    最近在学asp net 在使用RequiredFieldValidator控件进行验证时 发现报错 界面控件如下图 点击完确定之后按理来说是要报不能为空的提示的但是却报错如下图 经过一番研究发现 也看了其他人的解决方案 总结如下 net 4
  • pytest自动化测试两种执行环境切换的解决方案

    一 痛点分析 在实际企业的项目中 自动化测试的代码往往需要在不同的环境中进行切换 比如多套测试环境 预上线环境 UAT环境 线上环境等等 并且在DevOps理念中 往往自动化都会与Jenkins进行CI CD 不论是定时执行策略还是迭代测试
  • 为什么要同时重写equals方法和hashCode方法(详解)

    在解释为什么要重写equals方法和hashcode方法时 我们要先了解一下这样重写的目的是什么 也让自己有一个思路 围绕这个思路去思考问题 能更好的整握其中的缘由 针对这个目的去思考为什么要去重写 重写的作用是什么 以及如何去重写它们 一
  • MySql SQL语句优化方法

    1 插入优化 当数据过大时 通过load函数上传 2 主键优化 页分裂 当数据乱序插入时 由于主键是按序排的 所以再插入时 当发现页的空间不够时 会通过重新开辟一个页 将原页中的数据拷贝进新的页中 并重新设定链表指针方向 页融合 当删除页内
  • Arduino Uno 实验7——SG90舵机

    SG90舵机简介 舵机是一种位置 角度 伺服的驱动器 适用于那些需要角度不断变化并可以保持的控制系统 主要是由外壳 电路板 驱动马达 直流电机 减速齿轮组 位置检测元件 控制电路 所构成 是一套自动 闭环 控制装置 所谓自动 闭环 控制就是
  • Spring包结构以及各个包之间引用关系说明

    Spring 包结构说明 spring jar 包含有完整发布的单个jar包 他包含有除spring mock jar之外的所有jar 原因是 spring mock jar只有在开发环境中才会用到 而且仅仅是作为一个辅助测试类存在 除了s
  • 解析#pragma指令

    在所有的预处理指令中 Pragma 指令可能是最复杂的了 它的作用是设定编译器的状态或者是指示编译器完成一些特定的动作 pragma指令对每个编译器给出了一个方法 在保持与C和C 语言完全兼容的情况下 给出主机或操作系统专有的特征 依据定义
  • Eclipse安装STS(Spring Tool Suite (STS) for Eclipse)插件

    由于最近在学习SpringBooot 用Eclipse创建SpringBoot项目比较不爽 听说STS插件能直接创建SpringBoot项目 就动手安装一下 希望能对像我一样的小白有所帮助 STS 官网 https spring io to
  • 【毕业设计】基于stm32的便携式U盘设计与实现 - stm32制作U盘

    文章目录 0 前言 1 简介 2 主要器件 3 实现过程 4 部分核心代码 5 最后 0 前言 这两年开始毕业设计和毕业答辩的要求和难度不断提升 传统的毕设题目缺少创新和亮点 往往达不到毕业答辩的要求 这两年不断有学弟学妹告诉学长自己做的项
  • 如何解决网站被黑客攻击-深夜一次网站被攻击瘫痪

    情况 客户网站深夜被黑客攻击 服务器对外发出大量攻击行为流量 运维人员已经不可登录服务器进行安全操作 1首先看能不能后台登录经网站管理界面 如果可以的话那就去查看相关日志 确定黑客攻击的范围 一定要尽可能的得到所有的日志 数据库的 Web服
  • (AJAX/JSON)技术实现校验用户名是否存在

    案例 校验用户名是否存在 1 服务器响应的数据 在客户端使用时 要想当做json数据格式使用 有两种解决方案 1 get type 将最后一个参数type指定为 json 2 在服务器端设置MIME类型 response setConten
  • tensorflow教程_TensorFlow教程

    tensorflow教程 TensorFlow教程 TensorFlow Tutorial PDF Version Quick Guide Resources Job Search Discussion PDF版本 快速指南 资源资源 求职
  • nginx配置中root和alias的区别

    例 访问http 127 0 0 1 download 这个目录时候让他去 opt app code这个目录找 方法一 使用root关键字 location root usr share nginx location download gz
  • 水平集分割

    基于距离正则的水平集分割MATLAB代码 无需初始化 This Matlab code demonstrates an edge based active contour model as an application of the Dis