[仮想の器・3次元表示 のための、断面画像を生成する], Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり

Python(パイソン) プログラム作ってみた インデックス へ

-----

2024.9.21 presented in [note] ( //note.com/runningWater/ )
2024.9.21 プログラム改変に伴う、書き直しを行った

----------
1 はじめに

これ以降に記述されている内容は、このようなコンピューター・プログラムを制作した、というような事を、ただ、述べているに過ぎない。

以下の記述を読んだ人が、それを単に参考にする、というのであれば、問題は無いと、思われる。

しかし、記述されている内容に沿って、その人が、そこに記されているのと同様の制作や作業を行った際に、その制作、作業、コンピューターの作動の結果、使用されたコンピューター等、様々な方面において、何らかの問題が発生しない、という保証は、全くない。

その制作、作業、コンピューターの作動の結果、その人や、その人が所属している組織、その人が使用した様々な機器、インフラストラクチャー等の、身の上にどのような事が起ころうとも、私は一切、責任を負わない。

このプログラムは、Python(パイソン) 言語を使って、記述されている。

----------
2 どのようなものを作ったのか

[断面画像を重ね合わせて、物体を3次元表示], Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり

のモジュール群に対して、与える、断面画像を生成する、というようなものを、作ってみた。

このモジュール群により、生成された断面画像のうちの、一部を、下記に示した。

DrawingImageData_05.png

DrawingImageData_25.png

DrawingImageData_50.png

これらのデータを、

[[断面画像を重ね合わせて、物体を3次元表示], Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり] モジュール

に対して、与え、そのモジュールを動かすと、下図のように、表示された。


Fig 1


Fig 2


----------
3 発想

[仮想の器]のイメージを生成するには、下記3個の要素があればよいのでは、と、発想した。

器の断面の画像
器の半径の推移(上下方向での)を示す曲線(を格納する画像)
器の表面の絵柄を表す画像

そこで、下記のような画像を、作成した。

----------
器の断面の画像

Fig 3

上図の中の、赤色部分が、器の断面を、表している。

----------
器の半径の推移を示す曲線(を格納する画像)

Fig 4

上図の中の、赤色部分が、器の半径の推移を示す曲線を、表している。

----------
器の表面の絵柄を表す画像

Fig 5

上図のような絵柄を、生成される器に、貼り付けていく、というようなイメージだ。

----------
3 このモジュール群の構成

以下のような、モジュールから、構成されている。

[ StartProcess ]
[ MakeImageDatas ]
[ Prepare ]
[ DetectCurveInImageData ]
[ OneObject ]

これらのモジュールは、必要に応じて、下記に解説されているモジュールを、使用している。

[画像中の、特定の色で塗りつぶされている部分の、境界部分の位置座標を、検出し、それを、テキストファイルに出力する] , Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり

[[画像処理, OpenCV2 使用] を 行う, 機能追加版, 多角形(内部ぬりつぶし)描画機能を追加] , Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり

[テキストデータ を処理する] ためのクラス, Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり

Python(パイソン) ,ソースプログラムリスト あり ,プログラム作ってみた ,[エラー処理] を 行う

----------

以降に、各モジュールの内容を、記す。

----------
4 [ StartProcess モジュール]

ファイル名 [ StartProcess.py ]

----------


import  MakeImageDatas

MODULE_NAME = "StartProcess"
FUNCTION_NAME = "start_process"

print ( "==================================" )
print ( "Module = " + MODULE_NAME
                   + " ,  function = " + FUNCTION_NAME )
print ( "process started"  )
print ( "==================================" )

MakeImageDatas.make_ImageDatas ( )

print ( "==================================" )
print ( "Module = " + MODULE_NAME
                   + " ,  function = " + FUNCTION_NAME )
print ( "process terminated"  )
print ( "==================================" )

----------

----------
5 [ MakeImageDatas モジュール]

ファイル名 [ MakeImageDatas.py ]

----------


#import  sys

import  time

import  Prepare
import  OneObject
import  ImageDataTwoDimensionHandlingV3

MODULE_NAME = "MakeImageDatas"

global_from_Z = 1
global_to_Z   = 90

global_detecting_angle_degree_incliment_for_CrossSectionalView = 0.25
global_detecting_line_length_incliment_for_CrossSectionalView = 1.0

global_center_of_Object_location_x = 0
global_center_of_Object_location_y = 0

global_ins_ImageDataTwoDimensionHandling_BasicImage = ""
global_abs_path_of_ImageData_Basic = " "
global_Part_2_of_abs_path_of_ImageData_output = " "
global_abs_path_of_ImageData_output_part_1 = " "

#=================================
def  make_ImageDatas (  ) :

    function_name = "make_ImageDatas"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "==================================" )

    id_of_Object  = 1
    list_of_path = Prepare   \
                      .make_path_list ( id_of_Object )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "passed : phase 1"  )
    print ( "==================================" )

    global  global_from_Z
    global  global_to_Z

    Prepare  \
          .make_SectionImageData_of_initial_status ( \
                      list_of_path [ 0 ]   # arg_abs_path_of_ImageData_Basic
                    , list_of_path [ 6 ]   # arg_Part_1_of_abs_path_of_ImageData_output
                    , list_of_path [ 7 ]   #arg_Part_2_of_abs_path_of_ImageData_outpu

                    , global_from_Z
                    , global_to_Z
                                                   )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "passed : phase 2"  )
    print ( "==================================" )

    ins_ImageDataTwoDimensionHandling_BasicImage = \
        ImageDataTwoDimensionHandlingV3   \
          .ImageDataTwoDimensionHandlingV3 ( MODULE_NAME , function_name )
    ins_ImageDataTwoDimensionHandling_BasicImage  \
         .load_image_data ( \
                     MODULE_NAME \
                   , function_name
                   , list_of_path [ 0 ]  # abs_path_of_ImageData_Basic
                          )
    width_of_ImageData_Basic = \
         ins_ImageDataTwoDimensionHandling_BasicImage  \
               .get_width_of_ImageData (  )
    height_of_ImageData_Basic = \
         ins_ImageDataTwoDimensionHandling_BasicImage  \
               .get_height_of_ImageData (  )

    global  global_center_of_Object_location_x
    global  global_center_of_Object_location_y
    global_center_of_Object_location_x \
              = int ( width_of_ImageData_Basic / 2.0 )
    global_center_of_Object_location_y \
              = int ( height_of_ImageData_Basic / 2.0 )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "passed : phase 3"  )
    print ( "global_center_of_Object_location_x = " ,   \
                                 global_center_of_Object_location_x )
    print ( "global_center_of_Object_location_y = " ,   \
                                 global_center_of_Object_location_y )
    print ( "==================================" )

             #------------------------------------------
    ins_OneObject = make_OneObject (  )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "start : phase 4"  )
    print ( "==================================" )

    ins_OneObject  \
               .vary_ImageData_for_all_z (
                     MODULE_NAME    # arg_requester_module
                  ,  function_name    # arg_requester_function
                                          )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "==================================" )

