更新港口切片逻辑
parent
c689b2d84d
commit
d63423ff18
|
|
@ -118,14 +118,14 @@ def processPool(srcFolderPath,preFolderPath,targetfolderPath,logPath=r"R:\TYSAR-
|
||||||
print("{}/{}".format(pidx+1,len(async_results)),async_result.get())
|
print("{}/{}".format(pidx+1,len(async_results)),async_result.get())
|
||||||
writeoutlog(logPath,"{}/{} {}".format(pidx+1,len(async_results),async_result.get()))
|
writeoutlog(logPath,"{}/{} {}".format(pidx+1,len(async_results),async_result.get()))
|
||||||
writeoutlog(logPath, "\nprocess finished \n")
|
writeoutlog(logPath, "\nprocess finished \n")
|
||||||
moverTip,moveflag=moveDir(preFolderPath, targetfolderPath)
|
# moverTip,moveflag=moveDir(preFolderPath, targetfolderPath)
|
||||||
writeoutlog(logPath, moverTip)
|
# writeoutlog(logPath, moverTip)
|
||||||
|
|
||||||
writeoutlog(logPath, "====================================================================================\n")
|
writeoutlog(logPath, "====================================================================================\n")
|
||||||
if moveflag:
|
# if moveflag:
|
||||||
pass
|
# pass
|
||||||
else:
|
# else:
|
||||||
exit(3)
|
# exit(3)
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
# 流程执行区
|
# 流程执行区
|
||||||
|
|
@ -146,16 +146,16 @@ if __name__ == '__main__':
|
||||||
# processPool(srcFolderPath, preFolderPath,targetfolderPath, logPath)
|
# processPool(srcFolderPath, preFolderPath,targetfolderPath, logPath)
|
||||||
#
|
#
|
||||||
# 20250826-不分类 条带模式
|
# 20250826-不分类 条带模式
|
||||||
srcFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\0-原图"
|
srcFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\航道\20250930-不分类\0-原图"
|
||||||
preFolderPath = r"D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\A-预处理\AB-图像预处理"
|
preFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\航道\20250930-不分类\A-预处理\AB-图像预处理"
|
||||||
targetfolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\A-预处理\AB-图像预处理"
|
targetfolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\A-预处理\AB-图像预处理"
|
||||||
processPool(srcFolderPath, preFolderPath, targetfolderPath,logPath)
|
processPool(srcFolderPath, preFolderPath, targetfolderPath,logPath)
|
||||||
|
|
||||||
# 20250903-不分类 条带模式
|
# # 20250903-不分类 条带模式
|
||||||
srcFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250903-不分类\0-原图"
|
# srcFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250903-不分类\0-原图"
|
||||||
preFolderPath = r"D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250903-不分类\A-预处理\AB-图像预处理"
|
# preFolderPath = r"D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250903-不分类\A-预处理\AB-图像预处理"
|
||||||
targetfolderPath = r"D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250903-不分类\A-预处理\AB-图像预处理"
|
# targetfolderPath = r"D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250903-不分类\A-预处理\AB-图像预处理"
|
||||||
processPool(srcFolderPath, preFolderPath,targetfolderPath, logPath)
|
# processPool(srcFolderPath, preFolderPath,targetfolderPath, logPath)
|
||||||
|
|
||||||
# # 20250910-不分类 条带模式
|
# # 20250910-不分类 条带模式
|
||||||
# srcFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250910-不分类\0-原图"
|
# srcFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250910-不分类\0-原图"
|
||||||
|
|
@ -164,7 +164,7 @@ if __name__ == '__main__':
|
||||||
# processPool(srcFolderPath, preFolderPath, targetfolderPath,logPath)
|
# processPool(srcFolderPath, preFolderPath, targetfolderPath,logPath)
|
||||||
|
|
||||||
|
|
||||||
result_flag_txt = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\strechResult_finish.log"
|
result_flag_txt = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\航道\20250930-不分类\strechResult_finish.log"
|
||||||
with open(result_flag_txt,"w",encoding="utf-8") as f:
|
with open(result_flag_txt,"w",encoding="utf-8") as f:
|
||||||
f.write("strech finied!!!\n")
|
f.write("strech finied!!!\n")
|
||||||
writeoutlog(logPath, "strech finied!!!\n")
|
writeoutlog(logPath, "strech finied!!!\n")
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ def SpliteProcess(srcfolderpath,infolderpath,outfolderpath):
|
||||||
|
|
||||||
labeltxtPaths=find_label_files_pathlib(infolderpath)
|
labeltxtPaths=find_label_files_pathlib(infolderpath)
|
||||||
|
|
||||||
JportLabel=os.path.join(outfolderpath,'君港')
|
JportLabel=os.path.join(outfolderpath,'军港')
|
||||||
MportLabel=os.path.join(outfolderpath,'民港')
|
MportLabel=os.path.join(outfolderpath,'民港')
|
||||||
MJportLabel=os.path.join(outfolderpath,'混合港')
|
MJportLabel=os.path.join(outfolderpath,'混合港')
|
||||||
NoportLabel=os.path.join(outfolderpath,'无港口')
|
NoportLabel=os.path.join(outfolderpath,'无港口')
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ def statictNumber(inlabelfilepath):
|
||||||
def StaticProcess(inlabelfolder,outcsvpath):
|
def StaticProcess(inlabelfolder,outcsvpath):
|
||||||
labelfilepaths=find_txt_files_pathlib(inlabelfolder)
|
labelfilepaths=find_txt_files_pathlib(inlabelfolder)
|
||||||
with open(outcsvpath,"w",encoding="utf-8") as f:
|
with open(outcsvpath,"w",encoding="utf-8") as f:
|
||||||
f.write("切片名,君用飞机,民用飞机,君民一体飞机,君用轮船,民用轮船,民用机场,君用机场,君民一体机场,君用港口,民用港口,君民一体港口,总计\n")
|
f.write("切片名,军用飞机,民用飞机,军民一体飞机,军用轮船,民用轮船,民用机场,军用机场,军民一体机场,军用港口,民用港口,军民一体港口,总计\n")
|
||||||
f.write("标注,military_airplane, civil_airplane,mix_airpllane,military_ship,civil_ship,civil_airport,military_airport,mix_airport,military_harbor,civil_harbor,mix_harbor,Total\n")
|
f.write("标注,military_airplane, civil_airplane,mix_airpllane,military_ship,civil_ship,civil_airport,military_airport,mix_airport,military_harbor,civil_harbor,mix_harbor,Total\n")
|
||||||
|
|
||||||
for labelfilepath in labelfilepaths:
|
for labelfilepath in labelfilepaths:
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ import argparse
|
||||||
def stats_ship_labels(input_dir, output_file, person="", work_time=""):
|
def stats_ship_labels(input_dir, output_file, person="", work_time=""):
|
||||||
header = [
|
header = [
|
||||||
"标签", "负责人", "作业时间",
|
"标签", "负责人", "作业时间",
|
||||||
"君用飞机", "民用飞机", "君民一体飞机",
|
"军用飞机", "民用飞机", "军民一体飞机",
|
||||||
"君用轮船", "民用轮船",
|
"军用轮船", "民用轮船",
|
||||||
"民用机场", "君用机场", "君民一体机场",
|
"民用机场", "军用机场", "军民一体机场",
|
||||||
"民用港口", "君用港口", "君民一体港口",
|
"民用港口", "军用港口", "军民一体港口",
|
||||||
"总计"
|
"总计"
|
||||||
]
|
]
|
||||||
alias = [
|
alias = [
|
||||||
|
|
@ -50,16 +50,16 @@ def stats_ship_labels(input_dir, output_file, person="", work_time=""):
|
||||||
# "负责人":person,
|
# "负责人":person,
|
||||||
# "作业时间":work_time,
|
# "作业时间":work_time,
|
||||||
# "民用飞机":0,
|
# "民用飞机":0,
|
||||||
# "君用飞机":0,
|
# "军用飞机":0,
|
||||||
# "君民一体飞机":0,
|
# "军民一体飞机":0,
|
||||||
# "君用轮船":0,
|
# "军用轮船":0,
|
||||||
# "民用轮船":counts["民用轮船"],
|
# "民用轮船":counts["民用轮船"],
|
||||||
# "民用机场":0,
|
# "民用机场":0,
|
||||||
# "君用机场":0,
|
# "军用机场":0,
|
||||||
# "君民一体机场":0,
|
# "军民一体机场":0,
|
||||||
# "君用港口":0,
|
# "军用港口":0,
|
||||||
# "民用港口":0,
|
# "民用港口":0,
|
||||||
# "君民一体港口":0
|
# "军民一体港口":0
|
||||||
# }
|
# }
|
||||||
# row["总计"] = row["民用轮船"]
|
# row["总计"] = row["民用轮船"]
|
||||||
# rows.append(row)
|
# rows.append(row)
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ def preProcessShipPortTools(srcFolderPath,targetFolderPath,outTargetFolderPath):
|
||||||
#
|
#
|
||||||
# # 文件接口创建
|
# # 文件接口创建
|
||||||
# MPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","民港口")
|
# MPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","民港口")
|
||||||
# JPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","君港口")
|
# JPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","军港口")
|
||||||
# MJPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","混合港口")
|
# MJPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","混合港口")
|
||||||
# NoPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","无港口")
|
# NoPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","无港口")
|
||||||
#
|
#
|
||||||
|
|
@ -105,8 +105,8 @@ def preProcessShipPortTools(srcFolderPath,targetFolderPath,outTargetFolderPath):
|
||||||
existOrCreate(outMJPortFolderPath)
|
existOrCreate(outMJPortFolderPath)
|
||||||
|
|
||||||
MLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\港口(民船).shp"
|
MLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\港口(民船).shp"
|
||||||
JLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\君港.shp"
|
JLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\军港.shp"
|
||||||
MJLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\君民一体港口.shp"
|
MJLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\军民一体港口.shp"
|
||||||
|
|
||||||
processMJPortflag=processMJPort(srcFolderPath,outMJPortSumTxtPath,outMJPortFolderPath,MLCShapeFilePath,JLCShapeFilePath,MJLCShapeFilePath)
|
processMJPortflag=processMJPort(srcFolderPath,outMJPortSumTxtPath,outMJPortFolderPath,MLCShapeFilePath,JLCShapeFilePath,MJLCShapeFilePath)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ def preProcessShipPortTools(srcFolderPath,targetFolderPath,outTargetFolderPath):
|
||||||
|
|
||||||
# 文件接口创建
|
# 文件接口创建
|
||||||
MPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","民港口")
|
MPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","民港口")
|
||||||
JPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","君港口")
|
JPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","军港口")
|
||||||
MJPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","混合港口")
|
MJPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","混合港口")
|
||||||
NoPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","无港口")
|
NoPortFolder=os.path.join(targetFolderPath,"AC-图像预处理","无港口")
|
||||||
|
|
||||||
|
|
@ -105,8 +105,8 @@ def preProcessShipPortTools(srcFolderPath,targetFolderPath,outTargetFolderPath):
|
||||||
existOrCreate(outMJPortFolderPath)
|
existOrCreate(outMJPortFolderPath)
|
||||||
|
|
||||||
MLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\港口(民船).shp"
|
MLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\港口(民船).shp"
|
||||||
JLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\君港.shp" # 数据BM,不公开
|
JLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\军港.shp" # 数据BM,不公开
|
||||||
MJLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\君民一体港口.shp"
|
MJLCShapeFilePath=r"D:\TYSAR-德清院\目标点位信息更新\0828目标点位\军民一体港口.shp"
|
||||||
|
|
||||||
processMJPortflag=processMJPort(srcFolderPath,outMJPortSumTxtPath,outMJPortFolderPath,MLCShapeFilePath,JLCShapeFilePath,MJLCShapeFilePath)
|
processMJPortflag=processMJPort(srcFolderPath,outMJPortSumTxtPath,outMJPortFolderPath,MLCShapeFilePath,JLCShapeFilePath,MJLCShapeFilePath)
|
||||||
# 港口归属
|
# 港口归属
|
||||||
|
|
@ -140,13 +140,13 @@ def preProcessShipPortTools(srcFolderPath,targetFolderPath,outTargetFolderPath):
|
||||||
tarPortFolder=NoPortFolder
|
tarPortFolder=NoPortFolder
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
# async_results.append(preProcessTiFF(tiffpath,portTxtpath,tarPortFolder))
|
async_results.append(preProcessTiFF(tiffpath,portTxtpath,tarPortFolder))
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
# 处理分块
|
# 处理分块
|
||||||
for pidx in range(len(async_results)):
|
for pidx in range(len(async_results)):
|
||||||
async_result=async_results[pidx]
|
async_result=async_results[pidx]
|
||||||
print("{}/{}".format(pidx+1,len(async_results)),async_result.get())
|
print("{}/{} {}".format(pidx+1,len(async_results)),async_result.get())
|
||||||
writeoutlog(logPath,"{}/{} {}".format(pidx+1,len(async_results),async_result.get()))
|
writeoutlog(logPath,"{}/{} {}".format(pidx+1,len(async_results),async_result.get()))
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
@ -177,8 +177,14 @@ if __name__ == '__main__':
|
||||||
# preProcessShipPortTools(srcFolderPath, preFolderPath,targetfolderPath, logPath)
|
# preProcessShipPortTools(srcFolderPath, preFolderPath,targetfolderPath, logPath)
|
||||||
#
|
#
|
||||||
# 20250826-不分类 条带模式
|
# 20250826-不分类 条带模式
|
||||||
srcFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\0-原图"
|
# srcFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\0-原图"
|
||||||
preFolderPath = r"D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\A-预处理"
|
# preFolderPath = r"D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\A-预处理"
|
||||||
|
# targetfolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\A-预处理"
|
||||||
|
# preProcessShipPortTools(srcFolderPath, preFolderPath, targetfolderPath)
|
||||||
|
|
||||||
|
# 20250930-不分类 条带模式
|
||||||
|
srcFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\航道\20250930-不分类\0-原图"
|
||||||
|
preFolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\航道\20250930-不分类\A-预处理"
|
||||||
targetfolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\A-预处理"
|
targetfolderPath = r"R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250826-不分类\A-预处理"
|
||||||
preProcessShipPortTools(srcFolderPath, preFolderPath, targetfolderPath)
|
preProcessShipPortTools(srcFolderPath, preFolderPath, targetfolderPath)
|
||||||
|
|
||||||
|
|
@ -189,5 +195,3 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -311,20 +311,22 @@ def slicePortDataset(rootname,im_data,src_im_data, im_Geotrans, im_proj, outfold
|
||||||
MLCPoints=[]
|
MLCPoints=[]
|
||||||
JLCPoints=[]
|
JLCPoints=[]
|
||||||
MJLCPoints=[]
|
MJLCPoints=[]
|
||||||
|
portfilelines=[]
|
||||||
with open(portfilestr,"r",encoding="utf-8") as portfile:
|
with open(portfilestr,"r",encoding="utf-8") as portfile:
|
||||||
for line in portfile.readlines():
|
portfilelines=portfile.readlines()
|
||||||
if(len(line)>3):
|
for line in portfilelines:
|
||||||
linemetas=line.split("\t\t")
|
if(len(line)>3):
|
||||||
clsname=linemetas[0]
|
linemetas=line.split("\t\t")
|
||||||
pointstr=linemetas[1]
|
clsname=linemetas[0]
|
||||||
pointx=float(pointstr.split(",")[0])
|
pointstr=linemetas[1]
|
||||||
pointy=float(pointstr.split(",")[1])
|
pointx=float(pointstr.split(",")[0]) # PX
|
||||||
if clsname=="JLC":
|
pointy=float(pointstr.split(",")[1]) # Py
|
||||||
JLCPoints.append([pointx,pointy])
|
if clsname=="JLC":
|
||||||
elif clsname=="MJLC":
|
JLCPoints.append([pointx,pointy])
|
||||||
MJLCPoints.append([pointx,pointy])
|
elif clsname=="MJLC":
|
||||||
elif clsname=="MLC":
|
MJLCPoints.append([pointx,pointy])
|
||||||
MLCPoints.append([pointx,pointy])
|
elif clsname=="MLC":
|
||||||
|
MLCPoints.append([pointx,pointy])
|
||||||
# 处理文件脚本
|
# 处理文件脚本
|
||||||
if len(MLCPoints)==0 and len(JLCPoints)==0 and len(MJLCPoints)==0:
|
if len(MLCPoints)==0 and len(JLCPoints)==0 and len(MJLCPoints)==0:
|
||||||
return
|
return
|
||||||
|
|
@ -334,27 +336,66 @@ def slicePortDataset(rootname,im_data,src_im_data, im_Geotrans, im_proj, outfold
|
||||||
binfolder=os.path.join(outfolder,"港口","unit8binfolder")
|
binfolder=os.path.join(outfolder,"港口","unit8binfolder")
|
||||||
pngfolder=os.path.join(outfolder,"港口","pngfolder")
|
pngfolder=os.path.join(outfolder,"港口","pngfolder")
|
||||||
tifffolder=os.path.join(outfolder,"港口","tifffolder")
|
tifffolder=os.path.join(outfolder,"港口","tifffolder")
|
||||||
h,w=im_data.shape
|
|
||||||
nextH,ht=getNextSliceNumber(h,portsliceSize,BlockOverLayer)
|
|
||||||
nextW,wt=getNextSliceNumber(w,portsliceSize,BlockOverLayer)
|
|
||||||
padH=nextH-h
|
|
||||||
padW=nextW-w
|
|
||||||
im_data=np.pad(im_data,((0,padH),(0,padW)),mode='constant',constant_values=0)
|
|
||||||
src_im_data=np.pad(src_im_data,((0,padH),(0,padW)),mode='constant',constant_values=0)
|
|
||||||
for hi in ht:
|
|
||||||
for wi in wt:
|
|
||||||
geotrans_temp=getsliceGeotrans(im_Geotrans,wi,hi)
|
|
||||||
im_data_temp=im_data[hi:hi+portsliceSize,wi:wi+portsliceSize]
|
|
||||||
src_im_data_temp=src_im_data[hi:hi+portsliceSize,wi:wi+portsliceSize]
|
|
||||||
slice_ID = slice_ID + 1
|
|
||||||
if ishasPort(geotrans_temp,src_im_data_temp,MLCPoints,JLCPoints,MJLCPoints):
|
|
||||||
sliceBinPath=os.path.join(binfolder, rootname+"_"+str(slice_ID).zfill(4)+"_image.tiff")
|
|
||||||
slicepngPath=os.path.join(pngfolder, rootname+"_"+str(slice_ID).zfill(4)+"_image.png")
|
|
||||||
slicesrctiffPath=os.path.join(tifffolder, rootname+"_"+str(slice_ID).zfill(4)+"_image.tiff")
|
|
||||||
|
|
||||||
write_tiff(src_im_data_temp, geotrans_temp, im_proj, slicesrctiffPath)
|
for P in JLCPoints:
|
||||||
write_envi(im_data_temp,geotrans_temp,im_proj,sliceBinPath)
|
Px=P[0]
|
||||||
Image.fromarray(im_data_temp).save(slicepngPath,compress_level=0)
|
Py=P[1]
|
||||||
|
Sx=P[0]-portsliceSize/2
|
||||||
|
Sy=P[1]-portsliceSize/2
|
||||||
|
wi=Sx if Sx>0 else 0
|
||||||
|
hi=Sy if Sy>0 else 0
|
||||||
|
slice_ID = slice_ID + 1
|
||||||
|
im_data_temp = im_data[hi:hi + portsliceSize, wi:wi + portsliceSize]
|
||||||
|
src_im_data_temp = src_im_data[hi:hi + portsliceSize, wi:wi + portsliceSize]
|
||||||
|
|
||||||
|
sliceBinPath = os.path.join(binfolder, rootname + "_" + str(slice_ID).zfill(4) + "_image.tiff")
|
||||||
|
slicepngPath = os.path.join(pngfolder, rootname + "_" + str(slice_ID).zfill(4) + "_image.png")
|
||||||
|
slicesrctiffPath = os.path.join(tifffolder, rootname + "_" + str(slice_ID).zfill(4) + "_image.tiff")
|
||||||
|
|
||||||
|
geotrans_temp = getsliceGeotrans(im_Geotrans, wi, hi)
|
||||||
|
write_tiff(src_im_data_temp, geotrans_temp, im_proj, slicesrctiffPath)
|
||||||
|
write_envi(im_data_temp, geotrans_temp, im_proj, sliceBinPath)
|
||||||
|
Image.fromarray(im_data_temp).save(slicepngPath, compress_level=4)
|
||||||
|
|
||||||
|
for P in MJLCPoints:
|
||||||
|
Px = P[0]
|
||||||
|
Py = P[1]
|
||||||
|
Sx = P[0] - portsliceSize / 2
|
||||||
|
Sy = P[1] - portsliceSize / 2
|
||||||
|
wi = Sx if Sx > 0 else 0
|
||||||
|
hi = Sy if Sy > 0 else 0
|
||||||
|
slice_ID = slice_ID + 1
|
||||||
|
im_data_temp = im_data[hi:hi + portsliceSize, wi:wi + portsliceSize]
|
||||||
|
src_im_data_temp = src_im_data[hi:hi + portsliceSize, wi:wi + portsliceSize]
|
||||||
|
|
||||||
|
sliceBinPath = os.path.join(binfolder, rootname + "_" + str(slice_ID).zfill(4) + "_image.tiff")
|
||||||
|
slicepngPath = os.path.join(pngfolder, rootname + "_" + str(slice_ID).zfill(4) + "_image.png")
|
||||||
|
slicesrctiffPath = os.path.join(tifffolder, rootname + "_" + str(slice_ID).zfill(4) + "_image.tiff")
|
||||||
|
|
||||||
|
geotrans_temp = getsliceGeotrans(im_Geotrans, wi, hi)
|
||||||
|
write_tiff(src_im_data_temp, geotrans_temp, im_proj, slicesrctiffPath)
|
||||||
|
write_envi(im_data_temp, geotrans_temp, im_proj, sliceBinPath)
|
||||||
|
Image.fromarray(im_data_temp).save(slicepngPath, compress_level=4)
|
||||||
|
|
||||||
|
for P in MLCPoints:
|
||||||
|
Px = P[0]
|
||||||
|
Py = P[1]
|
||||||
|
Sx = P[0] - portsliceSize / 2
|
||||||
|
Sy = P[1] - portsliceSize / 2
|
||||||
|
wi = Sx if Sx > 0 else 0
|
||||||
|
hi = Sy if Sy > 0 else 0
|
||||||
|
slice_ID = slice_ID + 1
|
||||||
|
im_data_temp = im_data[hi:hi + portsliceSize, wi:wi + portsliceSize]
|
||||||
|
src_im_data_temp = src_im_data[hi:hi + portsliceSize, wi:wi + portsliceSize]
|
||||||
|
|
||||||
|
sliceBinPath = os.path.join(binfolder, rootname + "_" + str(slice_ID).zfill(4) + "_image.tiff")
|
||||||
|
slicepngPath = os.path.join(pngfolder, rootname + "_" + str(slice_ID).zfill(4) + "_image.png")
|
||||||
|
slicesrctiffPath = os.path.join(tifffolder, rootname + "_" + str(slice_ID).zfill(4) + "_image.tiff")
|
||||||
|
|
||||||
|
geotrans_temp = getsliceGeotrans(im_Geotrans, wi, hi)
|
||||||
|
write_tiff(src_im_data_temp, geotrans_temp, im_proj, slicesrctiffPath)
|
||||||
|
write_envi(im_data_temp, geotrans_temp, im_proj, sliceBinPath)
|
||||||
|
Image.fromarray(im_data_temp).save(slicepngPath, compress_level=4)
|
||||||
|
|
||||||
print("图像切片结束")
|
print("图像切片结束")
|
||||||
return slice_ID
|
return slice_ID
|
||||||
|
|
@ -439,8 +480,8 @@ def stretchSliceProcess(infilepath, outfolder,portfilestr, strechmethod):
|
||||||
slice_ID=0
|
slice_ID=0
|
||||||
slice_ID=sliceShipDataset(rootname,im_data, src_im_data,im_Geotrans, im_proj, outfolder) # 舰船切片
|
slice_ID=sliceShipDataset(rootname,im_data, src_im_data,im_Geotrans, im_proj, outfolder) # 舰船切片
|
||||||
slice_ID=slice_ID+1
|
slice_ID=slice_ID+1
|
||||||
# slice_ID=slicePortDataset(rootname,im_data, src_im_data,im_Geotrans, im_proj, outfolder,slice_ID,portfilestr)
|
slice_ID=slicePortDataset(rootname,im_data, src_im_data,im_Geotrans, im_proj, outfolder,slice_ID,portfilestr)
|
||||||
slice_ID=sliceLabelPortDataset(rootname,im_data, src_im_data,im_Geotrans, im_proj, outfolder,slice_ID,portfilestr) # 港口拉伸
|
# slice_ID=sliceLabelPortDataset(rootname,im_data, src_im_data,im_Geotrans, im_proj, outfolder,slice_ID,portfilestr) # 港口拉伸
|
||||||
print("图像切片与拉伸完成")
|
print("图像切片与拉伸完成")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ from pathlib import Path
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
"""
|
"""
|
||||||
1. 港口,5000x5000,君港与民港切片,
|
1. 港口,5000x5000,军港与民港切片,
|
||||||
a. 预标注框给他们
|
a. 预标注框给他们
|
||||||
b. 重叠率25%重复
|
b. 重叠率25%重复
|
||||||
c. 君民2000m 以内,影像抽出来
|
c. 军民2000m 以内,影像抽出来
|
||||||
d. 原影像如果只有 1 个港口,-》 港口类型
|
d. 原影像如果只有 1 个港口,-》 港口类型
|
||||||
多 个港口,-》 远近,如果港口距离1000m ,单独拉出来
|
多 个港口,-》 远近,如果港口距离1000m ,单独拉出来
|
||||||
|
|
||||||
|
|
@ -269,8 +269,8 @@ def getParams():
|
||||||
parser.add_argument('-o', '--outfilepath',type=str,default=r'D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250903-不分类\A-预处理\JMPort.txt', help='输出geojson文件')
|
parser.add_argument('-o', '--outfilepath',type=str,default=r'D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250903-不分类\A-预处理\JMPort.txt', help='输出geojson文件')
|
||||||
parser.add_argument('-f', '--folderOutpath',type=str,help=r'PortfolderOutpath', default=r'D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250903-不分类\A-预处理\PortPoints')
|
parser.add_argument('-f', '--folderOutpath',type=str,help=r'PortfolderOutpath', default=r'D:\TYSAR-德清院\TYSAR-条带模式(SM)\港口\20250903-不分类\A-预处理\PortPoints')
|
||||||
parser.add_argument('-m', '--mLC',type=str,help=r'MLC', default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\港口(民船).shp')
|
parser.add_argument('-m', '--mLC',type=str,help=r'MLC', default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\港口(民船).shp')
|
||||||
parser.add_argument('-j', '--jLC',type=str,help=r'JLC' ,default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\君港.shp')
|
parser.add_argument('-j', '--jLC',type=str,help=r'JLC' ,default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\军港.shp')
|
||||||
parser.add_argument('-jm', '--jmlc',type=str,help=r'JMLC', default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\君民一体港口.shp')
|
parser.add_argument('-jm', '--jmlc',type=str,help=r'JMLC', default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\军民一体港口.shp')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -247,10 +247,10 @@ def getParams():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-s','--srcfolder',type=str,default=r'R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口', help='输入shapefile文件')
|
parser.add_argument('-s','--srcfolder',type=str,default=r'R:\TYSAR-德清院\TYSAR-条带模式(SM)\港口', help='输入shapefile文件')
|
||||||
parser.add_argument('-i','--intiffolder',type=str,default=r'D:\TYSAR-德清院\切片结果整理', help='输入shapefile文件')
|
parser.add_argument('-i','--intiffolder',type=str,default=r'D:\TYSAR-德清院\切片结果整理', help='输入shapefile文件')
|
||||||
parser.add_argument('-o', '--outfolder',type=str,default=r'D:\TYSAR-德清院\君民区分结果', help='输出geojson文件')
|
parser.add_argument('-o', '--outfolder',type=str,default=r'D:\TYSAR-德清院\军民区分结果', help='输出geojson文件')
|
||||||
parser.add_argument('-m', '--mLC',type=str,help=r'MLC', default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\港口(民船).shp')
|
parser.add_argument('-m', '--mLC',type=str,help=r'MLC', default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\港口(民船).shp')
|
||||||
parser.add_argument('-j', '--jLC',type=str,help=r'JLC' ,default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\君港.shp')
|
parser.add_argument('-j', '--jLC',type=str,help=r'JLC' ,default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\军港.shp')
|
||||||
parser.add_argument('-jm', '--jmLC',type=str,help=r'MJLC', default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\君民一体港口.shp')
|
parser.add_argument('-jm', '--jmLC',type=str,help=r'MJLC', default=r'D:\TYSAR-德清院\目标点位信息更新\0828目标点位\军民一体港口.shp')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue