This commit is contained in:
copper 2022-05-12 18:57:30 +08:00
parent ef79be328c
commit 30ceccbd49
30 changed files with 154 additions and 61 deletions

BIN
icons/change_detect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

BIN
icons/create.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 B

BIN
icons/data_load.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
icons/delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

BIN
icons/document.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
icons/exit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
icons/filter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
icons/grid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 B

BIN
icons/grid_close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
icons/layer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
icons/open.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
icons/pan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
icons/pan_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
icons/save.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
icons/select.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
icons/toolbox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
icons/tools.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
icons/view.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

BIN
icons/zoom_in.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
icons/zoom_out.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
icons/zoom_to.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +1,42 @@
import numpy as np
def OTSU(hist):
u1=0.0#背景像素的平均灰度值
u2=0.0#前景像素的平均灰度值
th=0.0
#总的像素数目
PixSum= np.sum(hist)
#各灰度值所占总像素数的比例
PixRate=hist / PixSum
#统计各个灰度值的像素个数
Max_var = 0
#确定最大类间方差对应的阈值
GrayScale = len(hist)
for i in range(1,len(hist)):#从1开始是为了避免w1为0.
u1_tem=0.0
u2_tem=0.0
#背景像素的比列
w1=np.sum(PixRate[:i])
#前景像素的比例
w2=1.0-w1
if w1==0 or w2==0:
pass
else:#背景像素的平均灰度值
for m in range(i):
u1_tem=u1_tem+PixRate[m]*m
u1 = u1_tem * 1.0 / w1
#前景像素的平均灰度值
for n in range(i,GrayScale):
u2_tem = u2_tem + PixRate[n]*n
u2 = u2_tem / w2
#print(u1)
#类间方差公式G=w1*w2*(u1-u2)**2
tem_var=w1*w2*np.power((u1-u2),2)
#print(tem_var)
#判断当前类间方差是否为最大值。
if Max_var<tem_var:
Max_var=tem_var#深拷贝Max_var与tem_var占用不同的内存空间。
th=i
return th

45
res.qrc Normal file
View File

@ -0,0 +1,45 @@
<RCC>
<qresource prefix="/">
<file>icons\change_detect.png</file>
<file>icons\cancel.svg</file>
<file>icons\clear.svg</file>
<file>icons\edit.svg</file>
<file>icons\exit.png</file>
<file>icons\export.svg</file>
<file>icons\font.svg</file>
<file>icons\full.svg</file>
<file>icons\create.png</file>
<file>icons\data_load.png</file>
<file>icons\delete.png</file>
<file>icons\document.png</file>
<file>icons\filter.png</file>
<file>icons\grid_close.png</file>
<file>icons\grid.png</file>
<file>icons\layer.png</file>
<file>icons\open.png</file>
<file>icons\pan.png</file>
<file>icons\pan_1.png</file>
<file>icons\save.png</file>
<file>icons\select.png</file>
<file>icons\toolbox.png</file>
<file>icons\tools.png</file>
<file>icons\view.png</file>
<file>icons\zoom_in.png</file>
<file>icons\zoom_out.png</file>
<file>icons\zoom_to.png</file>
<file>icons\load.svg</file>
<file>icons\logo.svg</file>
<file>icons\model.svg</file>
<file>icons\ok.svg</file>
<file>icons\outline.svg</file>
<file>icons\paint.svg</file>
<file>icons\pan.svg</file>
<file>icons\qt.svg</file>
<file>icons\settings.svg</file>
<file>icons\splash.png</file>
<file>icons\start.svg</file>
<file>icons\vector.svg</file>
<file>icons\zoomin.svg</file>
<file>icons\zoomout.svg</file>
</qresource>
</RCC>

View File

