添加了新的非监督算法

This commit is contained in:
石沈昊 2022-08-31 23:30:02 +08:00
parent 9b9514a262
commit af45f1efc9
4 changed files with 12467 additions and 3 deletions

View File

@ -17,7 +17,7 @@ from In_one import pic
import math import math
from skimage.filters import rank from skimage.filters import rank
from skimage.morphology import disk, rectangle from skimage.morphology import disk, rectangle
from In_one.scripts.UnsupervisedCD import LSTS,CVA,acd,aht,ocd,lhba from In_one.scripts.UnsupervisedCD import LSTS,CVA,acd,aht,ocd,lhba,sh
def Meanfilter(x_size,y_size,layer:MultiBandRasterLayer): def Meanfilter(x_size,y_size,layer:MultiBandRasterLayer):
x_size = int(x_size) x_size = int(x_size)
y_size = int(y_size) y_size = int(y_size)
@ -473,7 +473,7 @@ class AllInOne(QDialog):
return p return p
class InOnePlugin(BasicPlugin): class InOnePlugin(BasicPlugin):
pre={"均值滤波":Meanfilter}#可添加其他方法 pre={"均值滤波":Meanfilter}#可添加其他方法
cd={'差分法':basic_cd,'LSTS':LSTS,'CVA':CVA,'ACD':acd,'AHT':aht,'OCD':ocd,'LHBA':lhba}#可添加其他方法 cd={'差分法':basic_cd,'LSTS':LSTS,'CVA':CVA,'ACD':acd,'AHT':aht,'OCD':ocd,'LHBA':lhba,'SH':sh}#可添加其他方法
threshold={'OTSU阈值':otsu}#可添加其他方法 threshold={'OTSU阈值':otsu}#可添加其他方法

12424
plugins/In_one/scripts/SH.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@ from .USCD import ACD
from .AHT import AHT from .AHT import AHT
from .OCD import OCD from .OCD import OCD
from .LHBA import LHBA from .LHBA import LHBA
from .SH import SH
def warp(file,ds:gdal.Dataset,srcWin=[0,0,0,0]): def warp(file,ds:gdal.Dataset,srcWin=[0,0,0,0]):
driver = gdal.GetDriverByName('GTiff') driver = gdal.GetDriverByName('GTiff')
xsize=ds.RasterXSize xsize=ds.RasterXSize
@ -509,3 +510,42 @@ def lhba(pth1:str,pth2:str,layer_parent:PairLayer,send_message):
ds.SetProjection(proj) ds.SetProjection(proj)
del ds del ds
return out_normal_tif return out_normal_tif
def sh(pth1:str,pth2:str,layer_parent:PairLayer,send_message):
xsize = layer_parent.size[0]
ysize = layer_parent.size[1]
geo=layer_parent.grid.geo
proj=layer_parent.grid.proj
#提取公共部分
send_message.emit('提取重叠区域数据.....')
ds2:gdal.Dataset=gdal.Open(pth2)
temp_tif2 = os.path.join(Project().other_path,'temp2.tif')
start2x,start2y=geo2imageRC(ds2.GetGeoTransform(),layer_parent.mask.xy[0],layer_parent.mask.xy[1])
end2x,end2y=geo2imageRC(ds2.GetGeoTransform(),layer_parent.mask.xy[2],layer_parent.mask.xy[3])
warp(temp_tif2,ds2,srcWin=[start2x,start2y,xsize,ysize])
del ds2
send_message.emit('图像二提取完成')
ds1:gdal.Dataset=gdal.Open(pth1)
temp_tif1 = os.path.join(Project().other_path, 'temp1.tif')
start1x,start1y=geo2imageRC(ds1.GetGeoTransform(),layer_parent.mask.xy[0],layer_parent.mask.xy[1])
end1x,end1y=geo2imageRC(ds1.GetGeoTransform(),layer_parent.mask.xy[2],layer_parent.mask.xy[3])
warp(temp_tif1,ds1,srcWin=[start1x,start1y,xsize,ysize])
del ds1
send_message.emit('图像一提取完成')
#运算
send_message.emit('开始SH计算.....')
time.sleep(0.1)
out_normal_tif = os.path.join(Project().cmi_path, '{}_{}_cmi.tif'.format(layer_parent.name, int(np.random.rand() * 100000)))
SH(temp_tif1,temp_tif2,out_normal_tif)
#添加投影
send_message.emit('录入投影信息.....')
time.sleep(0.1)
ds=gdal.Open(out_normal_tif,1)
ds.SetGeoTransform(geo)
ds.SetProjection(proj)
del ds
return out_normal_tif

Binary file not shown.