WORK備忘録

メモ

AppleScript HTML作成

2016-04-24 22:10:33 | 日記

set html_head to "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>

<title>類似画像検査結果</title>
</head>
<body>

類似画像検査結果



"

set html_foot to "


</body>
</html>"


set kakucho to ".jpg"

set file_1 to "doubutu321_1" & kakucho
set file_1_name to "doubutu321_1"

set file_2 to "doubutu321_2" & kakucho
set file_2_name to "doubutu321_2"


set tb_data to "
" & file_1_name & "
" & file_2_name & " " & return

set html_text to html_head & tb_data & html_foot


AppleScript HTML作成

2016-04-24 22:10:33 | 日記

set html_head to "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
\"http://www.w3.org/TR/html4/loose.dtd\">
<html>
<head>

<title>類似画像検査結果</title>
</head>
<body>

類似画像検査結果

" set html_foot to "
</body> </html>" set kakucho to ".jpg" set file_1 to "doubutu321_1" & kakucho set file_1_name to "doubutu321_1" set file_2 to "doubutu321_2" & kakucho set file_2_name to "doubutu321_2" set tb_data to " " & file_1_name & " " & file_2_name & " " & return set html_text to html_head & tb_data & html_foot

類似画像

2016-04-17 21:50:31 | 日記
set allhist_list to do shell script "cat /Users/nagayoshinaoya/Desktop/his/hislist.txt"

set allph_cou to count every paragraph of allhist_list


set px_all_count to 79807

set ItemList to allph_cou
repeat with kijyun from 1 to allph_cou --基準画像
set list_a to paragraph kijyun of allhist_list

repeat with i from 1 to allph_cou

if kijyun ≠ i then
set list_b to paragraph i of allhist_list


--log list_a & "a"
--log list_b & "b" & return


set min_goukei to min(list_a, list_b, px_all_count)


log min_goukei
end if

end repeat

end repeat




--ハンドラ
on min(_a, _b, px_all_count)

set saisyoukekka to 0

repeat with i from 2 to 5
set asdlm to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
try
set fname1 to (text item 1 of _a as string)
set fname2 to (text item 1 of _b as string)


set it1 to (text item i of _a as string)
set it2 to (text item i of _b as string)
set AppleScript's text item delimiters to asdlm
on error
set AppleScript's text item delimiters to asdlm
return
end try
--最小値取得
if it1 < it2 then
set min_item to it1
else
set min_item to it2
end if

set saisyoukekka to saisyoukekka + (min_item as integer)
set kekka to (saisyoukekka / px_all_count) * 100
end repeat

set kekka_text to fname1 & tab & fname2 & tab & tab & kekka --3.tif 4.tif 100.0
return kekka_text

end min


--データ
(*
1.tif,15815,18734,44488,770
2.tif,15813,18736,44480,778
3.tif,15815,18734,44487,771
4.tif,15815,18734,44487,771
*)

ヒストグラム減色

2016-04-17 21:49:17 | 日記
set hist to {0, 0, 0, 0, 0, 1, 3, 27, 91, 264, 425, 724, 888, 819, 604, 585, 474, 422, 467, 486, 478, 464, 472, 524, 483, 473, 460, 438, 441, 378, 384, 298, 256, 229, 200, 164, 148, 134, 137, 129, 113, 122, 111, 109, 116, 109, 131, 112, 134, 115, 95, 108, 115, 120, 135, 113, 124, 107, 123, 115, 128, 107, 153, 128, 113, 148, 129, 136, 135, 152, 146, 126, 144, 163, 173, 164, 152, 172, 181, 161, 176, 175, 179, 203, 203, 191, 226, 201, 234, 214, 240, 240, 206, 223, 248, 260, 263, 278, 250, 273, 281, 283, 302, 304, 295, 285, 238, 280, 277, 268, 301, 314, 334, 366, 369, 398, 414, 471, 501, 571, 595, 643, 704, 629, 624, 627, 620, 564, 661, 689, 765, 789, 862, 848, 878, 990, 988, 1037, 1127, 1230, 1354, 1474, 1752, 1973, 1806, 1288, 760, 579, 613, 629, 743, 756, 756, 771, 805, 902, 958, 993, 925, 922, 911, 1000, 1243, 1300, 1405, 1386, 1423, 1217, 662, 418, 239, 148, 122, 116, 115, 119, 94, 90, 89, 79, 69, 81, 57, 81, 43, 61, 47, 65, 48, 44, 46, 40, 40, 55, 39, 44, 34, 41, 44, 56, 45, 33, 33, 33, 40, 28, 28, 30, 23, 27, 20, 22, 14, 15, 9, 7, 8, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}


set file_name to "ABC.tif"
set w to 1234 as string
set h to 5678 as string


set his_henkan to hist_gensyoku(hist) --減色値タブ区切り
set file_name to file_name & tab & w & tab & h & tab & his_henkan




--減色ルーチン
on hist_gensyoku(hist)

--0,63,127,91,255

set hist1 to items 1 thru 64 of hist
set hist1 to hist_gokei(hist1) of me

set hist2 to items 65 thru 128 of hist
set hist2 to hist_gokei(hist2) of me


set hist3 to items 129 thru 192 of hist
set hist3 to hist_gokei(hist3) of me

set hist4 to items 193 thru 256 of hist
set hist4 to hist_gokei(hist4) of me

set gensyoku_hist to hist1 & tab & hist2 & tab & hist3 & tab & hist4

end hist_gensyoku

--抽出リスト合計ルーチン
on hist_gokei(a_histrist)

set asdlm to AppleScript's text item delimiters
set AppleScript's text item delimiters to " + "
try
set calcString to (a_histrist as string)
set AppleScript's text item delimiters to asdlm
on error
set AppleScript's text item delimiters to asdlm
return
end try

set gokei to do shell script "echo " & quoted form of calcString & " | bc"
return gokei
end hist_gokei