example: displaytiffinfo 指導教授 : 黃文楨 學生 :9624707 林宗道

5
Example: DisplayTiffInfo 指指指指 : 指指指 指指 :9624707 指指指

Post on 20-Dec-2015

232 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: Example: DisplayTiffInfo 指導教授 : 黃文楨 學生 :9624707 林宗道

Example: DisplayTiffInfo

指導教授 :黃文楨 學生 :9624707 林宗道

Page 2: Example: DisplayTiffInfo 指導教授 : 黃文楨 學生 :9624707 林宗道

DisplayTiffInfo 程式碼 macro "Display TIFF Info" { if (getVersion>="1.39t") { print("\nImage description from '"+getTitle+"':"); print(getInfo("image.description")); return; } setBatchMode(true); 背景執行 id = getImageID(); title = getTitle(); if (indexOf(toLowerCase(title), “.tif”)==-1) 沒有找到特定字串 exit("The macro requires a TIFF image"); dir = getDirectory("image"); if (isOpen(“Log”)) { 如果有 log 時,將關閉” image”且開啟log selectWindow("Log"); run("Close"); }

Page 3: Example: DisplayTiffInfo 指導教授 : 黃文楨 學生 :9624707 林宗道

開啟偵錯控制項 (ㄧ )

setOption("DebugMode", true);

open(dir+title); 開啟新視窗 close();

run("Misc...", "divide=Infinity antialiased");

selectWindow("Log");

info = getInfo(); 把錯誤訊息回傳到 getinfo

run("Close");

Page 4: Example: DisplayTiffInfo 指導教授 : 黃文楨 學生 :9624707 林宗道

開啟偵錯控制項 (二 )

setOption(“DebugMode”, false); 關閉偵錯控制項 index1 = indexOf(info, "Image Description:"); if (index1==-1) 表示沒有找到特定字串 exit("This TIFF does not appear to have an image description

tag"); index1 += 19; index2=indexOf(info, “\n”, index1); 找到有” \n”回傳到 index1 data = substring(info, index1,index2); ( 起始索引 ,終止索引 ) if (lengthOf(data)>200 && indexOf(data, "\n")==-1) exit("The image description is longer than 200 characters."); showMessage ("Image description from "+title, data);

Page 5: Example: DisplayTiffInfo 指導教授 : 黃文楨 學生 :9624707 林宗道

執行結果

Image description from 'Sunset.jpg':