【HALCON】タプル操作完全ガイド - tuple関数リファレンス
HALCONのタプル(Tuple)は、複数の値を一つのデータ構造として扱うための基本データ型です。数値、文字列、混合データを格納でき、画像処理やデータ解析において広く使用されます。
基本操作
tuple_length - タプルの長さを取得
タプル内の要素数を取得します。
tuple_length(Tuple, Length)
Tuple := [10, 20, 30, 40, 50]
tuple_length(Tuple, Length)
* Length = 5
tuple_select - 要素の選択
指定したインデックスの要素を取得します。
tuple_select(Tuple, Index, Selected)
Tuple := ['a', 'b', 'c', 'd']
tuple_select(Tuple, 2, Selected)
* Selected = 'c'
tuple_concat - タプルの結合
2つのタプルを結合します。
tuple_concat(Tuple1, Tuple2, Concatenated)
Tuple1 := [1, 2, 3]
Tuple2 := [4, 5, 6]
tuple_concat(Tuple1, Tuple2, Result)
* Result = [1, 2, 3, 4, 5, 6]
tuple_sort - ソート
タプルを昇順にソートします。
tuple_sort(Tuple, Sorted)
tuple_find - 要素の検索
タプル内で特定の値を検索し、インデックスを返します。
tuple_find(Tuple, ToFind, Indices)
数学関数
算術演算
| 関数 | 説明 | 例 |
|---|---|---|
tuple_add | 加算 | tuple_add([1,2], [3,4], R) → [4,6] |
tuple_sub | 減算 | tuple_sub([5,6], [1,2], R) → [4,4] |
tuple_mult | 乗算 | tuple_mult([2,3], [4,5], R) → [8,15] |
tuple_div | 除算 | tuple_div([10,20], [2,4], R) → [5,5] |
tuple_mod | 剰余 | tuple_mod([10,11], [3,3], R) → [1,2] |
tuple_neg | 符号反転 | tuple_neg([1,-2], R) → [-1,2] |
tuple_abs | 絶対値 | tuple_abs([-1,2,-3], R) → [1,2,3] |
tuple_pow | べき乗 | tuple_pow([2,3], [3,2], R) → [8,9] |
tuple_sqrt | 平方根 | tuple_sqrt([4,9,16], R) → [2,3,4] |
三角関数
| 関数 | 説明 |
|---|---|
tuple_sin | 正弦(サイン) |
tuple_cos | 余弦(コサイン) |
tuple_tan | 正接(タンジェント) |
tuple_asin | 逆正弦 |
tuple_acos | 逆余弦 |
tuple_atan | 逆正接 |
tuple_atan2 | 2引数逆正接 |
tuple_sinh | 双曲線正弦 |
tuple_cosh | 双曲線余弦 |
tuple_tanh | 双曲線正接 |
対数・指数関数
| 関数 | 説明 |
|---|---|
tuple_exp | 指数関数(e^x) |
tuple_log | 自然対数 |
tuple_log10 | 常用対数 |
tuple_ldexp | 2のべき乗スケーリング |
丸め関数
| 関数 | 説明 |
|---|---|
tuple_floor | 切り捨て |
tuple_ceil | 切り上げ |
tuple_round | 四捨五入 |
tuple_fabs | 浮動小数点絶対値 |
tuple_fmod | 浮動小数点剰余 |
角度変換
| 関数 | 説明 |
|---|---|
tuple_rad | 度からラジアンへ変換 |
tuple_deg | ラジアンから度へ変換 |
統計関数
| 関数 | 説明 |
|---|---|
tuple_min | 最小値 |
tuple_max | 最大値 |
tuple_min2 | 要素ごとの最小値 |
tuple_max2 | 要素ごとの最大値 |
tuple_mean | 平均値 |
tuple_median | 中央値 |
tuple_sum | 合計 |
tuple_cumul | 累積和 |
tuple_deviation | 標準偏差 |
比較演算
| 関数 | 説明 |
|---|---|
tuple_equal | 等しい |
tuple_not_equal | 等しくない |
tuple_greater | より大きい |
tuple_greater_equal | 以上 |
tuple_less | より小さい |
tuple_less_equal | 以下 |
tuple_equal_elem | 要素ごとの等価比較 |
tuple_greater_elem | 要素ごとの大小比較 |
論理・ビット演算
論理演算
| 関数 | 説明 |
|---|---|
tuple_and | 論理AND |
tuple_or | 論理OR |
tuple_not | 論理NOT |
tuple_xor | 排他的OR |
ビット演算
| 関数 | 説明 |
|---|---|
tuple_band | ビットAND |
tuple_bor | ビットOR |
tuple_bxor | ビットXOR |
tuple_bnot | ビットNOT |
tuple_lsh | 左シフト |
tuple_rsh | 右シフト |
文字列操作
基本操作
| 関数 | 説明 |
|---|---|
tuple_string | 数値を文字列に変換 |
tuple_number | 文字列を数値に変換 |
tuple_strlen | 文字列長を取得 |
tuple_substr | 部分文字列を取得 |
tuple_split | 文字列を分割 |
検索
| 関数 | 説明 |
|---|---|
tuple_strchr | 文字を検索 |
tuple_strrchr | 文字を後方から検索 |
tuple_strstr | 部分文字列を検索 |
tuple_strrstr | 部分文字列を後方から検索 |
正規表現
| 関数 | 説明 |
|---|---|
tuple_regexp_match | 正規表現マッチング |
tuple_regexp_replace | 正規表現置換 |
tuple_regexp_select | 正規表現選択 |
tuple_regexp_test | 正規表現テスト |
文字コード
| 関数 | 説明 |
|---|---|
tuple_chr | 文字コードを文字に変換 |
tuple_ord | 文字を文字コードに変換 |
選択・操作
| 関数 | 説明 |
|---|---|
tuple_first_n | 先頭からN個の要素を取得 |
tuple_last_n | 末尾からN個の要素を取得 |
tuple_select_range | 範囲を選択 |
tuple_select_mask | マスクで選択 |
tuple_select_rank | ランクで選択 |
tuple_insert | 要素を挿入 |
tuple_remove | 要素を削除 |
tuple_replace | 要素を置換 |
tuple_inverse | 順序を反転 |
tuple_uniq | 重複を除去 |
集合演算
| 関数 | 説明 |
|---|---|
tuple_union | 和集合 |
tuple_intersection | 積集合 |
tuple_difference | 差集合 |
tuple_symmdiff | 対称差 |
型チェック・変換
| 関数 | 説明 |
|---|---|
tuple_type | 型を取得 |
tuple_is_int | 整数かどうか |
tuple_is_real | 実数かどうか |
tuple_is_string | 文字列かどうか |
tuple_is_number | 数値かどうか |
tuple_is_mixed | 混合型かどうか |
tuple_int | 整数に変換 |
tuple_real | 実数に変換 |
生成関数
| 関数 | 説明 | 例 |
|---|---|---|
tuple_gen_const | 定数タプル生成 | tuple_gen_const(5, 0, T) → [0,0,0,0,0] |
tuple_gen_sequence | 連番タプル生成 | tuple_gen_sequence(5, 1, 2, T) → [1,3,5,7,9] |
tuple_rand | 乱数タプル生成 | tuple_rand(5, R) |
使用例
座標データの処理
* 点群のX座標とY座標
XCoords := [10, 20, 30, 40, 50]
YCoords := [15, 25, 35, 45, 55]
* 各点の距離を計算
tuple_mult(XCoords, XCoords, X2)
tuple_mult(YCoords, YCoords, Y2)
tuple_add(X2, Y2, Sum)
tuple_sqrt(Sum, Distances)
* 平均距離
tuple_mean(Distances, MeanDistance)
文字列処理
* ファイル名から拡張子を抽出
FileName := 'image_001.png'
tuple_strrchr(FileName, '.', Pos)
tuple_substr(FileName, Pos, 4, Extension)
* Extension = '.png'
まとめ
HALCONのタプル関数は、数値計算、文字列操作、データ変換など、画像処理に必要なあらゆるデータ操作をサポートしています。適切な関数を組み合わせることで、効率的なデータ処理が可能です。
Recommend
2024-09-13
【HALCON】regiongrowing 関数について - 領域拡張によるセグメンテーション
2024-09-13
【HALCON】rgb1_to_gray 関数について - RGB画像をグレースケール画像に変換
2024-09-13
【HALCON】sobel_amp 関数について - Sobelフィルタによるエッジ強度の計算
2024-09-13
【HALCON】write_image 関数について - 画像の保存
2024-09-13
【HALCON】xyz_to_object_model_3d 関数について - XYZデータから3Dオブジェクトモデルの生成
2024-09-12
【HALCON】read_cam_par 関数について - カメラパラメータの読み込み
2024-09-12
【HALCON】read_object_model_3d 関数について - 3Dオブジェクトモデルの読み込み
2024-09-12
【HALCON】read_ocr_class_mlp 関数について - MLP OCRクラス分類器の読み込み
2024-09-12
【HALCON】set_system 関数について - システムパラメータの設定
2024-09-12
【HALCON】smallest_circle 関数について - 最小外接円の計算
2024-09-12
【HALCON】smallest_rectangle1 関数について - 最小外接矩形(軸平行)の計算
2024-09-12
【HALCON】タプル操作完全ガイド - tuple関数リファレンス