@ -2,7 +2,7 @@ import logging
import os
from pathlib import Path
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QAction, QActionGroup, QLabel, QFileDialog
from PyQt5.QtWidgets import QAction, QActionGroup, QLabel, QFileDialog, QMenuBar
from rscder.gui.project import Create
from rscder.utils.project import Project
from rscder.utils.misc import singleton
@ -44,17 +44,18 @@ class ActionManager(QtCore.QObject):
self.menubar = None
self.status_bar = None
def set_menus(self, menubar):
def set_menus(self, menubar:QMenuBar):
self.menubar = menubar
self.file_menu = menubar.addMenu('&文件')
self.basic_menu = menubar.addMenu('&基本工具')
self.change_detection_menu = menubar.addMenu('&通用变化检测')
self.special_chagne_detec_menu = menubar.addMenu('&专题变化检测')
self.file_menu = menubar.addMenu( '&文件')
self.basic_menu = menubar.addMenu( '&基本工具')
self.change_detection_menu = menubar.addMenu( '&通用变化检测')
self.special_chagne_detec_menu = menubar.addMenu( '&专题变化检测')
self.seg_chagne_detec_menu = menubar.addMenu('&分类后变化检测')
self.postop_menu = menubar.addMenu('&检测后处理')
self.postop_menu = menubar.addMenu( '&检测后处理')
self.view_menu = menubar.addMenu('&视图')
self.plugin_menu = menubar.addMenu('&插件')
self.help_menu = menubar.addMenu('&帮助')
self.help_menu = menubar.addMenu( '&帮助')
@property
@ -83,16 +84,17 @@ class ActionManager(QtCore.QObject):
'''
File menu
'''
project_create = self.add_action(QAction('&工程创建', self.w_parent), 'File')
project_open = self.add_action(QAction('&打开工程', self.w_parent), 'File')
project_save = self.add_action(QAction('&保存工程', self.w_parent), 'File')
data_load = self.add_action(QAction('&数据加载', self.w_parent), 'File')
view_setting = self.add_action(QAction('&界面定制', self.w_parent), 'File')
exit_app = self.add_action(QAction('&退出', self.w_parent), 'File')
project_create = self.add_action(QAction(QtGui.QIcon( ':/icons/create.png' ), '&工程创建', self.w_parent), 'File')
project_open = self.add_action(QAction(QtGui.QIcon( ':/icons/open.png' ), '&打开工程', self.w_parent), 'File')
project_save = self.add_action(QAction(QtGui.QIcon( ':/icons/save.png' ),'&保存工程', self.w_parent), 'File')
data_load = self.add_action(QAction(QtGui.QIcon( ':/icons/data_load.png' ),'&数据加载', self.w_parent), 'File')
view_setting = self.add_action(QAction(QtGui.QIcon( ':/icons/view.png' ),'&界面定制', self.w_parent), 'File')
exit_app = self.add_action(QAction(QtGui.QIcon( ':/icons/exit.png' ),'&退出', self.w_parent), 'File')
project_create.triggered.connect(self.project_create)
project_open.triggered.connect(self.project_open)
project_save.triggered.connect(self.project_save)
data_load.triggered.connect(self.data_load)
view_setting.triggered.connect(self.view_setting)
exit_app.triggered.connect(self.w_parent.close)
@ -103,9 +105,9 @@ class ActionManager(QtCore.QObject):
self.file_menu.addAction(project_open)
self.file_menu.addAction(project_save)
self.file_menu.addAction(data_load)
self.file_menu.addAction(view_setting)
# self.file_menu.addAction(view_setting)
self.file_menu.addAction(exit_app)
self.view_menu.addAction(view_setting)
if self.toolbar is not None:
self.toolbar.addAction(project_create)
self.toolbar.addAction(project_open)
@ -114,14 +116,14 @@ class ActionManager(QtCore.QObject):
'''
Basic menu
'''
grid_line = self.add_action(QAction('&网格线', self.w_parent), 'Basic Line')
grid_line = self.add_action(QAction(QtGui.QIcon( ':/icons/grid.png' ),'&网格线', self.w_parent), 'Basic Line')
grid_line.setCheckable(True)
grid_line.setChecked(True)
zomm_in = self.add_action(QAction('&放大', self.w_parent), 'Basic')
zomm_out = self.add_action(QAction('&缩小', self.w_parent), 'Basic')
pan = self.add_action(QAction('&漫游', self.w_parent), 'Basic')
locate = self.add_action(QAction('&定位', self.w_parent), 'Basic')
zomm_in = self.add_action(QAction(QtGui.QIcon( ':/icons/zoom_out.png' ),'&放大', self.w_parent), 'Basic')
zomm_out = self.add_action(QAction(QtGui.QIcon( ':/icons/zoom_in.png' ),'&缩小', self.w_parent), 'Basic')
pan = self.add_action(QAction(QtGui.QIcon( ':/icons/pan_1.png' ),'&漫游', self.w_parent), 'Basic')
locate = self.add_action(QAction(QtGui.QIcon( ':/icons/zoom_to.png' ),'&定位', self.w_parent), 'Basic')
pan.setCheckable(True)
pan.setChecked(True)
@ -143,7 +145,7 @@ class ActionManager(QtCore.QObject):
'''
Plugin menu
'''
plugin_list = self.add_action(QAction('&插件列表', self.w_parent), 'Plugin')
plugin_list = self.add_action(QAction(QtGui.QIcon( ':/icons/toolbox.png' ),'&插件列表', self.w_parent), 'Plugin')
plugin_list.triggered.connect(self.plugin_list)
self.plugin_menu.addAction(plugin_list)
@ -163,10 +165,10 @@ class ActionManager(QtCore.QObject):
if self.status_bar is not None:
corr_widget = QLabel(self.status_bar)
# corr_widget.setLineWidth(200)
corr_widget.setFixedWidth(200)
corr_widget.setFixedWidth(250)
self.status_bar.addWidget(corr_widget)
scale_widget = QLabel(self.status_bar)
scale_widget.setFixedWidth(200)
scale_widget.setFixedWidth(250)
self.status_bar.addWidget(scale_widget)
self.double_map.corr_changed.connect(corr_widget.setText)
self.double_map.scale_changed.connect(scale_widget.setText)