#=================================
def  make_OneObject (  ) :

    function_name = "make_OneObject"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "==================================" )

    global global_from_Z
    global global_to_Z
    global global_number_of_Object

    list_center_of_Object_location = [  0.0 , 0.0 ]
    id_of_Object = 1

    list_of_path = Prepare   \
                       .make_path_list ( id_of_Object )

        # time.sleep ( 5 )

    Prepare   \
         .make_TextData_contain_VariationOfRadius ( \
                               # abs_path_of_VariationOfRadius
                      list_of_path [ 3 ]
                   ,           # abs_path_of_TextData_contain_VariationOfRadius
                      list_of_path [ 4 ]
                                                 )
             #----------------------------------------------
    Prepare   \
         .make_TextData_contain_CrossSectionalView ( \
                                # abs_path_of_CrossSectionalView
                      list_of_path [ 1 ]
                   ,           # abs_path_of_TextData_contain_CrossSectionalView
                     list_of_path [ 2 ]

                   ,  global_detecting_angle_degree_incliment_for_CrossSectionalView
                   ,  global_detecting_line_length_incliment_for_CrossSectionalView
                                                      )

             #----------------------------------------------
    ins_OneObject \
            = OneObject   \
                  .OneObject (  \
                        MODULE_NAME   # arg_requester_module
                      , function_name     # arg_requester_function

                      , id_of_Object
                      , ( "Object_" + str ( id_of_Object ) )  #name of Object

                      ,  global_center_of_Object_location_x
                      ,  global_center_of_Object_location_y

                      ,  global_from_Z
                      ,  global_to_Z

                      ,  list_of_path [ 0 ]    # arg_abs_path_of_ImageData_Basic

                      ,  list_of_path [ 5 ]    # arg_abs_path_ForDrawingSurfaceImage

                      ,  list_of_path [ 6 ]    # arg_Part_1_of_abs_path_of_ImageData_output
                      ,  list_of_path [ 7 ]    # arg_Part_2_of_abs_path_of_ImageData_output

                      ,  list_of_path [ 2 ]    # arg_abs_path_of_TextData_contain_CrossSectionalImage

                      ,  list_of_path [ 4 ]    # arg_abs_path_of_TextData_contain_VariationOfRadius
                                )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "one Object has been constructed" )
    print (  "id_of_Object = " , id_of_Object )
    print ( "==================================" )

    return  ins_OneObject

    #------------------------------------------------------------
def  prepare_ImageData_BasicImage ( \
                 arg_abs_path_of_ImageData_Basic ) :

    function_name = "prepare_ImageData_BasicImage"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_abs_path_of_ImageData_Basic = " \
                + arg_abs_path_of_ImageData_Basic )
    print ( "==================================" )

    return_ins_ImageDataTwoDimensionHandling = \
             ImageDataTwoDimensionHandling  \
                 .ImageDataTwoDimensionHandling ( \
                          MODULE_NAME
                        , function_name
                                           )
    return_ins_ImageDataTwoDimensionHandling  \
           .load_image_data ( \
                          MODULE_NAME
                        , function_name
                        , arg_abs_path_of_ImageData_Basic
                         )

    width_of_BasicImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
    height_of_BasicImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "width_of_BasicImage = " , width_of_BasicImage )
    print ( "height_of_BasicImage = " , height_of_BasicImage )
    print ( "==================================" )

    return  return_ins_ImageDataTwoDimensionHandling


----------

----------
6 [ Prepare モジュール]

ファイル名 [ Prepare.py ]

----------


import  ImageDataTwoDimensionHandlingV3
import  OneObject
import  DetectCurveInImageData
import  TextFileHandling
import  MakeLocationDataFileOfCurve

MODULE_NAME = "Prepare"

global_ins_ImageDataTwoDimensionHandling_BasicImage = ""
global_abs_path_of_ImageData_Basic = " "
global_Part_2_of_abs_path_of_ImageData_output = " "
global_abs_path_of_ImageData_output_part_1 = " "

#=================================
def  make_path_list ( arg_id_of_Object ) :

    function_name = "make_path_list"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_id_of_Object = " , arg_id_of_Object )
    print ( "==================================" )

    return_list = [ " " , " " , " " , " " , " " , " "  , " " , " " ]

    path_of_Top   \
                  =   "E:ForPython/ForTest/Test_11/"

    path_of_directory_InputImageData = "InputImageData/"

    path_of_directory_OutputImageData = "OutputImageData/"

    path_of_directory_BasicImageData = "BasicImageData/"
    path_of_file_part_1_BasicImageData = "BasicImageData"

    path_of_directory_CrossSectionalView = "CrossSectionalView/"
    path_of_file_part_1_CrossSectionalView = "CrossSectionalView"

    path_of_directory_VariationOfRadius = "VariationOfRadius/"
    path_of_file_part_1_VariationOfRadius = "VariationOfRadius"

    path_of_directory_ForDrawingSurfaceImage = "ForDrawingSurfaceImage/"
    path_of_file_ForDrawingSurfaceImage = "ForDrawingSurfaceImage.png"

    path_of_directory_DrawingImageData = "DrawingImageData/"
    path_of_file_part_1_DrawingImageData = "DrawingImageData"

    path_of_directory_TextData = "TextData/"

    path_of_file_part_2_for_ImageData = ".png"
    path_of_file_part_2_for_TextData = ".txt"

    path_of_directory_for_each_Figure = "For_Figure_"

        #------ abs_path_of_ImageData_Basic ----------------
    return_list [ 0 ] = \
              path_of_Top  \
            + path_of_directory_InputImageData \
            + path_of_directory_BasicImageData  \
            + path_of_file_part_1_BasicImageData  \
            + path_of_file_part_2_for_ImageData

    print ( "return_list [ 0 ] = " + return_list [ 0 ] )

        #------ abs_path_of_CrossSectionalView ----------------
    return_list [ 1 ] = \
              path_of_Top  \
            + path_of_directory_InputImageData \
            + path_of_directory_CrossSectionalView  \
       + path_of_file_part_1_CrossSectionalView  \
       + path_of_file_part_2_for_ImageData

    print ( "return_list [ 1 ] = " + return_list [ 1 ] )

          # ----- abs_path_of_TextData_contain_CrossSectionalView ---------------
    return_list [ 2 ] =  \
         path_of_Top  \
       + path_of_directory_TextData \
       + path_of_directory_CrossSectionalView \
       + path_of_file_part_1_CrossSectionalView  \
       + path_of_file_part_2_for_TextData

    print ( "return_list [ 2 ] = " + return_list [ 2 ] )

        #------ abs_path_of_VariationOfRadius ----------------
    return_list [ 3 ] = \
               path_of_Top  \
             + path_of_directory_InputImageData \
             + path_of_directory_VariationOfRadius \
             + path_of_file_part_1_VariationOfRadius  \
             + path_of_file_part_2_for_ImageData

    print ( "return_list [ 3 ] = " + return_list [ 3 ] )

          # ----- abs_path_of_TextData_contain_VariationOfRadius ---------------
    return_list [ 4 ] =  \
         path_of_Top  \
       + path_of_directory_TextData \
       + path_of_directory_VariationOfRadius \
       + path_of_file_part_1_VariationOfRadius  \
       + path_of_file_part_2_for_TextData

    print ( "return_list [ 4 ] = " + return_list [ 4 ] )

          # ----- abs_path_of_ForDrawingSurfaceImage ---------------
    return_list [ 5 ] = \
              path_of_Top  \
            + path_of_directory_InputImageData \
            + path_of_directory_ForDrawingSurfaceImage  \
            + path_of_file_ForDrawingSurfaceImage

    print ( "return_list [ 5 ] = " + return_list [ 5 ] )

            #---- abs_path_of_ImageData_output_part_1 --------------
    return_list [ 6 ] =  \
               path_of_Top  \
             + path_of_directory_OutputImageData \
             + path_of_directory_DrawingImageData \
             + path_of_file_part_1_DrawingImageData  \
             + "_"

    print ( "return_list [ 6 ] = " + return_list [ 6 ] )

            #---- abs_path_of_ImageData_output_part_2 --------------
    return_list [ 7 ] =  \
                 path_of_file_part_2_for_ImageData

    print ( "return_list [ 7 ] = " + return_list [ 7 ] )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_id_of_Object = " , arg_id_of_Object )
    print ( "==================================" )

    return return_list

