当前位置: 首页 > news >正文

房产网站程序wordpress登录qq微信

房产网站程序,wordpress登录qq微信,网站如何运营,一般做网站价格今天主要想说的是#xff0c;分形中的差分盒子维数的原理#xff0c;基于分形的基础概念就不在这里说啦.分形维数可以用于定量描述图像表面的空间复杂程度#xff0c;能够定量的表现图像的纹理特征. 采用不同的维数进行纹理特征描述时#xff0c;精度有所区别#xff0c;我…今天主要想说的是分形中的差分盒子维数的原理基于分形的基础概念就不在这里说啦.分形维数可以用于定量描述图像表面的空间复杂程度能够定量的表现图像的纹理特征. 采用不同的维数进行纹理特征描述时精度有所区别我们今天主要来说一下比较简单的盒子维.1.差分盒子维数Gangepain 和 Roques-Carms 在1986年提出基于盒计数(Box-counting)的分形维数通过计算覆盖图像表面的最小盒子数来度量. 说得详细一点将一幅大小为 的图像分为 的子块图像 处的灰度值为 总的灰度级为 . 此时将图像看成三维物体的表面灰度集 . 平面上是 的网格 轴为网格内像素灰度值每个网格上有若干个盒子叠加盒子高度为 .注一般灰度图像的灰度级为 L 256.若在第 个网格中第 个盒子中包含网格内灰度最小值第 个盒子包含网格内灰度最大值则覆盖第 个网格的盒子数 .覆盖整个盒子的数为 为由此可求分形维数D为式中 .通过改变网格 的大小计算一组 然后计算点对 的线性回归其斜率即是分形维数 .2.实验我们先来看一下将灰度图像看作三维物体的表面灰度集是怎么样呢① 实现灰度图像的表面灰度集采用matlab程序如下function Show_GraySurface(filename)% 把一幅图像看成三维空间的曲面 % 像素的位置(x,y)构成xoy坐标面 % 像素的灰度值看成z轴的值由此构成灰度曲面picture_dir D:Matlabworktest;I imread([picture_dir,filename]);if (length(size(I)) 2)I rgb2gray(I);end M size(I,1);Temp diag(1:256)*ones(256,256);x reshape(Temp.,1,M*M);y reshape(Temp,1,M*M);z reshape(I,1,M*M);tri delaunay(x,y);trisurf(tri,x,y,z);shading interpview(3);grid on;colorbarend附加python程序import cv2 import numpy as np import matplotlib.pyplot as pltdef surface(img):X np.arange(0, 363, 1) # cols of the imageY np.arange(0, 480, 1) # rows of the imageX,Y np.meshgrid(X,Y) # extending pointsZ np.array(img) #2 dimensionfig, ax plt.subplots(subplot_kw {projection: 3d})surf ax.plot_surface(X, Y, Z, cmap rainbow, linewidth 0, antialiased False)ax.contour(X, Y, Z, zdir z, offset 75, cmap plt.get_cmap(rainbow)) # projectionfig.colorbar(surf) # colorbarplt.show()if __name__ __main__:img cv2.imread(3.jpg, 0)surface(img) 注matlab程序中图像大小256 x 256.效果如下图1 图像灰度曲面② 计算差分盒维数采用Python程序.★ 主程序文件main.pyimport cv2 from DBC import Fractalsrc cv2.imread(D5.jpg, cv2.IMREAD_UNCHANGED)# create an object obj Fractal()#linear fitting for solveing differential box dimension(DBC) obj.execute(src)★ 子程序文件DBC.pyimport numpy as np import cv2 import math from matplotlib import pyplot as pltclass Fractal():def __init__(self):pass# method of image grayingdef gray(self, src):gray_img np.uint8(src[:,:, 0] * 0.144 src[:, :, 1] * 0.587 src[:, :, 2] * 0.299) # cla_img cv2.bilateralFilter(gray_img, 3, 64, 64)# #clahe processing# clahe cv2.createCLAHE(clipLimit 3, tileGridSize (32, 32))# cla_img clahe.apply(bil_img)return gray_img# differential box dimension counting (DBC)def differential_box_counting (self, gray_img):h, w gray_img.shape[:2]M min(h,w)Nr []for s in range(2,M//21,1): # the box side length: 2 ~ M//2H 255*s/M # high of the boxbox_num 0 # initialization of the box numberfor row in range(h//s): # h//s: the number of rows in the box; w//s: the number of columns in the boxfor col in range(w//s):nr math.ceil((np.max(gray_img[row*s:(row1)*s, col*s:(col1)*s])-np.min(gray_img[row*s:(row1)*s, col*s:(col1)*s]))/H 1)box_num nrNr.append(box_num)return Nr,Mdef least_squares(self, x , y):(1) input datesets of x and y (2) the straight line is fitted by Least-square method(3) output a coefficient(w), intercept(b) and coefficient of determination (r)(4) the fitting straight line : y wx bx_ x.mean()y_ y.mean()m1 np.zeros(1)m2 np.zeros(1)m3 np.zeros(1) k1 np.zeros(1)k2 np.zeros(1)k3 np.zeros(1)for i in np.arange(len(x)):m1 (x[i] - x_)* y[i]m2 np.square(x[i])m3 x[i]k1 (x[i]-x_) * (y[i]-y_)k2 np.square(x[i] - x_)k3 np.square(y[i] - y_)w m1/(m2 - 1/len(x) * np.square(m3))b y_ - w * x_r k1 / np.sqrt(k2 * k3)return w, b, rdef plot_line(self, x, y, w, b, r):# print(w, b, r ** 2)y_pred w * x b# create a fig and an axesfig, ax plt.subplots(figsize (10, 5))# fontsyle: SimHei(黑体)support chineseplt.rcParams[font.sans-serif] [SimHei]ax.plot(x, y, co, markersize 6, label scatter datas)ax.plot(x, y_pred, r-, linewidth 2, label y %.4fx %.4f %(w, b))# set xlim and yxlim ax.set_aspect(0.5)ax.set_xlim(1, 6)ax.set_ylim(2, 12)# set x_ticks and y_ticksax.tick_params(labelsize 16)labels ax.get_xticklabels() ax.get_yticklabels()[label.set_fontname(Times New Roman) for label in labels] # create gridsax.grid(which major, axis both)# display labelsfont1 {family: Times New Roman, weight: normal, size: 16}ax.legend(prop font1) #set x_label and y_labelfont2 {family: Times New Roman, weight: normal, size: 20}ax.set_xlabel(ln 1/r, fontdict font2)ax.set_ylabel(ln Nr, fontdict font2)# set a position of R^2ax.text(3.5, 7.8, R^2 %.4f % float(r * r), fontdict font1,verticalalignmentcenter, horizontalalignment left, rotation0)plt.savefig(line.jpg, dpi 300, bbox_inches tight)plt.show()def execute(self, img):gray_img self.gray(img)Nr, M self.differential_box_counting(gray_img)x np.log([round(M/s) for s in range(2,M//21,1)])y np.log(Nr)#fitting a straight linew, b, r self.least_squares(x, y)self.plot_line(x, y, w, b, r) 我们来看一下效果图用最小二乘法进行拟合斜率就是我们需要的维数.图2 线性拟合# 其实最小二乘法也可以通过sklearn库直接调用.import cv2 import numpy as np import math from matplotlib import pyplot as plt from sklearn import linear_model from sklearn.metrics import r2_scorefrom numba import jitjit def differential_box_counting (gray_img):# cv2.imshow(gray_img,gray_img)h, w gray_img.shape[:2]M min(h,w)Nr []for s in range(2,M//21,1): #盒子边长从2到图片最小尺寸的二分之一,每次边长加1H 255*s/M #盒子柱高lbox_num 0 #初始化盒子数for row in range(h//s): #h//s为盒子的行数w//s为盒子的列数for col in range(w//s):nr math.ceil((np.max(gray_img[row*s:(row1)*s, col*s:(col1)*s])-np.min(gray_img[row*s:(row1)*s, col*s:(col1)*s]))/H 1)box_num nrNr.append(box_num)return Nr,Mdef Least_squares():x np.log([round(M/s) for s in range(2,M//21,1)])x np.array(x).reshape((-1, 1)) # transform list to numpy.ndarrayy np.log(Nr)y np.array(y).reshape((-1, 1)) # transform list to numpy.ndarray# Create linear regression objectregr linear_model.LinearRegression() # is equivalent to # regr linear_model.Ridge(alpha 0)# Train the model using the setsregr.fit(x, y)y_pred regr.predict(x)# The coefficientsprint(Coefficients: , regr.coef_)#The interceptprint(Intercept: , regr.intercept_)# The coefficient of determination: 1 is perfect predictionprint(Coefficient of determination: %.8f% r2_score(y, y_pred))plt.scatter(x, y, colorblack)plt.plot(x, y_pred, colorblue, linewidth3)plt.show()if __name__ __main__:gray_img cv2.imread(D3.jpg, cv2.IMREAD_GRAYSCALE)# thresh cv2.threshold(gray_img, 220, 255, cv2.THRESH_BINARY)[1]Nr,M differential_box_counting(gray_img)Least_squares()喜欢的话给予鼓励点个赞...
http://www.zqtcl.cn/news/595614/