View File

@ -1,15 +1,19 @@
from PyQt5.QtWidgets import QComboBox
from PyQt5.QtGui import QIcon
from rscder.utils.project import Project
class LayerCombox(QComboBox):
def __init__(self, parent=None):
super().__init__(parent)
self.addItem('---', None)
for layer in Project().layers.values():
self.addItem(layer.name, layer.id)
for i in range(self.count() - 1):
self.setItemIcon(i + 1, QIcon(':/icons/layer.png'))
self.currentIndexChanged.connect(self.on_changed)
self.current_layer = None

View File

@ -32,6 +32,7 @@ class LayerTree(QtWidgets.QWidget):
self.tree.setHeaderHidden(True)
# self.tree.setHeaderLabels(['图层'])
self.root.setText(0,'图层')
self.root.setIcon(0,QtGui.QIcon(':/icons/layer.png'))
# child1=QTreeWidgetItem()
# child1.setText(0,'child1')
@ -98,6 +99,7 @@ class LayerTree(QtWidgets.QWidget):
layer:PairLayer = Project().layers[layer]
item_root = QtWidgets.QTreeWidgetItem(self.root)
item_root.setText(0,layer.name)
item_root.setIcon(0, QtGui.QIcon(':/icons/document.png'))
item_root.setData(0, Qt.UserRole, LayerTree.LAYER_TOOT)
item_root.setData(0, Qt.UserRole + 1, layer.id)
item_root.setCheckState(0, Qt.Checked if layer.enable else Qt.Unchecked)
@ -112,18 +114,21 @@ class LayerTree(QtWidgets.QWidget):
grid_item.setText(0,'格网')
grid_item.setData(0, Qt.UserRole, LayerTree.GRID)
grid_item.setCheckState(0, Qt.Checked if layer.grid_enable else Qt.Unchecked)
grid_item.setIcon(0, QtGui.QIcon(':/icons/grid.png'))
item1 = QtWidgets.QTreeWidgetItem(item_root)
item1.setText(0, layer.l1_name)
item1.setCheckState(0, Qt.Checked if layer.l1_enable else Qt.Unchecked)
item1.setData(0, Qt.UserRole, LayerTree.SUB_RASTER)
item1.setData(0, Qt.UserRole + 1, LayerTree.LEFT_RASTER)
item1.setIcon(0, QtGui.QIcon(':/icons/layer.png'))
item2 = QtWidgets.QTreeWidgetItem(item_root)
item2.setText(0, layer.l2_name)
item2.setCheckState(0, Qt.Checked if layer.l2_enable else Qt.Unchecked)
item1.setData(0, Qt.UserRole, LayerTree.SUB_RASTER)
item1.setData(0, Qt.UserRole + 1, LayerTree.RIGHT_RASTER)
item2.setData(0, Qt.UserRole, LayerTree.SUB_RASTER)
item2.setData(0, Qt.UserRole + 1, LayerTree.RIGHT_RASTER)
item2.setIcon(0, QtGui.QIcon(':/icons/layer.png'))
for ri, item in enumerate(layer.results):
item_result = QtWidgets.QTreeWidgetItem(item_root)
@ -132,6 +137,8 @@ class LayerTree(QtWidgets.QWidget):
item_result.setData(0, Qt.UserRole, LayerTree.RESULT)
item_result.setData(0, Qt.UserRole + 1, ri)
item_result.setIcon(0, QtGui.QIcon(':/icons/vector.svg'))
self.tree.expandAll()
def update_layer(self, layer:str):

View File