#=================================
def  make_TextData_contain_VariationOfRadius ( \
                arg_abs_path_of_ImageData
              , arg_abs_path_of_TextData
                               ) :

    function_name = "make_TextData_contain_VariationOfRadius"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_abs_path_of_ImageData = " , arg_abs_path_of_ImageData )
    print ( "arg_abs_path_of_TextData = " , arg_abs_path_of_TextData )
    print ( "==================================" )

    DetectCurveInImageData  \
        .detect_Curve_in_ImageData ( \
                arg_abs_path_of_ImageData
              , arg_abs_path_of_TextData
               )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_abs_path_of_ImageData = " , arg_abs_path_of_ImageData )
    print ( "arg_abs_path_of_TextData = " , arg_abs_path_of_TextData )
    print ( "==================================" )

#=================================
def  make_TextData_contain_CrossSectionalView ( \
                 arg_abs_path_of_ImageData
              ,  arg_abs_path_of_TextData

              ,  arg_detecting_angle_degree_incliment
              ,  arg_detecting_line_length_incliment
                                                ) :

    function_name = "make_TextData_contain_CrossSectionalView"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_abs_path_of_ImageData = " , arg_abs_path_of_ImageData )
    print ( "arg_abs_path_of_TextData = " , arg_abs_path_of_TextData )
    print ( "==================================" )

    ins_ImageDataTwoDimensionHandling = \
         ImageDataTwoDimensionHandlingV3   \
            .ImageDataTwoDimensionHandlingV3 ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
                                        )
    ins_ImageDataTwoDimensionHandling  \
         .load_image_data ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
               , arg_abs_path_of_ImageData
                      )
    width_of_ImageData = \
             ins_ImageDataTwoDimensionHandling \
                     .get_width_of_ImageData ( )
    height_of_ImageData = \
             ins_ImageDataTwoDimensionHandling \
                     .get_height_of_ImageData ( )
               #-------------------------------------
    ins_TextFileHandling   \
           = TextFileHandling   \
                  .TextFileHandling ( \
                         MODULE_NAME #  arg_requester_module
                       , function_name   # arg_requester_function
                       , arg_abs_path_of_TextData
                       , "|"     # arg_character_used_for_delimiter
                                          )
               #-------------------------------------
    list_color_value_from = [ 0 ,       0 ,    200 ]
    list_color_value_to  =  [ 50 ,     50 ,    255 ]

    MakeLocationDataFileOfCurve   \
            .detect_Curve (   \
                          ins_ImageDataTwoDimensionHandling
                       ,  arg_abs_path_of_ImageData

                       ,  ins_TextFileHandling

                                    #  arg_list_location_of_detecting_Center
                       ,  [   \
                               int ( width_of_ImageData / 2.0 )  \
                            ,  int ( height_of_ImageData / 2.0 )  \
                          ]

                       ,  arg_detecting_angle_degree_incliment
                       ,  arg_detecting_line_length_incliment
                       ,  list_color_value_from
                       ,  list_color_value_to
                           )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "==================================" )

#=================================
def  make_SectionImageData_of_initial_status ( \
            arg_abs_path_of_ImageData_Basic
          , arg_abs_path_of_ImageData_output_part_1
          , arg_abs_path_of_ImageData_output_part_2

         ,  arg_from_Z
         ,  arg_to_Z
                                         ) :

    function_name = "make_SectionImageData_of_initial_status"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_abs_path_of_ImageData_Basic = " \
              + arg_abs_path_of_ImageData_Basic )
    print ( "arg_abs_path_of_ImageData_output_part_1 = " \
              + arg_abs_path_of_ImageData_output_part_1 )
    print ( "arg_abs_path_of_ImageData_output_part_2 = " \
              + arg_abs_path_of_ImageData_output_part_2 )
    print ( "==================================" )

    ins_ImageDataTwoDimensionHandling_BasicImage = \
        ImageDataTwoDimensionHandlingV3   \
          .ImageDataTwoDimensionHandlingV3 ( MODULE_NAME , function_name )
    ins_ImageDataTwoDimensionHandling_BasicImage  \
         .load_image_data ( \
                     MODULE_NAME \
                   , function_name
                   , arg_abs_path_of_ImageData_Basic
                     )

    from_Z = arg_from_Z
    to_Z = arg_to_Z

    current_Z = from_Z
    while ( current_Z <= to_Z ) :

        make_and_write_ImageData_for_directed_Z ( \
                current_Z
              , ins_ImageDataTwoDimensionHandling_BasicImage
              , arg_abs_path_of_ImageData_output_part_1
              , arg_abs_path_of_ImageData_output_part_2
                                     )
        print ( "==================================" )
        print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
        print ( "current_Z = " , current_Z )
        print ( "to_Z = " , to_Z )
        print ( "==================================" )

        current_Z += 1

      #---------------------------------------------------
def  make_and_write_ImageData_for_directed_Z ( \
                arg_z
              , arg_ins_ImageDataTwoDimensionHandling_BasicImage
              , arg_abs_path_of_ImageData_output_part_1
              , arg_abs_path_of_ImageData_output_part_2
                ) :

    function_name = "make_and_write_ImageData_for_directed_Z"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_z = " , arg_z )
    print ( "==================================" )

    abs_path_of_write = \
            make_abs_path ( \
                arg_z
              , arg_abs_path_of_ImageData_output_part_1
              , arg_abs_path_of_ImageData_output_part_2
                           )
    arg_ins_ImageDataTwoDimensionHandling_BasicImage \
              .write_loaded_image_data_to_directed_path (
                          MODULE_NAME
                        , function_name
                        , abs_path_of_write )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "Has been written , " + abs_path_of_write )
    print ( "==================================" )

          #------------------------------------------------------------
