惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
U
Unit 42
罗磊的独立博客
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
Vercel News
Vercel News
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
Hugging Face - Blog
Hugging Face - Blog
大猫的无限游戏
大猫的无限游戏
F
Fortinet All Blogs
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
博客园 - 【当耐特】
H
Help Net Security
The GitHub Blog
The GitHub Blog

hwchiu learning note Blog

Kubernetes 怎麼計算 imageFS | hwchiu learning note Nginx Proxy_Pass 不會重新查詢 DNS | hwchiu learning note Multus 下如何透過 network policy 設定 | hwchiu learning note Linux Bridge MTU | hwchiu learning note Kubevirt 初體驗 | hwchiu learning note [MacOS ]隨手筆記 Sed 與 Rename 的使用 | hwchiu learning note Docusaurus 使用 blog mode 後連結一直反白的問題 | hwchiu learning note gcloud 切換帳號 | hwchiu learning note k8s 內安裝 redis-cluster | hwchiu learning note Helm Chart 中如何根據條件來動態安裝 Template 內的物件 | hwchiu learning note GCS 操作上注意事項 | hwchiu learning note istio 操作記錄 | hwchiu learning note terraform | hwchiu learning note Kubernetes GKE 維運上小筆記 | hwchiu learning note Git 修改 author/committer | hwchiu learning note GCP NAT 相關筆記 | hwchiu learning note gcloud ssh 到 GCP VM | hwchiu learning note CloudSQL 收費注意事項 | hwchiu learning note Loki 安裝上的參數調整以及 Ring 的問題除錯 | hwchiu learning note kustomize + helm | hwchiu learning note 觀測 K8s 內 OOM 事件 | hwchiu learning note GKE 上的 RBAC 筆記 | hwchiu learning note 本地產生 jwt token | hwchiu learning note ArgoCD 安裝筆記 | hwchiu learning note CircleCI Context 的使用 | hwchiu learning note 透過 GCP IAP Gateway 來保護 GKE 內的網站 | hwchiu learning note 閱讀筆記: 「SRE 的工作介绍」 | hwchiu learning note 閱讀筆記: 「DevOps is a failure」 | hwchiu learning note 閱讀筆記: 「面試人生 - 設計一個簡易的分散式 Job Scheduler」 | hwchiu learning note 閱讀筆記: 「Cloudflare 06/21 災後報告」 | hwchiu learning note
Matlab 簡單練習 | hwchiu learning note
2013-03-29 · via hwchiu learning note Blog

應朋友的要求,用matlab幫忙寫了一個簡單的腳本

需要能夠ˋ彈出對話框選擇一個資料夾,讀取資料夾底下的影像檔,然後與某個特定的影像檔做相減,並命名輸出

這部分用到了一些指令,在這邊紀錄下來

%choose directory
target_path = uigetdir();
file_path = [target_path '/C00*.tif'];
background = [target_path '/REF.tif'];
file_struct = dir(file_path);
back_struct = dir(background);

%load background image
back = imread([target_path '/' back_struct.name]);
for i=1:length(file_struct)
temp_image = imread([target_path '/' file_struct(i).name]);
result_image = imsubtract(temp_image,back);
imwrite(result_image,[target_path '/new' file_struct(i).name]);
end

====END=======

首先使用到了uigetdir,與其類似的還有uigetfile

呼叫此函數後,會彈出directoryOpenDialog的介面,選擇完畢後,會把選擇的路徑回傳

接下來我想要移動到該路徑,於是希望透過 cd 這個指令,無奈 cd這個指令沒有辦法吃參數,只能吃完整路徑,所以就必須要改換成其他的方法

由於我已經知道圖檔的命名規則,於是先用 [] 的方式,把字串給連接起來,這邊使用regular的方式,之後再搜尋檔案的時候會更方便

接者使用dir這個指令,就可以得到我想要的所有檔案,dir回傳的是一個struct,內容包含了檔案的

name -- 檔案名稱 date -- 修改日期 bytes -- 檔案大小 isdir -- 是否為資料夾 datenum -- Matlab特定的修改日期

這邊我只需要它的名稱,於是透過一個迴圈,把所有的路徑檔案都以圖片的方式(imread)給讀取近來 在與事先讀取好的背景圖片(back)使用imsubtract做相減,得到新的圖片,再透過imwrite給寫出檔案