@ -22,7 +22,7 @@ class MainWindow(QMainWindow):
self.setWindowTitle(QApplication.applicationName() + ' ' + str(self.current_instance))
else:
self.setWindowTitle(QApplication.applicationName())
self.setWindowIcon(QIcon(":/icons/logo.svg"))
self.setWindowIcon(QIcon(":/icons/change_detect.png"))
self.setAcceptDrops(True)
self.setContextMenuPolicy(Qt.CustomContextMenu)

View File

@ -2,7 +2,7 @@
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt,QModelIndex, pyqtSignal
from PyQt5.QtGui import QStandardItemModel, QStandardItem
from PyQt5.QtWidgets import (QTableWidgetItem, QTableWidget, QAbstractItemView, QHeaderView, QStyleFactory)
from PyQt5.QtWidgets import (QTableWidgetItem, QTableWidget, QMessageBox, QAbstractItemView, QHeaderView, QStyleFactory)
from rscder.utils.project import PairLayer, Project, ResultLayer
@ -56,9 +56,16 @@ class ResultTable(QtWidgets.QWidget):
y = self.tablewidget.item(row, 1).text()
self.on_item_click.emit({'x':float(x), 'y':float(y)})
def save(self):
if self.result is None:
return
self.result.save()
def on_result(self, layer_id, result_id):
self.is_in_set_data = True
result = Project().layers[layer_id].results[result_id]
if result != self.result:
self.save()
self.result = result
self.clear()
self.set_data(result)

View File

@ -1,26 +0,0 @@
<RCC>
<qresource prefix="/">
<file>icons\assessment.svg</file>
<file>icons\cancel.svg</file>
<file>icons\clear.svg</file>
<file>icons\edit.svg</file>
<file>icons\exit.svg</file>
<file>icons\export.svg</file>
<file>icons\font.svg</file>
<file>icons\full.svg</file>
<file>icons\load.svg</file>
<file>icons\logo.svg</file>
<file>icons\model.svg</file>
<file>icons\ok.svg</file>
<file>icons\outline.svg</file>
<file>icons\paint.svg</file>
<file>icons\pan.svg</file>
<file>icons\qt.svg</file>
<file>icons\settings.svg</file>
<file>icons\splash.png</file>
<file>icons\start.svg</file>
<file>icons\vector.svg</file>
<file>icons\zoomin.svg</file>
<file>icons\zoomout.svg</file>
</qresource>
</RCC>

View File

@ -83,6 +83,8 @@ class Project(QObject):
'root': self.root,
'layers': [ layer.to_dict(None if self.file_mode == Project.ABSOLUTE_MODE else self.root) for layer in self.layers.values() ],
}
for layer in self.layers.values():
layer.save()
with open(self.file, 'w') as f:
yaml.safe_dump(data_dict, f)
# yaml.safe_dump(data_dict, open(self.file, 'w'))
@ -129,19 +131,16 @@ class Project(QObject):
else:
self.message_box.error(player.msg)
class VectorLayer:
pass
class GridLayer:
def set_render(self):
symbol_layer = QgsSimpleLineSymbolLayer()
symbol_layer.setWidth(1)
symbol_layer.setColor(QColor.fromRgb(255,255,255, 100))
symbol_layer.setWidth(1 * self.x_res)
symbol_layer.setColor(QColor.fromRgb(255,255,255, 200))
symbol = QgsLineSymbol()
symbol.changeSymbolLayer(0, symbol_layer)
symbol.setWidthUnit(QgsUnitTypes.RenderMapUnits)
render = QgsSingleSymbolRenderer(symbol)
self.lines_layer.setRenderer(render)
@ -228,6 +227,14 @@ class ResultLayer:
self.enable = False
self.parent = parent
def save(self):
if self.layer_type == ResultLayer.POINT:
with open(self.path, 'w') as f:
f.write('x,y,diff,status\n')
for i in range(len(self.data)):
f.write('{},{},{},{}\n'.format(self.data[i][0], self.data[i][1], self.data[i][2], int(self.data[i][3])))
def update(self, data):
if self.layer_type == ResultLayer.POINT:
row = data['row']
@ -403,6 +410,11 @@ class PairLayer:
layer.results.append(ResultLayer.from_dict(r, layer, root))
# layer.grid_layer = GridLayer.from_dict(data['grid_layer'])
return layer
def save(self):
for r in self.results:
r.save()
def __init__(self, pth1, pth2, cell_size) -> None:
self.pth1 = pth1
self.pth2 = pth2