[[花、ハナ、はな] の画像を、作る] , Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり
Python(パイソン) プログラム作ってみた インデックス へ
-----
2024.10.25 presented in [note] ( //note.com/runningWater/ )
2024.10.30 rewritten
----------
1 はじめに
これ以降に記述されている内容は、このようなコンピューター・プログラムを制作した、というような事を、ただ、述べているに過ぎない。
以下の記述を読んだ人が、それを単に参考にする、というのであれば、問題は無いと、思われる。
しかし、記述されている内容に沿って、その人が、そこに記されているのと同様の制作や作業を行った際に、その制作、作業、コンピューターの作動の結果、使用されたコンピューター等、様々な方面において、何らかの問題が発生しない、という保証は、全くない。
その制作、作業、コンピューターの作動の結果、その人や、その人が所属している組織、その人が使用した様々な機器、インフラストラクチャー等の、身の上にどのような事が起ころうとも、私は一切、責任を負わない。
このプログラムは、Python(パイソン) 言語を使って、記述されている。
----------
2 どのようなものを作ったのか
下記 [Fig 1] にあるように、
[Fig 1]上部にある画像から、
[Fig 1]下部にある1個の画像を、作成した。
この作成は、以下のようにして、行われた。
-----
第1段階(make_Source_ImageData_of_Petal)
下記 [Fig 2] にあるように、
[Fig 2]上部にある画像から、
[Fig 2]下部にある、様々な色あいを持つ画像が、作成された。これらの画像は、次の段階で、[花イメージ画像]を、作成するために、使用される。
-----
第2段階
下記 [Fig 3] にあるように、
第1段階で作成された、画像を、
[花弁の外側部分] を作成するための画像
[花弁の内側部分] を作成するための画像
として、使用し、
それらと、
[花弁] を形成するための、パターン画像を使って、
[花弁イメージ画像]を作成し
それを、指定回数だけ、回転させながら、重ね合わせて、
[花イメージ画像]
の画像を、作り、
それらの、[花イメージ画像]を
[ベース画像]
の上に、
規則的に、順にコピーしていった(回転させながら)
そのようにして、[Fig 3]下部にある画像が、作成された。
----------
3 構成
このモジュール群は、下記のモジュールより、構成されている。
[ MakeFlowerImages ]
[ MakeOneFlowerImage ]
[ TestMakeFlowerImages ]
以降に、これらのモジュールの内容を、記す。
これらのモジュールは、必要に応じて、下記に解説されているモジュールを、使用している。
[画像を、別の画像に、重ね塗りする・機能強化 版] , Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり
[画像の色調を変える, 各色チャンネルごとにガンマ変換を使って], Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり
[[画像処理, OpenCV2 使用] を 行う, 機能追加版, 多角形(内部ぬりつぶし)描画機能を追加] , Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり
Python(パイソン) ,ソースプログラムリスト あり ,プログラム作ってみた ,[エラー処理] を 行う
----------
4 [ MakeFlowerImages ]
ファイル名 [ MakeFlowerImages.py ]
----------
import ImageDataTwoDimensionHandlingV3
import VaryColorByGamma
import CopyAndInsertImageDataV3
import MakeOneFlowerImage
global_module_name = "MakeFlowerImages"
global_number_of_rows = 8
global_number_of_columns = 12
#------ about Source ImageData of Petal
#for OuterPetal , number = 5 , for InnerPetal , number = 5
global_number_of_Source_ImageData_of_Petal = 5
global_list_Gamma_values_for_Source_ImageData_for_Outer = \
[ [ 2.0 , 0.5 , 0.5 ] , [ 0.5 , 2.0 , 0.5 ] \
, [ 0.5 , 0.5 , 2.0 ] , [ 0.5 , 2.0 , 2.0 ] , [ 2.0 , 0.5 , 2.0 ] ]
global_list_Gamma_values_for_Source_ImageData_for_Inner = \
[ [ 0.5 , 0.2 , 0.2 ] , [ 0.2 , 0.5 , 0.2 ] \
, [ 0.2 , 0.2 , 0.5 ] , [ 0.5 , 0.5 , 0.2 ] , [ 0.2 , 0.5 , 0.5 ] ]
#------ about Pattern ImageData of one Flower
global_list_Pattern = [ "Pattern_1.png" , "Pattern_2.png" , "Pattern_3.png" ]
#-------- about using information, at each row and column ---------------------
global_list_setting_number_of_petals = [ \
[ 5 , 6 , 8 , 4 , 5 , 5 , 6 , 8 , 4 , 5 , 5 , 6 ] \
, [ 5 , 6 , 8 , 4 , 5 , 5 , 6 , 8 , 4 , 5 , 5 , 6 ] \
, [ 5 , 6 , 8 , 4 , 5 , 5 , 6 , 8 , 4 , 5 , 5 , 6 ] \
, [ 5 , 6 , 8 , 4 , 5 , 5 , 6 , 8 , 4 , 5 , 5 , 6 ] \
, [ 5 , 6 , 8 , 4 , 5 , 5 , 6 , 8 , 4 , 5 , 5 , 6 ] \
, [ 5 , 6 , 8 , 4 , 5 , 5 , 6 , 8 , 4 , 5 , 5 , 6 ] \
, [ 5 , 6 , 8 , 4 , 5 , 5 , 6 , 8 , 4 , 5 , 5 , 6 ] \
, [ 5 , 6 , 8 , 4 , 5 , 5 , 6 , 8 , 4 , 5 , 5 , 6 ] \
]
global_list_use_Pattern = [ \
[ 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 ] \
, [ 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 ] \
, [ 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 ] \
, [ 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 ] \
, [ 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 ] \
, [ 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 ] \
, [ 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 ] \
, [ 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 ] \
]
global_list_use_Petal_Source_Image = [ \
[ 1 , 2 , 3 , 4 , 5 , 1 , 2 , 3 , 4 , 5 , 1 , 2 ] \
, [ 5 , 4 , 3 , 2 , 1 , 5 , 4 , 3 , 2 , 1 , 1 , 2 ] \
, [ 1 , 2 , 3 , 4 , 5 , 1 , 2 , 3 , 4 , 5 , 1 , 2 ] \
, [ 5 , 4 , 3 , 2 , 1 , 5 , 4 , 3 , 2 , 1 , 1 , 2 ] \
, [ 1 , 2 , 3 , 4 , 5 , 1 , 2 , 3 , 4 , 5 , 1 , 2 ] \
, [ 5 , 4 , 3 , 2 , 1 , 5 , 4 , 3 , 2 , 1 , 1 , 2 ] \
, [ 1 , 2 , 3 , 4 , 5 , 1 , 2 , 3 , 4 , 5 , 1 , 2 ] \
, [ 5 , 4 , 3 , 2 , 1 , 5 , 4 , 3 , 2 , 1 , 1 , 2 ] \
]
global_list_set_angle_degree = [ \
[ 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 ] \
, [ 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 ] \
, [ 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 ] \
, [ 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 ] \
, [ 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 ] \
, [ 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 ] \
, [ 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 ] \
, [ 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 , 0 , 90 , 180 , 270 ] \
]
#-------- about location for making one Flower Image ---------------------
global_list_location_xy_on_Pattern_for_Outer_Petal = [ 100 , 85 ]
global_list_location_xy_on_Pattern_for_Inner_Petal = [ 15 , 85 ]
global_scale_rate_CopySource_to_InsertedSide = 0.4
global_color_rate_CopySource_to_InsertedSide = 1.0
global_list_BasicLocation_x_and_y_on_CopySource_ImageData = [ 10 , 85 ]
global_list_BasicLocation_x_and_y_on_Pattern_ImageData = [ 10 , 85 ]
global_distance_of_petal_base_from_Center = 5
#-------- about file ---------------------
global_abs_path_of_directory_Top ="E:/ForPython/ForTest/Test_F/"
global_path_of_directory_Input = "Input/"
global_path_of_directory_Output = "Output/"
global_path_of_directory_BaseImage = "BaseImage/"
global_path_of_directory_Pattern = "Pattern/"
global_path_of_directory_Petal_Source_Image = "PetalSourceImage/"
#======================================
def main_process ( ) :
function_name = "main_process"
global global_module_name
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
make_Source_ImageData_of_Petal ( )
abs_path_of_BaseImage \
= global_abs_path_of_directory_Top \
+ global_path_of_directory_Input \
+ global_path_of_directory_BaseImage \
+ "BaseImage_2400_1600.png"
#----------------------
ins_CopyAndInsertImageDataV3 = \
CopyAndInsertImageDataV3 \
.CopyAndInsertImageDataV3 ( )
#------------------
ins_CopyAndInsertImageDataV3 \
.construct_ImageData ( 0 )
#------------------
ins_CopyAndInsertImageDataV3 \
.construct_ImageData ( 2 )
ins_CopyAndInsertImageDataV3 \
.load_ImageData ( 2 , abs_path_of_BaseImage )
#------------------
ins_CopyAndInsertImageDataV3 \
.construct_ImageData ( 3 )
ins_CopyAndInsertImageDataV3 \
.load_ImageData ( 3 , abs_path_of_BaseImage )
#---------------------------------------------
for row in range ( 1 , ( global_number_of_rows + 1 ) ) :
for column in range ( 1 , ( global_number_of_columns + 1 ) ) :
ins_CopyAndInsertImageDataV3_result = \
do_drawing_for_one_location ( \
row
, column
, ins_CopyAndInsertImageDataV3
)
#---------------------------------------------------
ins_CopyAndInsertImageDataV3_result \
.write_InsertedSide_Generated_ImageData ( \
"E:/ForPython/ForTest/Test_F/Output/Output.png" )
print ( "==================================" )
print ( "Exit from , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
#============================================
def do_drawing_for_one_location ( \
arg_row
, arg_column
, arg_ins_CopyAndInsertImageDataV3
) :
function_name = "do_drawing_for_one_location"
global global_module_name
print ( "==================================" )
print ( "Module = " + global_module_name
+ " , function = " + function_name )
print ( "arg_row = " , arg_row , " , arg_column = " , arg_column )
print ( "==================================" )
#------------------------------------
ins_ImageDataTwoDimensionHandling_one_Flower \
= make_ImageData_one_Flower ( arg_row , arg_column )
width_of_ImageData_one_Flower = \
ins_ImageDataTwoDimensionHandling_one_Flower \
.get_width_of_ImageData ( )
height_of_ImageData_one_Flower = \
ins_ImageDataTwoDimensionHandling_one_Flower \
.get_height_of_ImageData ( )
#------------------------------------
list_color_copying = [ [ 0 , 0 , 0 ] , [ 253 , 253 , 253 ] ]
list_CopySource_From_and_To_xy = \
[ [ 0 , 0 ] , \
[ ( width_of_ImageData_one_Flower - 1 ) \
, \
( height_of_ImageData_one_Flower - 1 ) \
] \
]
scale_rate_CopySource_to_InsertedSide = 1.0
color_rate_CopySource_to_InsertedSide = 1.0
w1 = int ( width_of_ImageData_one_Flower / 2 )
w2 = int ( height_of_ImageData_one_Flower / 2 )
list_BasicLocation_x_and_y_on_CopySource_ImageData = [ w1 , w2 ]
list_BasicLocation_x_and_y_on_Pattern_ImageData = [ w1 , w2 ]
list_BasicLocation_x_and_y_on_InsertedSide_ImageData = [ \
( 200 * ( arg_column - 1 ) ) + 100 \
, \
( 200 * ( global_number_of_rows - arg_row ) ) + 100 \
]
#-----------------------------------------------------
arg_ins_CopyAndInsertImageDataV3 \
.set_ImageData ( 0 , ins_ImageDataTwoDimensionHandling_one_Flower )
#------------------------------------------------------
arg_ins_CopyAndInsertImageDataV3 \
.copy_and_insert_ImageData ( \
"N" #arg_use_or_not_PatternImageData
, [ 0 , 0 ] #not used, arg_list_directed_x_and_y_on_PatternImageData
, list_color_copying
, list_CopySource_From_and_To_xy
, scale_rate_CopySource_to_InsertedSide
, color_rate_CopySource_to_InsertedSide
, list_BasicLocation_x_and_y_on_CopySource_ImageData
, list_BasicLocation_x_and_y_on_Pattern_ImageData
, list_BasicLocation_x_and_y_on_InsertedSide_ImageData
, "Y" # arg_do_rotation
#arg_rotation_degree_of_inserting_on_InsertedSide_Source
, global_list_set_angle_degree \
[ arg_row - 1 ] [ arg_column - 1 ]
)
return arg_ins_CopyAndInsertImageDataV3
#======================================
def make_Source_ImageData_of_Petal ( ) :
function_name = "make_Source_ImageData_of_Petal"
global global_module_name
global global_number_of_Source_ImageData_of_Petal
global global_list_Source_ImageData_for_Outer_Gamma
global global_list_Source_ImageData_for_Inner_Gamma
global global_abs_path_of_directory_Top
global global_path_of_directory_Input
global global_path_of_directory_Output
global global_path_of_directory_Petal_Source_Image
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
abs_path_of_Petal_Source_Image \
= global_abs_path_of_directory_Top \
+ global_path_of_directory_Input \
+ global_path_of_directory_Petal_Source_Image \
+ "SourceImage_200_170.png"
#----------------------------------
ins_VaryColorByGamma = \
VaryColorByGamma \
.VaryColorByGamma ( )
ins_VaryColorByGamma \
.construct_ImageData ( 0 )
ins_VaryColorByGamma \
.construct_ImageData ( 1 )
#----------------------------------
for i in range ( 0 , global_number_of_Source_ImageData_of_Petal ) :
#------ make ImageData for Outer Petal -----------------
ins_VaryColorByGamma \
.load_ImageData ( 0 , abs_path_of_Petal_Source_Image )
ins_VaryColorByGamma \
.load_ImageData ( 1 , abs_path_of_Petal_Source_Image )
list_using_Gamma_value = \
global_list_Gamma_values_for_Source_ImageData_for_Outer [ i ]
ins_VaryColorByGamma \
.set_Gamma_values ( list_using_Gamma_value )
ins_VaryColorByGamma \
.vary_color_of_ImageData_by_Gamma ( )
file_name_for_Output = \
"Source_Outer_Petal_" + str ( ( i + 1 ) ) + ".png"
abs_path_of_Output_ImageData \
= global_abs_path_of_directory_Top \
+ global_path_of_directory_Output \
+ global_path_of_directory_Petal_Source_Image \
+ file_name_for_Output
ins_VaryColorByGamma \
.write_ImageData_Varied_Color ( abs_path_of_Output_ImageData )
#------ make ImageData for Inner Petal ---------------------
ins_VaryColorByGamma \
.load_ImageData ( 0 , abs_path_of_Petal_Source_Image )
ins_VaryColorByGamma \
.load_ImageData ( 1 , abs_path_of_Petal_Source_Image )
list_using_Gamma_value = \
global_list_Gamma_values_for_Source_ImageData_for_Inner [ i ]
ins_VaryColorByGamma \
.set_Gamma_values ( list_using_Gamma_value )
ins_VaryColorByGamma \
.vary_color_of_ImageData_by_Gamma ( )
file_name_for_Output = \
"Source_Inner_Petal_" + str ( ( i + 1 ) ) + ".png"
abs_path_of_Output_ImageData \
= global_abs_path_of_directory_Top \
+ global_path_of_directory_Output \
+ global_path_of_directory_Petal_Source_Image \
+ file_name_for_Output
ins_VaryColorByGamma \
.write_ImageData_Varied_Color ( abs_path_of_Output_ImageData )
#-----------------------------------------
print ( "==================================" )
print ( "Exit from , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
#======================================
def make_ImageData_one_Flower ( arg_row , arg_column ) :
function_name = "make_ImageData_one_Flower"
global global_module_name
global global_list_setting_number_of_petals
global global_list_use_Pattern
global global_list_Pattern
global global_list_use_Petal_Source_Image
global global_list_PetalPiece_Outer_Gamma
global global_list_PetalPiece_Inner_Gamma
global global_list_location_xy_on_Pattern_for_Outer_Petal
global global_list_location_xy_on_Pattern_for_Inner_Petal
global global_scale_rate_CopySource_to_InsertedSide
global global_color_rate_CopySource_to_InsertedSide
global global_list_BasicLocation_x_and_y_on_CopySource_ImageData
global global_list_BasicLocation_x_and_y_on_Pattern_ImageData
global global_distance_of_petal_base_from_Center
global global_abs_path_of_directory_Top
global global_path_of_directory_Input
global global_path_of_directory_Output
global global_path_of_directory_Base_Image
global global_path_of_directory_Pattern
global global_path_of_directory_Petal_Source_Image
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
#------------------------------------------
abs_path_of_Base_Image \
= global_abs_path_of_directory_Top \
+ global_path_of_directory_Input \
+ global_path_of_directory_BaseImage \
+ "White_200_200.png"
ins_ImageDataTwoDimensionHandling_Base_Image = \
ImageDataTwoDimensionHandlingV3 \
.ImageDataTwoDimensionHandlingV3 ( \
global_module_name
, function_name
)
ins_ImageDataTwoDimensionHandling_Base_Image \
.load_image_data ( \
global_module_name
, function_name
, abs_path_of_Base_Image
)
#---------------------------
use_Petal_Source_Image_number \
= global_list_use_Petal_Source_Image \
[ arg_row - 1 ] [ arg_column - 1 ]
setting_number_of_petals \
= global_list_setting_number_of_petals \
[ arg_row - 1 ] [ arg_column - 1 ]
#----------------------------
file_name_of_OuterPetal_Source_Image = \
"Source_Outer_Petal_" + str ( use_Petal_Source_Image_number ) + ".png"
abs_path_of_OuterPetal_Source_Image \
= global_abs_path_of_directory_Top \
+ global_path_of_directory_Output \
+ global_path_of_directory_Petal_Source_Image \
+ file_name_of_OuterPetal_Source_Image
ins_ImageDataTwoDimensionHandling_OuterPetal_Source_Image = \
ImageDataTwoDimensionHandlingV3 \
.ImageDataTwoDimensionHandlingV3 ( \
global_module_name
, function_name
)
ins_ImageDataTwoDimensionHandling_OuterPetal_Source_Image \
.load_image_data ( \
global_module_name
, function_name
, abs_path_of_OuterPetal_Source_Image
)
#----------------------------
file_name_of_InnerPetal_Source_Image = \
"Source_Inner_Petal_" + str ( use_Petal_Source_Image_number ) + ".png"
abs_path_of_InnerPetal_Source_Image \
= global_abs_path_of_directory_Top \
+ global_path_of_directory_Output \
+ global_path_of_directory_Petal_Source_Image \
+ file_name_of_InnerPetal_Source_Image
ins_ImageDataTwoDimensionHandling_InnerPetal_Source_Image = \
ImageDataTwoDimensionHandlingV3 \
.ImageDataTwoDimensionHandlingV3 ( \
global_module_name
, function_name
)
ins_ImageDataTwoDimensionHandling_InnerPetal_Source_Image \
.load_image_data ( \
global_module_name
, function_name
, abs_path_of_InnerPetal_Source_Image
)
#------------------------------------------
use_Pattern_number = global_list_use_Pattern \
[ arg_row - 1 ] [ arg_column - 1 ]
use_Pattern_file_name = global_list_Pattern [ use_Pattern_number - 1 ]
abs_path_of_Pattern \
= global_abs_path_of_directory_Top \
+ global_path_of_directory_Input \
+ global_path_of_directory_Pattern \
+ use_Pattern_file_name
ins_ImageDataTwoDimensionHandling_Pattern = \
ImageDataTwoDimensionHandlingV3 \
.ImageDataTwoDimensionHandlingV3 ( \
global_module_name
, function_name
)
ins_ImageDataTwoDimensionHandling_Pattern \
.load_image_data ( \
global_module_name
, function_name
, abs_path_of_Pattern
)
#=================================
ins_ImageDataTwoDimensionHandlingV3_after_setting_petal = \
MakeOneFlowerImage \
.make_one_FlowerImage ( \
ins_ImageDataTwoDimensionHandling_Base_Image
, ins_ImageDataTwoDimensionHandling_OuterPetal_Source_Image
, global_list_location_xy_on_Pattern_for_Outer_Petal
, ins_ImageDataTwoDimensionHandling_InnerPetal_Source_Image
, global_list_location_xy_on_Pattern_for_Inner_Petal
, ins_ImageDataTwoDimensionHandling_Pattern
, global_scale_rate_CopySource_to_InsertedSide
, global_color_rate_CopySource_to_InsertedSide
, global_list_BasicLocation_x_and_y_on_CopySource_ImageData
, global_list_BasicLocation_x_and_y_on_Pattern_ImageData
, global_distance_of_petal_base_from_Center
, setting_number_of_petals
)
#-----------------------------
abs_path_of_OneFlower_Image \
= global_abs_path_of_directory_Top \
+ global_path_of_directory_Output \
+ "OneFlowerImage/" \
+ "OneFlowerImage_row_" + str ( arg_row ) \
+ "_column_" + str ( arg_column ) \
+ ".png"
ins_ImageDataTwoDimensionHandlingV3_after_setting_petal \
.write_loaded_image_data_to_directed_path ( \
global_module_name
, function_name
, abs_path_of_OneFlower_Image )
#-----------------------------
return ins_ImageDataTwoDimensionHandlingV3_after_setting_petal
#========================================
----------
5 [ MakeOneFlowerImage ]
ファイル名 [ MakeOneFlowerImage.py ]
----------
import math
import CopyAndInsertImageDataV3
import ImageDataTwoDimensionHandlingV3
#=====================================
# MakeOneFlowerImage
#=====================================
global_module_name = "MakeOneFlowerImage"
global_abs_path_of_directory_Top = "E:ForPython/ForTest/Test_F/"
global_path_of_directory_Input = "Input/"
global_path_of_directory_Output = "Output/"
global_path_of_directory_Base_Image = "BaseImage/"
global_path_of_directory_Petal_Image = "PetalImage/"
global_path_of_directory_Pattern_Image = "Pattern/"
#----------------------------------------------
def make_one_FlowerImage ( \
arg_ins_ImageDataTwoDimensionHandling_Base_Image
, arg_ins_ImageDataTwoDimensionHandling_Outer_Petal
, arg_location_xy_on_Pattern_for_Outer_Petal
, arg_ins_ImageDataTwoDimensionHandling_Inner_Petal
, arg_location_xy_on_Pattern_for_Inner_Petal
, arg_ins_ImageDataTwoDimensionHandling_Pattern
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, arg_list_BasicLocation_x_and_y_on_CopySource_ImageData
, arg_list_BasicLocation_x_and_y_on_Pattern_ImageData
, arg_distance_of_petal_base_from_Center
, arg_number_of_petals
) :
function_name = "make_one_FlowerImage"
global global_module_name
global global_abs_path_of_directory_Top
global global_path_of_directory_Input
global global_path_of_directory_Output
global global_path_of_directory_Base_Image
global global_path_of_directory_Petal_Image
global global_path_of_directory_Pattern_Image
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
width_of_Outer_Petal_ImageData = \
arg_ins_ImageDataTwoDimensionHandling_Outer_Petal \
.get_width_of_ImageData ( )
height_of_Outer_Petal_ImageData = \
arg_ins_ImageDataTwoDimensionHandling_Outer_Petal \
.get_height_of_ImageData ( )
list_CopySource_From_and_To_xy_Outer_Petal = [ \
[ 0 , 0 ] \
, [ \
( width_of_Outer_Petal_ImageData - 1 ) \
, \
( height_of_Outer_Petal_ImageData - 1 ) \
] \
]
#----------------------------------------------
width_of_Inner_Petal_ImageData = \
arg_ins_ImageDataTwoDimensionHandling_Inner_Petal \
.get_width_of_ImageData ( )
height_of_Inner_Petal_ImageData = \
arg_ins_ImageDataTwoDimensionHandling_Inner_Petal \
.get_height_of_ImageData ( )
list_CopySource_From_and_To_xy_Inner_Petal = [ \
[ 0 , 0 ] \
, [ \
( width_of_Inner_Petal_ImageData - 1 ) \
, \
( height_of_Inner_Petal_ImageData - 1 ) \
] \
]
#----------------------------------------------
width_of_Base_ImageData = \
arg_ins_ImageDataTwoDimensionHandling_Base_Image \
.get_width_of_ImageData ( )
height_of_Base_ImageData = \
arg_ins_ImageDataTwoDimensionHandling_Base_Image \
.get_height_of_ImageData ( )
#----------------------------------------------
abs_path_of_Output_ImageData \
= global_abs_path_of_directory_Top \
+ global_path_of_directory_Output \
+ "Output_ImageData_Flower.png"
#---------------------------------------
list_color_copying = [ [ 0 , 0 , 0 ] , [ 253 , 253 , 253 ] ]
scale_rate_CopySource_to_InsertedSide = 1.0
color_rate_CopySource_to_InsertedSide = 1.0
#--------------------------------------
ins_CopyAndInsertImageDataV3 \
= CopyAndInsertImageDataV3 \
.CopyAndInsertImageDataV3 ( )
#------------------- set image data of Pattern
ins_CopyAndInsertImageDataV3 \
.construct_ImageData ( 1 )
ins_CopyAndInsertImageDataV3 \
.set_ImageData ( 1 , arg_ins_ImageDataTwoDimensionHandling_Pattern )
#-------------------------------
ins_CopyAndInsertImageDataV3 \
.construct_ImageData ( 2 )
ins_CopyAndInsertImageDataV3 \
.set_ImageData ( 2 \
, arg_ins_ImageDataTwoDimensionHandling_Base_Image )
#-------------------------------
ins_CopyAndInsertImageDataV3 \
.construct_ImageData ( 3 )
ins_CopyAndInsertImageDataV3 \
.set_ImageData ( 3 \
, arg_ins_ImageDataTwoDimensionHandling_Base_Image )
#---------------------------------------------------------------------------
rotation_angle_for_one_piece_of_Petal = 360.0 / arg_number_of_petals
for i in range ( 0 , arg_number_of_petals ) :
draw_one_piece_of_Petal_onto_BaseImageData ( \
i
, rotation_angle_for_one_piece_of_Petal
, ins_CopyAndInsertImageDataV3
, arg_ins_ImageDataTwoDimensionHandling_Outer_Petal
, list_CopySource_From_and_To_xy_Outer_Petal
, arg_location_xy_on_Pattern_for_Outer_Petal
, arg_ins_ImageDataTwoDimensionHandling_Inner_Petal
, list_CopySource_From_and_To_xy_Inner_Petal
, arg_location_xy_on_Pattern_for_Inner_Petal
, list_color_copying
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, arg_list_BasicLocation_x_and_y_on_CopySource_ImageData
, arg_list_BasicLocation_x_and_y_on_Pattern_ImageData
, arg_distance_of_petal_base_from_Center
, width_of_Base_ImageData
, height_of_Base_ImageData
)
# ------------------------------------------
# get output ImageData of Phase_1 , setting petal
ins_ImageDataTwoDimensionHandlingV3_after_setting_petal \
= ins_CopyAndInsertImageDataV3 \
.get_ImageData ( 3 )
print ( "==================================" )
print ( "Exit from , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
return ins_ImageDataTwoDimensionHandlingV3_after_setting_petal
#==============================================
def draw_one_piece_of_Petal_onto_BaseImageData ( \
arg_i
, arg_rotation_angle_for_one_piece_of_Petal
, arg_ins_CopyAndInsertImageDataV3
, arg_ins_ImageDataTwoDimensionHandling_Outer_Petal
, arg_list_CopySource_From_and_To_xy_Outer_Petal
, arg_location_xy_on_Pattern_for_Outer_Petal
, arg_ins_ImageDataTwoDimensionHandling_Inner_Petal
, arg_list_CopySource_From_and_To_xy_Inner_Petal
, arg_location_xy_on_Pattern_for_Inner_Petal
, arg_list_color_copying
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, arg_list_BasicLocation_x_and_y_on_CopySource_ImageData
, arg_list_BasicLocation_x_and_y_on_Pattern_ImageData
, arg_distance_of_petal_base_from_Center
, arg_width_of_Base_ImageData
, arg_height_of_Base_ImageData
) :
function_name = "draw_one_piece_of_Petal_onto_BaseImageData"
global global_module_name
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
rotation_angle = \
arg_rotation_angle_for_one_piece_of_Petal * arg_i
#------------------------------------
list_BasicLocation_x_and_y_on_InsertedSide_ImageData \
= decide_BasicLocation_InsertedSide ( \
rotation_angle
, arg_distance_of_petal_base_from_Center
, arg_width_of_Base_ImageData
, arg_height_of_Base_ImageData
, arg_list_BasicLocation_x_and_y_on_CopySource_ImageData
)
#---------------------------------------------
arg_ins_CopyAndInsertImageDataV3 \
.construct_ImageData ( 0 )
#--------- draw outer petal, on BaseImage -------------------
arg_ins_CopyAndInsertImageDataV3 \
.set_ImageData ( 0 \
, arg_ins_ImageDataTwoDimensionHandling_Outer_Petal )
arg_ins_CopyAndInsertImageDataV3 \
.copy_and_insert_ImageData ( \
"Y" # use_or_not_PatternImageData
, arg_location_xy_on_Pattern_for_Outer_Petal
, arg_list_color_copying
, arg_list_CopySource_From_and_To_xy_Outer_Petal
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, arg_list_BasicLocation_x_and_y_on_CopySource_ImageData
, arg_list_BasicLocation_x_and_y_on_Pattern_ImageData
, list_BasicLocation_x_and_y_on_InsertedSide_ImageData
, "Y" # do_rotation
, rotation_angle
)
#--------- draw inner petal, on BaseImage -------------------
arg_ins_CopyAndInsertImageDataV3 \
.set_ImageData ( 0 \
, arg_ins_ImageDataTwoDimensionHandling_Inner_Petal )
arg_ins_CopyAndInsertImageDataV3 \
.copy_and_insert_ImageData ( \
"Y" # use_or_not_PatternImageData
, arg_location_xy_on_Pattern_for_Inner_Petal
, arg_list_color_copying
, arg_list_CopySource_From_and_To_xy_Inner_Petal
, arg_scale_rate_CopySource_to_InsertedSide
, arg_color_rate_CopySource_to_InsertedSide
, arg_list_BasicLocation_x_and_y_on_CopySource_ImageData
, arg_list_BasicLocation_x_and_y_on_Pattern_ImageData
, list_BasicLocation_x_and_y_on_InsertedSide_ImageData
, "Y" # do_rotation
, rotation_angle
)
#----------------------------------------------
def decide_BasicLocation_InsertedSide ( \
arg_rotation_angle_degree
, arg_distance_of_petal_base_from_Center
, arg_width_of_Base_ImageData
, arg_height_of_Base_ImageData
, arg_list_BasicLocation_x_and_y_on_CopySource_ImageData
) :
function_name = "decide_BasicLocation_InsertedSide"
global global_module_name
print ( "==================================" )
print ( "Enter into , Module = " + global_module_name
+ " , function = " + function_name )
print ( "==================================" )
set_angle_radian = ( math.pi / 180.0 ) * arg_rotation_angle_degree
center_of_Base_ImageData = [ \
arg_width_of_Base_ImageData / 2.0 \
, arg_height_of_Base_ImageData / 2.0 \
]
distance_from_Center_direction_x = \
arg_distance_of_petal_base_from_Center \
+ arg_list_BasicLocation_x_and_y_on_CopySource_ImageData [ 0 ]
list_return = [ 0 , 0 ]
list_return [ 0 ] = \
center_of_Base_ImageData [ 0 ] \
+ ( distance_from_Center_direction_x \
* math.cos ( set_angle_radian ) )
list_return [ 1 ] = \
center_of_Base_ImageData [ 1 ] \
+ ( distance_from_Center_direction_x \
* math.sin ( set_angle_radian ) )
return list_return
#----------------------------------------------
----------
----------
6 [ TestMakeFlowerImages ]
ファイル名 [ TestMakeFlowerImages.py ]
----------
import MakeFlowerImages
module_name = "TestMakeFlowerImages"
function_name = "_____"
MakeFlowerImages \
.main_process ( )
#========================================
----------
----------