/* * ***************************************************************** * * * * * Copyright (c) Fast Corporation, 1997 * * * * * * All Rights Reserved. Unpublished rights reserved under * * * the copyright laws of the Japan. * * * * * * The software contained on this media is proprietary to * * * and embodies the confidential technology of Fast * * * Corporation. Possession, use, duplication or * * * dissemination of the software and media is authorized only * * * pursuant to a valid written license from Fast Corporation. * * * * * ***************************************************************** */ /* CSC90X ライン上の正規化相関処理  CALCCORR.C */ /*[作成者]H.Yagi */ /* 目的: 関数: 履歴: Ver 1.0 97/08/14 注記:m_menu.hをインクルードして下さい。 m_menu.c及びm_note.cをリンクして下さい。 */ /* * Include compiler runtime library */ #include #include /* * Include CSC90X library */ #include "f_stdlib.h" #include "f_time.h" #include "f_gui.h" #include "f_stdio.h" #include "f_graph.h" #include "f_image.h" #include "f_pinf.h" #include "f_video.h" #include "f_system.h" #include "f_math.h" /* * Include CSC90X common local */ #include "m_menu.h" /* * プロトタイプ宣言 */ void main( void ); void main_menu_disp( void ); void disp_help( void ); void para_set( void ); void kijun( int, int, int, int ); void exec( int, int, int, int ); int calc_corr( int, int[], int[] ); int get_line_level( int, int, int, int, int, int * ); int u_abs( int ); void line_set( int *, int *, int *, int * ); int area_chk( int, int, int, int ); extern int message_note( void ); /* * メニュー項目 */ #define LANG_N 2 #define MAIN_MENU_N 4 static const char *str_main_menu[MAIN_MENU_N][LANG_N] = { { " SET ", " 設 定 " }, { " EXEC ", " 実 行 " }, { " PROC3 ", " 処理3 " }, { " PROC4 ", " 処理4 " } }; #define INIT_CUR_POS_X 255 #define INIT_CUR_POS_Y 239 int xs, ys, xe, ye; static int master[512]; /*マスター濃度配列 */ static int target[512]; /*ターゲット濃度配列*/ char ss[30]; /* * メイン */ void main( void ) { int sts; int xpos; int ypos; int s_xpos; int s_ypos; /* 初期メッセージ表示 */ if( NORMAL_RETURN != message_note() ) return; /* パラメタ初期化 */ xpos = INIT_CUR_POS_X; ypos = INIT_CUR_POS_Y; s_xpos = INIT_CUR_POS_X; s_ypos = INIT_CUR_POS_Y; xs = 100; ys = 100; xe = 300; ye = 100; /* 入力ビデオ制御 */ Lib_input_video_control( GRAY_PLANE ); /* ビデオ出力表示項目制御 */ Lib_display_control( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); /* ビデオ表示項目クリア */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); /* カーソル初期化 */ Lib_init_cursor(); /* メインメニューの表示 */ main_menu_disp(); /* マウスカーソルの表示 */ Lib_draw_cursor( INIT_CUR_POS_X, INIT_CUR_POS_Y ); /* メニュー制御 */ for (;;) { sts = 0; /* マウス位置読みとり */ sts = Lib_see_current_position( &xpos, &ypos ); if ( s_xpos != xpos || s_ypos != ypos ) { /* マウス表示位置移動 */ Lib_move_cursor( xpos, ypos ); s_xpos = xpos; s_ypos = ypos; } /* 処理振り分け */ if ( CURSOR_EXECUTE == sts ) { if ( xpos > MENU_1_XS && xpos < MENU_1_XE && ypos > MENU_1_YS && ypos < MENU_1_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); para_set(); /* 設定 */ main_menu_disp(); } else if ( xpos > MENU_2_XS && xpos < MENU_2_XE && ypos > MENU_2_YS && ypos < MENU_2_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); exec( xs, ys, xe, ye ); /* 実行 */ main_menu_disp(); } else if ( xpos > MENU_H_XS && xpos < MENU_H_XE && ypos > MENU_H_YS && ypos < MENU_H_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); disp_help(); /* ヘルプ */ main_menu_disp(); } else if ( xpos > MENU_E_XS && xpos < MENU_E_XE && ypos > MENU_E_YS && ypos < MENU_E_YE ) { break; /* 終了 */ } } } } /* * メインメニュー表示 */ static void main_menu_disp( void ) { int iLanguage; /* 日本語/英語表示文字列切替情報取得 */ iLanguage = Lib_get_disp_language(); /* 整列キー表示 -> ( m_menu.c ) */ SUB_menu_disp4he( (char *)str_main_menu[0][iLanguage], (char *)str_main_menu[1][iLanguage], (char *)NULL, (char *)NULL ); } /* * ヘルプ表示 */ static void disp_help( void ) { Lib_chrdisp( 10, 8, "【機能\概要】       CALCCORR" ); Lib_chrdisp( 11, 10, "ライン上の正規化相関処理サンプル" ); } /***********************************************************************/ /* パラメータ設定    */ /***********************************************************************/ void para_set() { int rtn; int pad_level; pad_level = Lib_view_open(); Lib_view_set_title( pad_level, "設定" ); Lib_view_set_null( pad_level, 5, 5 , "ライン設定", 0 ); Lib_view_set_null( pad_level, 5, 35, "基準値計測", 1 ); Lib_view_set_size( pad_level, 30, 30, 5, 5 ); Lib_draw_command( pad_level ); for (;;) { if ( ERROR_RETURN != ( rtn = Lib_process_command( pad_level ) ) ) { switch( rtn ) { case 0: /* ライン設定 */ line_set( &xs, &ys, &xe, &ye ); break; case 1: /* 基準値計測 */ kijun( xs, ys, xe, ye ); break; case PAD_CANCEL: /* 「終了」をクリック? */ break; } } if ( PAD_CANCEL == rtn ) break; } Lib_erase_command( pad_level ); Lib_view_close( pad_level ); } /***********************************************************************/ /* 基準値計測      */ /***********************************************************************/ void kijun( xs, ys, xe, ye ) int xs, ys, xe, ye; /*処理ラインの始点、終点座標*/ { int idc; idc = Lib_shelter_plane( 0, 0, (Lib_get_dx_size() - 1), (Lib_get_dy_size() - 1), CHAR_PLANE ); Lib_freeze( TRANSMIT ); Lib_drawline( xs, ys, xe, ye ); get_line_level( 0, xs, ys, xe, ye, master ); /*マスター濃度の取得*/ Lib_freerun(); Lib_chrdisp( 1, 30, "基準値計測が完了しました。" ); Lib_display_keyinput( 460, 0, "確認" ); Lib_cls( ( LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); Lib_recover_plane( idc ); } /************************************************************************/ /* 実行 */ /************************************************************************/ void exec( xs, ys, xe, ye ) int xs, ys, xe, ye; /*処理ラインの始点、終点座標*/ { int size; int corr; Lib_strtclk_count(); /*タイマーカウントモードのスタート*/ Lib_freeze( TRANSMIT ); get_line_level( 0, xs, ys, xe, ye, target ); /*ターゲット濃度の取得*/ if ( ys == ye ) /*水平?*/ size = u_abs( xe - xs + 1 ); else size = u_abs( ye - ys + 1 ); corr = calc_corr( size, master, target ); /*ライン上の正規化相関値計測*/ Lib_sprintf( ss, "相関値 = %d", corr ); Lib_chrdisp( 40, 30, ss ); Lib_drawline( xs, ys, xe, ye ); Lib_time_disp( 0, 452 ); Lib_display_keyinput( 460, 0, "確認" ); Lib_cls( ( LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); Lib_freerun(); } /************************************************************************/ /* ライン濃度取得 */ /************************************************************************/ int get_line_level( mem_no, xs, ys, xe, ye, outp ) int mem_no; /*入力:メモリNO */ int xs, ys, xe, ye; /*入力:処理ラインの始点、終点座標 */ int *outp; /*出力:濃度配列格納アドレス */ { int status; int i; char *base; char *line_base; char *cp; int size; status = ERROR_RETURN; if ( NULL != ( base = (void *)Lib_adrs_gray_memory( mem_no ) ) ) { line_base = base + ys * Lib_get_dx_size() + xs; if ( ys == ye ) /*水平?*/ { size = u_abs( xe - xs + 1 ); cp = line_base; for ( i=0; i kx ) /* 右半分側にある */ { if ( wy < ky ) /* 右上側にある */ { if ( ( wx - kx ) > ( ky - wy ) ) return( 4 ); else return( 1 ); } else /* 右下側にある */ { if ( ( wx - kx ) > ( wy - ky ) ) return( 4 ); else return( 3 ); } } else /* 左半分側にある */ { if ( wy < ky ) /* 左上側にある */ { if ( ( kx - wx ) > ( ky - wy ) ) return( 2 ); else return( 1 ); } else /* 左下側にある */ { if ( ( kx - wx ) > ( wy - ky ) ) return( 2 ); else return( 3 ); } } }