def  make_abs_path (  \
                     arg_z
                   , arg_abs_path_of_ImageData_output_part_1
                   , arg_abs_path_of_ImageData_output_part_2
                    ) :

    function_name = "make_abs_path"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_z = " , arg_z  )
    print ( "arg_abs_path_of_ImageData_output_part_1 = " \
              , arg_abs_path_of_ImageData_output_part_1  )
    print ( "arg_abs_path_of_ImageData_output_part_2 = " \
              , arg_abs_path_of_ImageData_output_part_2  )
    print ( "==================================" )

    if ( arg_z < 10 ) :
        string_of_file_order_number = "0" + str ( arg_z )
    else :
        string_of_file_order_number = str ( arg_z )

    return_abs_path_of_ImageDataFile =    \
             arg_abs_path_of_ImageData_output_part_1  \
           + string_of_file_order_number   \
           + arg_abs_path_of_ImageData_output_part_2

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "return_abs_path_of_ImageDataFile = " \
              + return_abs_path_of_ImageDataFile )
    print ( "==================================" )

    return  return_abs_path_of_ImageDataFile

    #------------------------------------------------------------
def  prepare_ImageData_BasicImage ( \
                 arg_abs_path_of_ImageData_Basic ) :

    function_name = "prepare_ImageData_BasicImage"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_abs_path_of_ImageData_Basic = " \
                + arg_abs_path_of_ImageData_Basic )
    print ( "==================================" )

    return_ins_ImageDataTwoDimensionHandling = \
             ImageDataTwoDimensionHandling  \
                 .ImageDataTwoDimensionHandling ( \
                          MODULE_NAME
                        , function_name
                                           )
    return_ins_ImageDataTwoDimensionHandling  \
           .load_image_data ( \
                          MODULE_NAME
                        , function_name
                        , arg_abs_path_of_ImageData_Basic
                         )

    width_of_BasicImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
    height_of_BasicImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "width_of_BasicImage = " , width_of_BasicImage )
    print ( "height_of_BasicImage = " , height_of_BasicImage )
    print ( "==================================" )

    return  return_ins_ImageDataTwoDimensionHandling




----------

----------
7 [ DetectCurveInImageData モジュール]

ファイル名 [ DetectCurveInImageData.py ]

----------


#=============================
# DetectCurveInImageData
#     detect Curve in ImageData
#       , and make text file of cordinates of the Curve
#=============================

import  ImageDataTwoDimensionHandlingV3
import  TextFileHandling

MODULE_NAME = "DetectCurveInImageData"

    #------------------------------------------------------------
def detect_Curve_in_ImageData ( \
                arg_abs_path_of_ImageData
              , arg_abs_path_of_TextData
                            ) :

    function_name = "detect_Curve_in_ImageData"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " , function = " + function_name )

    print ( "arg_abs_path_of_ImageData = " \
         + arg_abs_path_of_ImageData )
    print ( "arg_abs_path_of_TextData_ = " \
         + arg_abs_path_of_TextData )
    print ( "==================================" )

    ins_ImageDataTwoDimensionHandling = \
         ImageDataTwoDimensionHandlingV3   \
            .ImageDataTwoDimensionHandlingV3 ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
                                        )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " , function = " + function_name )

    print ( "arg_abs_path_of_ImageData = " \
         + arg_abs_path_of_ImageData )
    print ( "==================================" )

    ins_ImageDataTwoDimensionHandling  \
         .load_image_data ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
               , arg_abs_path_of_ImageData
                      )
    width_of_ImageData = \
         ins_ImageDataTwoDimensionHandling \
             .get_width_of_ImageData ( )
    height_of_ImageData = \
         ins_ImageDataTwoDimensionHandling \
             .get_height_of_ImageData ( )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " , function = " + function_name )
    print ( "arg_abs_path_of_ImageData = " \
             + arg_abs_path_of_ImageData )
    print ( "width_of_ImageData = " , width_of_ImageData )
    print ( "height_of_ImageData = " , height_of_ImageData )
    print ( "==================================" )

      # --------------------------------
    ins_TextFileHandling_1 = \
         TextFileHandling   \
            .TextFileHandling ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
               , arg_abs_path_of_TextData
                         # arg_character_used_for_delimiter
               , ","
                              )
    ins_TextFileHandling_1   \
        .do_open_process_output_mode ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
                                      )
       # ---------------------------------

    result_of_detect = [ " " , 0 , 0 , 0.0 , 0.0 ]
    for get_location_y  \
              in range ( height_of_ImageData ) :

        result_of_detect = detect_for_one_y ( \
                                   get_location_y
                                ,  ins_ImageDataTwoDimensionHandling
                                ,  width_of_ImageData
                                ,  height_of_ImageData
                                    )

        ins_TextFileHandling_1   \
            .do_write_one_line_process (    \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
               , result_of_detect  # arg_list_values_for_output_one_line
                                     )

         # -------------------------------------
    ins_TextFileHandling_1   \
        .do_close_process ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
                      )

    print ( "==================================" )
    print ( "Exit from into , Module = " + MODULE_NAME
                      + " , function = " + function_name )
    print ( "==================================" )

        #------------------------------------------------
def detect_for_one_y ( arg_get_location_y  \
                     , arg_ins_ImageDataTwoDimensionHandling
                     , arg_width_of_ImageData
                     , arg_height_of_ImageData
                      ) :

    function_name = "detect_for_one_y"

      #--------------------
    return_list = [ "N" , -999 , arg_get_location_y , 0.0 , 0.0 ]

    get_location_x = 0

    process_continue = "Y"
    while ( process_continue == "Y" ) :

        if ( get_location_x >= arg_width_of_ImageData ) :
              # pixel of Curve was not found
            process_continue = "N"
            return  return_list

            #-----------------------
        color_value = \
           arg_ins_ImageDataTwoDimensionHandling \
              .get_data_of_one_pixel ( \
                    MODULE_NAME #  arg_requester_module
                  , function_name   # arg_requester_function
                              # in the commonly used mathematical XY cordinates
                  , get_location_x  # arg_x_on_ImageData_space
                  , arg_get_location_y
                                  )

        if ( ( color_value [ 2 ] > 200 )   \
             and                          \
             ( color_value [ 0 ] < 200 )   \
             and                          \
             ( color_value [ 1 ] < 200 )   \
           ) :
           # color Red , found pixel of Curve
            return_list [ 0 ] = "Y"
            return_list [ 1 ] =  get_location_x

            return_list [ 3 ] =  \
                float ( return_list [ 1 ] ) /    \
                   float ( arg_width_of_ImageData)
            return_list [ 4 ] =  \
                float ( return_list [ 2 ] ) /    \
                   float ( arg_height_of_ImageData)

            return  return_list

        get_location_x += 1

#-----------------------------



----------

----------
8 [ OneObject モジュール]

ファイル名 [ OneObject.py ]

----------


