中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

現(xiàn)在主流的web框架東莞seo軟件

現(xiàn)在主流的web框架,東莞seo軟件,巴中學(xué)校網(wǎng)站建設(shè),福州企業(yè)自助建站.dat文件的命名規(guī)則沒有統(tǒng)一的規(guī)定,但通常以.dat為擴(kuò)展名。 目錄 一、 .dat格式數(shù)據(jù)1.1 .dat數(shù)據(jù)用途1.2 常見的.dat文件格式1.3 .dat文件示例 二、讀取.dat格式數(shù)據(jù)2.1 單個.dat文件讀取并轉(zhuǎn)換2.1.1 代碼2.1.2 查看數(shù)據(jù)2.1.3 輸出查看8Bit圖片 2.2 批量.dat文件讀取…

.dat文件的命名規(guī)則沒有統(tǒng)一的規(guī)定,但通常以.dat為擴(kuò)展名。

目錄

  • 一、 .dat格式數(shù)據(jù)
    • 1.1 .dat數(shù)據(jù)用途
    • 1.2 常見的.dat文件格式
    • 1.3 .dat文件示例
  • 二、讀取.dat格式數(shù)據(jù)
    • 2.1 單個.dat文件讀取并轉(zhuǎn)換
      • 2.1.1 代碼
      • 2.1.2 查看數(shù)據(jù)
      • 2.1.3 輸出查看8Bit圖片
    • 2.2 批量.dat文件讀取并轉(zhuǎn)換
      • 2.2.1 代碼參數(shù)修改
      • 2.2.2 代碼
      • 2.2.3 批量轉(zhuǎn)換結(jié)果
  • 三、總結(jié)

一、 .dat格式數(shù)據(jù)

.dat格式數(shù)據(jù)是一種通用的二進(jìn)制文件格式,可以用于存儲各種類型的數(shù)據(jù)。.dat文件的格式可以是任意的,因此需要根據(jù)數(shù)據(jù)的具體格式來編寫代碼來讀取數(shù)據(jù)。

1.1 .dat數(shù)據(jù)用途

存儲文本數(shù)據(jù),例如用戶配置信息或日志數(shù)據(jù)。

存儲二進(jìn)制數(shù)據(jù),例如圖像數(shù)據(jù)或音頻數(shù)據(jù)。

存儲結(jié)構(gòu)化數(shù)據(jù),例如數(shù)據(jù)庫表格。

1.2 常見的.dat文件格式

文本格式:數(shù)據(jù)以字符串的形式存儲。

二進(jìn)制格式:數(shù)據(jù)以二進(jìn)制數(shù)據(jù)的形式存儲。

結(jié)構(gòu)化格式:數(shù)據(jù)以結(jié)構(gòu)化的形式存儲。

注:如果不確定.dat文件的格式,您以嘗試使用hex編輯器來查看數(shù)據(jù)的二進(jìn)制格式。

1.3 .dat文件示例

用戶配置文件:通常用于存儲用戶的個人偏好或設(shè)置。

日志文件:通常用于記錄系統(tǒng)或應(yīng)用程序的運(yùn)行情況。

圖像文件:通常用于存儲圖像數(shù)據(jù)。

音頻文件:通常用于存儲音頻數(shù)據(jù)。

數(shù)據(jù)庫文件:通常用于存儲數(shù)據(jù)庫表格的數(shù)據(jù)。

二、讀取.dat格式數(shù)據(jù)

2.1 單個.dat文件讀取并轉(zhuǎn)換

這里主要是使用numpy讀取,我自己的.dat文件存放著圖像數(shù)據(jù),且圖像數(shù)據(jù)的尺寸為256*192,學(xué)者在使用該教程中代碼時,得提前明確自己的.dat文件是否存儲的是圖像數(shù)據(jù),且明確圖像尺寸。

使用代碼修改的地方如下:

在這里插入圖片描述

2.1.1 代碼

import numpy as np
import cv2def float32_to_unit8(img):max_val = img.max()min_val = img.min()img = (img - min_val)/(max_val - min_val) * 255img = img.astype(np.uint8)return imgdat_f = open("data/INF_AiRui/groundtruth/nuc_1879538664.dat")
# 讀取數(shù)據(jù)
data = np.fromfile(dat_f,dtype=np.uint16)# 定義圖片的列數(shù)和函數(shù)
col = 256
row = 192# 將一維data數(shù)組轉(zhuǎn)換為二位數(shù)組
dataReshape = data.reshape(row,col)# 調(diào)用float32_to_unit8函數(shù)將16bit數(shù)據(jù)轉(zhuǎn)為uint8數(shù)據(jù)
imgUint8 = float32_to_unit8(dataReshape)# 顯示uint8圖像
cv2.imshow("result_image",imgUint8)
cv2.waitKey(0)
cv2.destroyAllWindows()

2.1.2 查看數(shù)據(jù)

這里查看數(shù)據(jù)主要是通過DeBug解析每一步查看,如下:

在這里插入圖片描述

在這里插入圖片描述

在這里插入圖片描述

2.1.3 輸出查看8Bit圖片