相关文章:

  • 好看响应式网站模板制作商城公司
  • 网站的主题有哪些专业做律师网站的公司
  • 大连做网站 选领超科技网站建设公司的成本有哪些方面
  • 文章网站是怎么做的宁波网站建设lonoo
  • 做网站学cdr吗企业年金险是什么意思
  • 芜湖炎黄做的网站北京高端网站公司哪家好
  • 帮人做网站一定要先收费网站构建免费
  • 营销型网站的优缺点如何在腾讯云做网站
  • 现在做网站怎么样网站运营与管理规划书
  • 国际物流公司网站建设有关应用网站
  • 网站后台维护技能娱乐公司网站模板
  • 有建网站的公司吗p2p理财网站开发要求
  • 做私单的网站高端html5网站设计工作室织梦模板 dedecms5.7
  • 视频网站切片怎么做如何做网站结构及栏目策划
  • 公司和网站备案查询龙江网站建设公司
  • 建一个平台网站需要多少钱安徽网站建设大全
  • 做网站接广告网站注册页面怎么做
  • 西安建站价格表电脑做视频的网站比较好
  • 建筑中级职称查询网站百度指数功能模块
  • 建设网站只慧聪网怎样做网站友情链接
  • 德阳网站开发dedecms5.7装饰公司网站模板
  • 下步我院将建设网站信息保密浙江温州网络公司
  • 一键建站网站seo关键词快速排名介绍
  • 自己做网站 什么wordpress博客文章加密
  • 怎样做音视频宣传网站wordpress 推送
  • 网站图片上传代码专业的企业进销存软件定制
  • 商品网站模板wordpress文章推荐
  • 十里堡网站建设做吃的教程网站
  • 比较好的源码网站河南网站seo推广
  • 做网站推广什么好网站界面结构