import  math

import  Prepare
import  TextFileHandling
import  ImageDataTwoDimensionHandlingV3
import  ErrorProcess

#===========================================
class OneObject :

    CV_CLASS_NAME = "OneObject"

    #------------------------------------------------------------
            # definition of constructer ( set encording to UTF-8 )

    def __init__( self
                      , arg_requester_module
                      , arg_requester_function

                      , arg_id_of_Object
                      , arg_name_of_Object

                      , arg_Center_of_Object_location_x
                      , arg_Center_of_Object_location_y

                      ,  arg_from_z
                      ,  arg_to_z

                      , arg_abs_path_of_ImageData_Basic
                      , arg_abs_path_of_ImageData_ForDrawingSurfaceImage

                      , arg_Part_1_of_abs_path_of_ImageData_output
                      , arg_Part_2_of_abs_path_of_ImageData_output

                      , arg_abs_path_of_TextData_contain_CrossSectionalImage
                      , arg_abs_path_of_TextData_contain_VariationOfRadius
                ):

        methode_name = "constructer"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "    arg_requester_module = " + arg_requester_module
                   + " , arg_requester_function = " + arg_requester_function )
        print ( "    arg_id_of_Object = " , arg_id_of_Object )
        print ( "    arg_name_of_Object = " , arg_name_of_Object )
        print ( "==================================" )

        self.iv_from_to_incliment = 0.5

        self.iv_id_of_Object = arg_id_of_Object
        self.iv_name_of_Object  = arg_name_of_Object
            #-----------------------------------

        self.iv_Center_of_Object_location_x = arg_Center_of_Object_location_x
        self.iv_Center_of_Object_location_y = arg_Center_of_Object_location_y

             #----------------------------------
        self.iv_from_z = arg_from_z
        self.iv_to_z = arg_to_z
        self.iv_length_z = self.iv_to_z - self.iv_from_z

        print ( "==================================" )
        print ( "Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "self.iv_from_z = " , self.iv_from_z )
        print ( "self.iv_to_z = " , self.iv_to_z )
        print ( "self.iv_length_z = " , self.iv_length_z )

        print ( "==================================" )

             #------------------------------
        self.iv_abs_path_of_TextData_contain_VariationOfRadius = \
              arg_abs_path_of_TextData_contain_VariationOfRadius

        print ( "self.iv_abs_path_of_TextData_contain_VariationOfRadius = "
              , self.iv_abs_path_of_TextData_contain_VariationOfRadius )

        self.iv_ins_TextFileHandling_VariationOfRadius  \
               = self.prepare_TextFileHandling_VariationOfRadius ( )

        self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = 0
        self.iv_total_number_of_information_VariationOfRadius = 0
        self.iv_readed_data_in_TextFileHandling_VariationOfRadius = ""

             # ----------------------------------
        self.iv_abs_path_of_ImageData_Basic = \
              arg_abs_path_of_ImageData_Basic

        print ( "self.iv_abs_path_of_ImageData_Basic = " \
                      + self.iv_abs_path_of_ImageData_Basic )

        self.iv_ins_ImageDataTwoDimensionHandling_BasicImage  \
               = self.prepare_ImageData_BasicImage ( \
                    # arg_abs_path_of_ImageData_Basic
                     )

             # --------------------------
        self.iv_abs_path_of_TextData_contain_CrossSectionalImage = \
              arg_abs_path_of_TextData_contain_CrossSectionalImage

        print ( "self.iv_abs_path_of_TextData_contain_CrossSectionalImage = "
              , self.iv_abs_path_of_TextData_contain_CrossSectionalImage )

        self.iv_ins_TextFileHandling_CrossSectionalImage  \
               = self.prepare_TextFileHandling_CrossSectionalImage ( )

               #-----------------------------------------
        self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage = \
               arg_abs_path_of_ImageData_ForDrawingSurfaceImage

        print ( "self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage = "
              , self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage )

        self.iv_ins_ImageData_ForDrawingSurfaceImage  \
               = self.prepare_ImageData_ForDrawingSurfaceImage (  )

              #-----------------------------------------
        self.iv_abs_path_of_ImageData_output_part_1 = \
               arg_Part_1_of_abs_path_of_ImageData_output

        print ( "self.iv_abs_path_of_ImageData_output_part_1 = "
              , self.iv_abs_path_of_ImageData_output_part_1 )

        self.iv_Part_2_of_abs_path_of_ImageData_output = \
                 arg_Part_2_of_abs_path_of_ImageData_output

        print ( "self.iv_Part_2_of_abs_path_of_ImageData_output = "
              , self.iv_Part_2_of_abs_path_of_ImageData_output )

           #=================================
        self.iv_rate_on_XYPlane = 0.0

           #=================================
        self.iv_width_of_BasicImage = 0
        self.iv_height_of_BasicImage = 0
        self.iv_location_of_Center_of_BasicImage_x = 0
        self.iv_location_of_Center_of_BasicImage_y = 0

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "    arg_requester_module = " + arg_requester_module
                   + " , arg_requester_function = " + arg_requester_function )
        print ( "==================================" )

            #------------------------------------------------------------
    def vary_ImageData_for_all_z ( self
                  ,  arg_requester_module
                  ,  arg_requester_function ) :

        methode_name = "make_ImageData_for_all_z"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "    arg_requester_module = " + arg_requester_module
                   + " , arg_requester_function = " + arg_requester_function )
        print ( "==================================" )

        self.prepare_TextFileHandling_VariationOfRadius ( )
        self.prepare_ImageData_BasicImage ( )

        current_z = self.iv_from_z
        while ( current_z <= self.iv_to_z ) :

            z_rate = float ( current_z ) / float ( self.iv_length_z )
            self.prepare_for_directed_z ( current_z ,  z_rate )

            self.make_and_write_ImageData_for_directed_z ( \
                                    current_z
                                                 )

            print ( "==================================" )
            print ( "Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
            print ( "current_z = " , current_z )
            print ( "self.iv_to_z = " , self.iv_to_z )
            print ( "z_rate = " , z_rate )
            print ( "==================================" )

            current_z += 1

    #------------------------------------------------------------
    def  prepare_TextFileHandling_VariationOfRadius ( self ) :

        methode_name = "prepare_TextFileHandling_VariationOfRadius"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

          #----------------------------------------
        self.iv_ins_TextFileHandling_VariationOfRadius = \
             TextFileHandling   \
                   .TextFileHandling (  \
                          OneObject.CV_CLASS_NAME     # arg_requester_module
                        , methode_name  #arg_requester_function
                        , self.iv_abs_path_of_TextData_contain_VariationOfRadius
                        , ","     # arg_character_used_for_delimiter
                                        )
                # ---- get total number of information in TextFile -----
                    # ---- open Text File -------
        self.iv_ins_TextFileHandling_VariationOfRadius   \
                .do_open_process_input_mode (
                       OneObject.CV_CLASS_NAME     # arg_requester_module
                     , methode_name                      #arg_requester_function
                      )
                    # ---- read all datas in Text File -------
        self.iv_total_number_of_information_VariationOfRadius = 0

        process_continue = "Y"
        while ( process_continue == "Y" ) :
            result_of_reading = \
                 self.iv_ins_TextFileHandling_VariationOfRadius   \
                        .do_read_one_line_process (
                                 OneObject.CV_CLASS_NAME     # arg_requester_module
                                , methode_name                      #arg_requester_function
                                                               )
            if ( result_of_reading [ 0 ] == "E" ) :
                           #reached to file end
                process_continue = "N"
                break

            self.iv_total_number_of_information_VariationOfRadius += 1

        print ( "-----------------------------------------" )
        print ( "Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "self.iv_total_number_of_information_VariationOfRadius = " \
                  , self.iv_total_number_of_information_VariationOfRadius )
        print ( "-----------------------------------------" )

                    # ---- close Text File -------
        self.iv_ins_TextFileHandling_VariationOfRadius   \
                       .do_close_process ( \
                             OneObject.CV_CLASS_NAME     # arg_requester_module
                           , methode_name                      #arg_requester_function
                                                             )
                      # ---- re open Text File -------
        self.iv_ins_TextFileHandling_VariationOfRadius  \
                .do_open_process_input_mode ( \
                       OneObject.CV_CLASS_NAME     # arg_requester_module
                     , methode_name       #arg_requester_function
                                       )

        self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = 0

                    # --- read first data
        self.iv_readed_data_in_TextFileHandling_VariationOfRadius \
           = self.iv_ins_TextFileHandling_VariationOfRadius   \
                     .do_read_one_line_process (\
                         OneObject.CV_CLASS_NAME     # arg_requester_module
                       , methode_name                      #arg_requester_function
                       )
        self.iv_readed_counter_for_TextFileHandling_VariationOfRadius += 1

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "self.iv_total_number_of_information_VariationOfRadius = " \
                   , self.iv_total_number_of_information_VariationOfRadius )
        print ( "self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = " \
                   , self.iv_readed_counter_for_TextFileHandling_VariationOfRadius )
        print ( "==================================" )

    #------------------------------------------------------------
    def  prepare_ImageData_BasicImage ( self ) :

        methode_name = "prepare_ImageData_BasicImage"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        return_ins_ImageDataTwoDimensionHandling = \
             ImageDataTwoDimensionHandlingV3  \
                 .ImageDataTwoDimensionHandlingV3 ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                                           )
        return_ins_ImageDataTwoDimensionHandling  \
           .load_image_data ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                        , self.iv_abs_path_of_ImageData_Basic
                         )

        self.iv_width_of_BasicImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
        self.iv_height_of_BasicImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )

        self.iv_location_of_Center_of_BasicImage_x = \
                self.iv_width_of_BasicImage / 2
        self.iv_location_of_Center_of_BasicImage_y = \
                self.iv_height_of_BasicImage / 2

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "width = " \
            , return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
             )
        print ( "height = " \
            , return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )
             )
        print ( "==================================" )

        return  return_ins_ImageDataTwoDimensionHandling

        #------------------------------------------------------------
    def  prepare_TextFileHandling_CrossSectionalImage ( self ) :

        methode_name = "prepare_TextFileHandling_CrossSectionalImage"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        self.iv_ins_TextFileHandling_CrossSectionalImage = \
             TextFileHandling   \
                   .TextFileHandling (  \
                          OneObject.CV_CLASS_NAME     # arg_requester_module
                        , methode_name  #arg_requester_function
                        , self.iv_abs_path_of_TextData_contain_CrossSectionalImage
                        , "|"     # arg_character_used_for_delimiter
                                        )

                    # ---- open Text File -------
        self.iv_ins_TextFileHandling_CrossSectionalImage   \
                .do_open_process_input_mode (
                       OneObject.CV_CLASS_NAME     # arg_requester_module
                     , methode_name                      #arg_requester_function
                      )
                    # ---- read to part of data -------
        process_continue = "Y"
        read_counter = 0
        while ( process_continue == "Y" ) :
            result_of_reading = \
                 self.iv_ins_TextFileHandling_CrossSectionalImage   \
                        .do_read_one_line_process (
                                 OneObject.CV_CLASS_NAME     # arg_requester_module
                                , methode_name                      #arg_requester_function
                                                               )
            read_counter += 1

             #************************************
            if ( read_counter == 8 ) :
                           #reached to part of data
             #************************************
                process_continue = "N"
                break

          #------------------------------------------
        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "self.iv_total_number_of_information_VariationOfRadius = " \
                   , self.iv_total_number_of_information_VariationOfRadius )
        print ( "self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = " \
                   , self.iv_readed_counter_for_TextFileHandling_VariationOfRadius )
        print ( "==================================" )

    #------------------------------------------------------------
    def  prepare_ImageData_ForDrawingSurfaceImage ( self ) :

        methode_name = "prepare_ImageData_ForDrawingSurfaceImage"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        return_ins_ImageDataTwoDimensionHandling = \
             ImageDataTwoDimensionHandlingV3  \
                 .ImageDataTwoDimensionHandlingV3 ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                                           )
        print ( "==================================" )
        print ( "Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        print ( "self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage = " \
          + self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage )

        return_ins_ImageDataTwoDimensionHandling  \
           .load_image_data ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                        , self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage
                         )

        self.iv_width_of_ImageData_ForDrawingSurfaceImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
        self.iv_height_of_ImageData_ForDrawingSurfaceImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "width = " \
            , return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
             )
        print ( "height = " \
            , return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )
             )
        print ( "==================================" )

        return  return_ins_ImageDataTwoDimensionHandling

        #---------------------------------------------------
    def  prepare_for_directed_z ( self , arg_z , arg_z_rate ) :

        methode_name = "prepare_for_directed_z"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "arg_z_rate = " ,  arg_z_rate )
        print ( "==================================" )

        result_list = \
                self.get_information_of_VariationOfRadius (  arg_z_rate , arg_z_rate )
        self.iv_exist_information_of_VariationOfRadius = result_list [ 1 ]
        self.iv_rate_on_XYPlane = float ( result_list [ 2 ] )

        #------------------------------------------------------
        self.prepare_TextFileHandling_CrossSectionalImage ( )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "result_list = " , result_list )
        print ( "self.iv_exist_information_of_VariationOfRadius = " \
                , self.iv_exist_information_of_VariationOfRadius )
        print ( "self.iv_rate_on_XYPlane = " \
                , self.iv_rate_on_XYPlane )
        print ( "==================================" )

        #---------------------------------------------------
    def  get_information_of_VariationOfRadius ( self  \
                                          ,  arg_z , arg_z_rate ) :

        methode_name = "get_information_of_VariationOfRadius"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        return_list = [ "N" , "N" , 0.0 ]

        current_rate_for_z = \
            float ( self.iv_readed_counter_for_TextFileHandling_VariationOfRadius ) \
              / float ( self.iv_total_number_of_information_VariationOfRadius )

        if ( current_rate_for_z > arg_z_rate ) : \
                      #process error
            print ( "==================================" )
            print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
            print ( "!!!!! process error , [ current_rate_for_z > arg_z_rate ]" )
            print ( "current_rate_for_z = " , current_rate_for_z )
            print ( "arg_z_rate = " ,  arg_z_rate )
            print ( "self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = " \
                  ,  self.iv_readed_counter_for_TextFileHandling_VariationOfRadius )
            print ( "self.iv_total_number_of_information_VariationOfRadius = " \
                   ,  self.iv_total_number_of_information_VariationOfRadius )
            print ( "==================================" )

            return return_list
              #--------------------------------
        process_continue = "Y"
        while ( process_continue == "Y" ) :

            current_rate_for_z = \
                  float ( self.iv_readed_counter_for_TextFileHandling_VariationOfRadius ) \
                    / float ( self.iv_total_number_of_information_VariationOfRadius )

            #print ( "==================================" )
            #print ( "Class = " + OneObject.CV_CLASS_NAME
            #                  + " , methode = " + methode_name )

            #print ( "self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = " \
            #          ,  self.iv_readed_counter_for_TextFileHandling_VariationOfRadius )
            #print ( "self.iv_total_number_of_information_VariationOfRadius = " \
            #          ,  self.iv_total_number_of_information_VariationOfRadius )
            #print ( "current_rate_for_z = " \
            #          ,  current_rate_for_z )
            #print ( "arg_z_rate = " \
            #          ,  arg_z_rate )
            #print ( "==================================" )

                  #--------------------------------
            if ( current_rate_for_z >= arg_z_rate ) :
                if ( self.iv_readed_data_in_TextFileHandling_VariationOfRadius [ 0 ] \
                         == "E" ) :
                                             #process error
                    print ( "==================================" )
                    print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
                    print ( "!!!!! process error , reached end" )
                    print ( "current_rate_for_z = " , current_rate_for_z )
                    print ( "arg_z_rate = " ,  arg_z_rate )
                    print ( "self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = " \
                      ,  self.iv_readed_counter_for_TextFileHandling_VariationOfRadius )
                    print ( "self.iv_total_number_of_information_VariationOfRadius = " \
                      ,  self.iv_total_number_of_information_VariationOfRadius )
                    print ( "==================================" )

                    return return_list

                process_continue = "Y"

                return_list [ 0 ] = "Y"
                return_list [ 1 ] =  \
                   self.iv_readed_data_in_TextFileHandling_VariationOfRadius [ 1 ]
                return_list [ 2 ] = \
                   self.iv_readed_data_in_TextFileHandling_VariationOfRadius [ 4 ]

                   #*****************************
                   # OK return
                   #*****************************

                print ( "==================================" )
                print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
                print ( "OK return" )
                print ( "return_list = " , return_list )
                print ( "self.iv_readed_data_in_TextFileHandling_VariationOfRadius = " \
                      , self.iv_readed_data_in_TextFileHandling_VariationOfRadius )
                print ( "==================================" )

                return return_list

                                      # --- read next data
            self.iv_readed_data_in_TextFileHandling_VariationOfRadius \
               = self.iv_ins_TextFileHandling_VariationOfRadius   \
                     .do_read_one_line_process ( \
                         OneObject.CV_CLASS_NAME     # arg_requester_module
                       , methode_name                      #arg_requester_function
                                                 )
            self.iv_readed_counter_for_TextFileHandling_VariationOfRadius += 1

          #---------------------------------------------------
    def  make_and_write_ImageData_for_directed_z ( self  \
                                        , arg_z
                                                 ) :

        methode_name = "make_and_write_ImageData_for_directed_z"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "arg_z = " , arg_z )
        # print ( "arg_z_rate = " , arg_z_rate )
        print ( "==================================" )

        abs_path_of_write = \
            self.make_abs_path ( arg_z )

        ins_ImageDataTwoDimensionHandling_Target = \
              ImageDataTwoDimensionHandlingV3        \
                  .ImageDataTwoDimensionHandlingV3 ( \
                       OneObject.CV_CLASS_NAME
                     , methode_name
                      )
        ins_ImageDataTwoDimensionHandling_Target \
              .load_image_data ( \
                       OneObject.CV_CLASS_NAME
                     , methode_name
                     , abs_path_of_write
                                 )
            # overwrite on above loaded image data
            # ------------ draw each locations ------------

                #------ read first data
        result_of_reading_current = \
                 self.iv_ins_TextFileHandling_CrossSectionalImage   \
                        .do_read_one_line_process (
                                 OneObject.CV_CLASS_NAME     # arg_requester_module
                                , methode_name                      #arg_requester_function
                                                               )
                # -----------------------------------------
        process_continue = "Y"
        while ( process_continue == "Y" ) :
            result_of_reading_next = \
                 self.iv_ins_TextFileHandling_CrossSectionalImage   \
                        .do_read_one_line_process (
                                 OneObject.CV_CLASS_NAME     # arg_requester_module
                                , methode_name                      #arg_requester_function
                                                               )

            # print ( "==================================" )
            # print ( "Class = " + OneObject.CV_CLASS_NAME    \
            #           + " , methode = " + methode_name )
            # print ( "result_of_reading = " )
            # print ( result_of_reading )
            # print ( "==================================" )

            if ( result_of_reading_next [ 0 ] == "E" ) :
                           #reached to file end
                process_continue = "N"
                break

            self.draw_one_line_on_ImageData ( \
                           arg_z
                        ,  result_of_reading_current
                        ,  result_of_reading_next
                        ,  ins_ImageDataTwoDimensionHandling_Target
                        ,  self.iv_rate_on_XYPlane
                                          )

            result_of_reading_current = result_of_reading_next

             # ------------ write data ------------
        ins_ImageDataTwoDimensionHandling_Target \
              .write_loaded_image_data_to_directed_path (
                          OneObject.CV_CLASS_NAME
                        , methode_name
                        , abs_path_of_write )

        self.iv_ins_TextFileHandling_CrossSectionalImage   \
                .do_close_process (
                       OneObject.CV_CLASS_NAME     # arg_requester_module
                     , methode_name                      #arg_requester_function
                      )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "Has been written , " + abs_path_of_write )
        print ( "==================================" )