直接運(yùn)行上面代碼后就可以輸出單個.dat數(shù)據(jù)轉(zhuǎn)換后的uint8圖片,如下:

在這里插入圖片描述

2.2 批量.dat文件讀取并轉(zhuǎn)換

2.2.1 代碼參數(shù)修改

主體代碼和上面一樣,就加了遍歷文件夾的代碼,需要修改的地方如下:

在這里插入圖片描述

2.2.2 代碼

import numpy as np
import cv2
import os
import sysdef float32_to_unit8(img):max_val = img.max()min_val = img.min()img = (img - min_val)/(max_val - min_val) * 255img = img.astype(np.uint8)return imgdat_path = "data/INF_AiRui/groundtruth"
save_path = "data/INF_AiRui_bmp/groundtruth"dat_file = os.listdir(path = dat_path)for file_name in dat_file:dat_f = open(os.path.join(dat_path,file_name))# 讀取數(shù)據(jù)data = np.fromfile(dat_f,dtype=np.uint16)# 定義圖片的列數(shù)和函數(shù)col = 256row = 192# 將一維data數(shù)組轉(zhuǎn)換為二位數(shù)組dataReshape = data.reshape(row,col)# 調(diào)用float32_to_unit8函數(shù)將16bit數(shù)據(jù)轉(zhuǎn)為uint8數(shù)據(jù)imgUint8 = float32_to_unit8(dataReshape)out_dat_name = file_name[:-4]+".bmp"print("圖片{}轉(zhuǎn)換成功!".format(file_name[:-4]))cv2.imwrite(os.path.join(save_path,out_dat_name),imgUint8)key = cv2.waitKey(30) & 0xffif key == 27:sys.exit(0)

2.2.3 批量轉(zhuǎn)換結(jié)果

在這里插入圖片描述

三、總結(jié)

以上就是使用Python讀取.dat格式數(shù)據(jù)并轉(zhuǎn)為.png,.jpg,.bmp等可視化格式的過程及詳細(xì)代碼,本代碼轉(zhuǎn)換只適用于.dat存儲的是圖像數(shù)據(jù),其它數(shù)據(jù)不適用。

總結(jié)不易,多多支持,謝謝!

http://www.risenshineclean.com/news/49974.html

相關(guān)文章:

  • 有贊商城網(wǎng)站建設(shè)企業(yè)網(wǎng)站怎么制作
  • 低價網(wǎng)站建設(shè)順德企業(yè)qq手機(jī)版
  • wordpress調(diào)用側(cè)邊欄關(guān)鍵詞優(yōu)化怎么操作
  • 網(wǎng)站建設(shè)論文大全小紅書網(wǎng)絡(luò)營銷策劃方案
  • 本科畢業(yè)論文答辯稿網(wǎng)站開發(fā)阿里云萬網(wǎng)域名注冊
  • html5高端網(wǎng)站建設(shè)織夢模板下載營銷軟件網(wǎng)
  • 網(wǎng)站開發(fā)人員必備技能谷歌外貿(mào)平臺叫什么
  • 涉縣企業(yè)做網(wǎng)站推廣邯鄲seo推廣
  • css div網(wǎng)站網(wǎng)時代教育培訓(xùn)機(jī)構(gòu)官網(wǎng)
  • 義烏專業(yè)做網(wǎng)站的在線客服系統(tǒng)
  • 做貿(mào)易做個外貿(mào)網(wǎng)站有必要嗎公司想做個網(wǎng)站怎么辦
  • 學(xué)校校園網(wǎng)站建設(shè)方案百度信息流賬戶搭建
  • wordpress 單頁案例seo全網(wǎng)優(yōu)化指南
  • 怎么給自己的網(wǎng)站做seo北京網(wǎng)站優(yōu)化方法
  • 深圳自適應(yīng)網(wǎng)站開發(fā)頭條廣告入口
  • 動態(tài)網(wǎng)站開發(fā)需求外貿(mào)google推廣
  • 怎么自己做砍價網(wǎng)站網(wǎng)推是什么
  • 網(wǎng)站惡意刷seodao cn
  • 微網(wǎng)站建設(shè)合同拉新推廣怎么快速拉人
  • 公司網(wǎng)站建設(shè)是哪個部門的事情ai智能營銷系統(tǒng)
  • 黃岡網(wǎng)站制作百度一下你就知道百度官網(wǎng)
  • 網(wǎng)站開發(fā)語言哪一種好些技能培訓(xùn)網(wǎng)
  • 做代理記賬網(wǎng)站競價推廣代運(yùn)營企業(yè)
  • 如何做淘客網(wǎng)站源碼河北百度推廣seo
  • 濟(jì)寧市住房和城鄉(xiāng)建設(shè)局網(wǎng)站北京外貿(mào)網(wǎng)站優(yōu)化
  • 蘭州網(wǎng)站制作公司百度一下首頁下載安裝桌面
  • 扁平化網(wǎng)站登錄界面推廣軟件
  • 黃驊貼吧招聘2022年深圳優(yōu)化服務(wù)
  • 網(wǎng)站怎么做賺錢廣州推廣服務(wù)
  • 上海千途建站百度下載官方下載安裝