#---------------------------------------------------------
    def   draw_one_line_on_ImageData ( self \
                                 ,  arg_value_z
                                 ,  arg_result_of_reading_current
                                 ,  arg_result_of_reading_next
                                 ,  arg_ins_ImageDataTwoDimensionHandling_Target
                                 ,  arg_rate_on_XYPlane
                                       ) :

        methode_name = "draw_one_line_on_ImageData"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                     + " , methode = " + methode_name )
        print ( "arg_value_z = " , arg_value_z )
        print ( "arg_rate_on_XYPlane = " , arg_rate_on_XYPlane )
        print ( "==================================" )

                      #--------------------------------------
        angle_degree =  float ( arg_result_of_reading_current [ 2 ] )

        color_list = \
                self.decide_drawing_color ( \
                            angle_degree
                          , arg_value_z
                                          )
            #------------------------------------------
        if ( ( color_list [ 0 ] == "O" )  #Over Area
              or
             ( color_list [ 0 ] == "W" )  #Color = White ( not draw )
          ) :
               # do not draw at this point
            return "N"
                #------------------------------------------

        list_cordinates_of_vertex \
              = self.decide_cordinates_of_vertex (   \
                             arg_result_of_reading_current
                           , arg_result_of_reading_next
                           , arg_rate_on_XYPlane
                                                 )
        arg_ins_ImageDataTwoDimensionHandling_Target   \
               .insert_polygon_filled_into_ImageData (    \
                        OneObject.CV_CLASS_NAME
                       , methode_name  # arg_requester_function
                              # in the commonly used mathematical XY cordinates
                   , list_cordinates_of_vertex

                   , color_list [ 1 ]     # arg_font_color_Blue
                   , color_list [ 2 ]     # arg_font_color_Green
                   , color_list [ 3 ]     # arg_font_color_Red
                                                    )

#----------------------------------------------------------------
    def  decide_cordinates_of_vertex (   self  \
                            ,  arg_result_of_reading_current
                            ,  arg_result_of_reading_next
                            ,  arg_rate_on_XYPlane
                                      ) :

        methode_name = "decide_cordinates_of_vertex"

        current_from_x = float ( arg_result_of_reading_current   [ 8 ] ) \
                                           *  arg_rate_on_XYPlane
        current_from_y = float ( arg_result_of_reading_current  [ 9 ] ) \
                                           *  arg_rate_on_XYPlane
        current_to_x = float ( arg_result_of_reading_current   [ 12 ] ) \
                                           *  arg_rate_on_XYPlane
        current_to_y = float ( arg_result_of_reading_current  [ 13 ] ) \
                                           *  arg_rate_on_XYPlane

        current_from_value_x = int ( self.iv_location_of_Center_of_BasicImage_x  \
                                                               + current_from_x )
        current_from_value_y = int ( self.iv_location_of_Center_of_BasicImage_y \
                                                              + current_from_y )
        current_to_value_x = int ( self.iv_location_of_Center_of_BasicImage_x  \
                                                              + current_to_x )
        current_to_value_y = int ( self.iv_location_of_Center_of_BasicImage_y \
                                                              + current_to_y )
              #----------------------------
        next_from_x = float ( arg_result_of_reading_next   [ 8 ] ) \
                                         *  arg_rate_on_XYPlane
        next_from_y = float ( arg_result_of_reading_next  [ 9 ] )  \
                                         *  arg_rate_on_XYPlane
        next_to_x = float ( arg_result_of_reading_next   [ 12 ] )  \
                                         *  arg_rate_on_XYPlane
        next_to_y = float ( arg_result_of_reading_next  [ 13 ] )  \
                                         *  arg_rate_on_XYPlane

        next_from_value_x = int ( self.iv_location_of_Center_of_BasicImage_x  \
                                                      + next_from_x )
        next_from_value_y = int ( self.iv_location_of_Center_of_BasicImage_y \
                                                      + next_from_y )
        next_to_value_x = int ( self.iv_location_of_Center_of_BasicImage_x  \
                                                      + next_to_x )
        next_to_value_y = int ( self.iv_location_of_Center_of_BasicImage_y \
                                                      + next_to_y )

        list_return = [ ]
        list_return.append (  [ current_from_value_x , current_from_value_y ] )
        list_return.append (  [ current_to_value_x , current_to_value_y ] )
        list_return.append (  [ next_to_value_x , next_to_value_y ] )
        list_return.append (  [ next_from_value_x , next_from_value_y ] )

        return list_return

#--------------------------------------------------------------

    def  make_abs_path ( self \
                             , arg_z ) :

        if ( arg_z < 10 ) :
            string_of_file_order_number = "0" + str ( arg_z )
        else :
            string_of_file_order_number = str ( arg_z )

        abs_path_of_ImageDataFile =    \
             self.iv_abs_path_of_ImageData_output_part_1  \
           + string_of_file_order_number   \
           + self.iv_Part_2_of_abs_path_of_ImageData_output  \

        return  abs_path_of_ImageDataFile

          #---------------------------------------------------
    def  decide_drawing_color ( self \
                              ,  arg_angle_degree
                              ,  arg_value_z
                               ) :

        methode_name = "decide_drawing_color"

        #print ( "==================================" )
        #print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
        #              + " , methode = " + methode_name )
        #print ( "==================================" )

        return_list  = [ "Y" , 0 , 0 , 0 ]

        if ( arg_angle_degree < 180 ) :
            w_angle_location_rate_in_0_180 = float ( arg_angle_degree ) / 180.0
        else :
            w_1 = arg_angle_degree - 180.0
            w_2 = float ( w_1 ) / 180.0
            w_angle_location_rate_in_0_180 = 1.0 - w_2

        w_x = self.iv_width_of_ImageData_ForDrawingSurfaceImage \
                                *  ( w_angle_location_rate_in_0_180 )
        w_x_int = int ( w_x )
        get_x = w_x_int
        if ( w_x_int < 0 ) :
            get_x = 0
        if ( w_x_int >= self.iv_width_of_ImageData_ForDrawingSurfaceImage ) :
            get_x = self.iv_width_of_ImageData_ForDrawingSurfaceImage - 1
                  #-------------------------------------
        z_rate =  float ( arg_value_z ) / float ( self.iv_length_z )
        w_y = self.iv_height_of_ImageData_ForDrawingSurfaceImage  \
                              * z_rate
        w_y_int = int ( w_y )
        get_y = w_y_int
        if ( w_y_int < 0 ) :
            get_y = 0
        if ( w_y_int >= self.iv_height_of_ImageData_ForDrawingSurfaceImage ) :
            get_y = self.iv_height_of_ImageData_ForDrawingSurfaceImage - 1
                                          #-------------------------------------
        color_data_1 = \
              self.iv_ins_ImageData_ForDrawingSurfaceImage  \
                    .get_data_of_one_pixel ( \
                           OneObject.CV_CLASS_NAME
                         , methode_name
                         , get_x
                         , get_y
                               )
              #-----------------------------------
        if ( ( color_data_1 [ 0 ] > 250 )  \
              and \
             ( color_data_1 [ 1 ] > 250 )  \
              and \
             ( color_data_1 [ 2 ] > 250 )  \
            ) :
                 # White color is set , at this location
                 #   not draw this location
            return_list [ 0 ] = "W"
            return return_list
              #-----------------------------------
        return_list [ 1 ] = int ( color_data_1 [ 0 ] )
        return_list [ 2 ] = int ( color_data_1 [ 1 ] )
        return_list [ 3 ] = int ( color_data_1 [ 2 ] )

                 # normaly color was gotten
        return_list [ 0 ] = "Y"
        return return_list



----------

Python(パイソン) プログラム作ってみた インデックス へ

この記事が気に入ったらサポートをしてみませんか?