質問編集履歴

2

hensyuu

2018/11/15 19:20

投稿

coco_
coco_

スコア19

test CHANGED
File without changes
test CHANGED
@@ -36,352 +36,438 @@
36
36
 
37
37
  {
38
38
 
39
- // 係数用にメンバー変数を定義
40
-
41
- Dictionary<string, Dictionary<string, Dictionary<string, double>>> keisuu = null;
42
-
43
-
44
-
45
-
46
-
47
- /// <summary>
48
-
49
- /// コンストラクタ
50
-
51
- /// </summary>
52
-
53
- public Form1()
54
-
55
- {
56
-
57
- InitializeComponent();
58
-
59
-
60
-
61
- // 係数ファイルを読み込み。
62
-
63
- try
39
+ keisuu = new Dictionary<string, Dictionary<string, Dictionary<string, double>>>();
40
+
41
+
42
+
43
+ // xxxxx1 = 基本色、全色相、活気、評価値の平均
44
+
45
+ keisuu["xxx1"] = new Dictionary<string, Dictionary<string, double>>();
46
+
47
+ keisuu["xxx1"]["a0"] = new Dictionary<string, double>();
48
+
49
+ keisuu["xxx1"]["a0"]["B"] = -0.138;
50
+
51
+ keisuu["xxx1"]["a0"]["G"] = -0.137;
52
+
53
+ keisuu["xxx1"]["a0"]["P"] = -0.134;
54
+
55
+ keisuu["xxx1"]["a0"]["R"] = -0.135;
56
+
57
+ keisuu["xxx1"]["a0"]["Y"] = -0.137;
58
+
59
+         .
60
+
61
+ .
62
+
63
+ .
64
+
65
+ keisuu["xxx1"]["a5"] = new Dictionary<string, double>();
66
+
67
+ keisuu["xxx1"]["a5"]["B"] = 0.013;
68
+
69
+ keisuu["xxx1"]["a5"]["G"] = 0.008;
70
+
71
+ keisuu["xxx1"]["a5"]["P"] = 0.017;
72
+
73
+ keisuu["xxx1"]["a5"]["R"] = 0.007;
74
+
75
+ keisuu["xxx1"]["a5"]["Y"] = 0.010;
76
+
77
+ //xxx2 = 基本色、全色相、落ち着き、評価値の平均
78
+
79
+ keisuu["xxx2"] = new Dictionary<string, Dictionary<string, double>>();
80
+
81
+ keisuu["xxx2"]["a0"] = new Dictionary<string, double>();
82
+
83
+ keisuu["xxx2"]["a0"]["B"] = 0.268;
84
+
85
+ keisuu["xxx2"]["a0"]["G"] = 0.267;
86
+
87
+ keisuu["xxx2"]["a0"]["P"] = 0.265;
88
+
89
+ keisuu["xxx2"]["a0"]["R"] = 0.251;
90
+
91
+ keisuu["xxx2"]["a0"]["Y"] = 0.258;
92
+
93
+ .
94
+
95
+ .
96
+
97
+ .
98
+
99
+ keisuu["xxx2"]["a5"] = new Dictionary<string, double>();
100
+
101
+ keisuu["xxx2"]["a5"]["B"] = 0.003;
102
+
103
+ keisuu["xxx2"]["a5"]["G"] = -0.020;
104
+
105
+ keisuu["xxx2"]["a5"]["P"] = 0.010;
106
+
107
+ keisuu["xxx2"]["a5"]["R"] = -0.017;
108
+
109
+ keisuu["xxx2"]["a5"]["Y"] = -0.028;
110
+
111
+ // xxx3 = 強調色、全色相、活気、評価値の平均
112
+
113
+ keisuu["xxx3"] = new Dictionary<string, Dictionary<string, double>>();
114
+
115
+ keisuu["xxx3"]["a0"] = new Dictionary<string, double>();
116
+
117
+ keisuu["xxx3"]["a0"]["B"] = 0.044;
118
+
119
+ keisuu["xxx3"]["a0"]["G"] = 0.043;
120
+
121
+ keisuu["xxx3"]["a0"]["P"] = 0.047;
122
+
123
+ keisuu["xxx3"]["a0"]["R"] = 0.047;
124
+
125
+ keisuu["xxx3"]["a0"]["Y"] = 0.043;
126
+
127
+ .
128
+
129
+ .
130
+
131
+ .
132
+
133
+ keisuu["xxx3"]["a5"] = new Dictionary<string, double>();
134
+
135
+ keisuu["xxx3"]["a5"]["B"] = 0.011;
136
+
137
+ keisuu["xxx3"]["a5"]["G"] = 0.007;
138
+
139
+ keisuu["xxx3"]["a5"]["P"] = 0.007;
140
+
141
+ keisuu["xxx3"]["a5"]["R"] = 0.003;
142
+
143
+ keisuu["xxx3"]["a5"]["Y"] = 0.006;
144
+
145
+ // xxx4 = 強調色、全色相、落ち着き、評価値の平均
146
+
147
+ keisuu["xxx4"] = new Dictionary<string, Dictionary<string, double>>();
148
+
149
+ keisuu["xxx4"]["a0"] = new Dictionary<string, double>();
150
+
151
+ keisuu["xxx4"]["a0"]["B"] = 0.426;
152
+
153
+ keisuu["xxx4"]["a0"]["G"] = 0.427;
154
+
155
+ keisuu["xxx4"]["a0"]["P"] = 0.415;
156
+
157
+ keisuu["xxx4"]["a0"]["R"] = 0.412;
158
+
159
+ keisuu["xxx4"]["a0"]["Y"] = 0.417;
160
+
161
+ .
162
+
163
+ .
164
+
165
+ .
166
+
167
+ keisuu["xxx4"]["a5"] = new Dictionary<string, double>();
168
+
169
+ keisuu["xxx4"]["a5"]["B"] = 0.001;
170
+
171
+ keisuu["xxx4"]["a5"]["G"] = -0.017;
172
+
173
+ keisuu["xxx4"]["a5"]["P"] = -0.004;
174
+
175
+ keisuu["xxx4"]["a5"]["R"] = -0.004;
176
+
177
+ keisuu["xxx4"]["a5"]["Y"] = -0.014;
178
+
179
+
180
+
181
+ // 文字列定義している場所は変数に入れて使える。
182
+
183
+ /*
184
+
185
+ string xxx = "xxx1";
186
+
187
+ string tarColor ="B";
188
+
189
+ double z = keisuu[xxx]["a0"][tarColor]
190
+
191
+ + (keisuu[xxx]["a1"][tarColor] * x)
192
+
193
+ + (keisuu[xxx]["a2"][tarColor] * y)
194
+
195
+ + (keisuu[xxx]["a3"][tarColor] * x * x)
196
+
197
+ + (keisuu[xxx]["a4"][tarColor] * x * y)
198
+
199
+ + (keisuu[xxx]["a5"][tarColor] * y * y);
200
+
201
+ */
202
+
203
+ }
204
+
205
+
206
+
207
+
208
+
209
+ private void button1_Click(object sender, EventArgs e)
64
210
 
65
211
  {
66
212
 
213
+
214
+
215
+
216
+
217
+ // Retrieve the image.
218
+
219
+ Bitmap image1 = new Bitmap(@"C:\Users\peanuts\Source\Repos\WindowsFormsApp12\WindowsFormsApp12\Resources\blue.png");
220
+
221
+ //Bitmap image1 = new Bitmap(MAXLINE + 1, MAXLINE +1); // サイズはとても重要(200だったら、201である必要がある)
222
+
223
+
224
+
225
+ int CELL_CNT_x = 100; // 座標1セル当たり100個必要
226
+
227
+ int CELL_CNT_y = 100; // 座標1セル当たり100個必要
228
+
229
+ int BASELINE_x = image1.Width / CELL_CNT_x + 1; // x軸の最大の長さを100等分する
230
+
231
+ int BASELINE_y = image1.Height / CELL_CNT_y; // y軸の最大の長さを100等分する
232
+
233
+
234
+
235
+ int x, y;
236
+
237
+
238
+
239
+ string keisuuType = "kkk1";
240
+
241
+ string kanten1 = "xxx1";
242
+
243
+ string kanten2 = "xxx2";
244
+
245
+ string tarColor = "B";
246
+
67
- string filepath = @"D:\temp\sample20181025byMH\keisuu_utf8.csv";
247
+ string selectedkeisuutype = (comboBoxkeisuuType.SelectedItem.ToString());
248
+
68
-
249
+ string selectedtarColor = (comboBox1.SelectedItem.ToString());
250
+
251
+ if ("基本色" == selectedkeisuutype)
252
+
253
+ {
254
+
255
+ keisuuType = "kkk1";
256
+
257
+ kanten1 = "xxx1";
258
+
259
+ kanten2 = "xxx2";
260
+
261
+ }
262
+
263
+
264
+
265
+ else if ("強調色" == selectedkeisuutype)
266
+
267
+ {
268
+
269
+ keisuuType = "kkk2";
270
+
271
+ kanten1 = "xxx3";
272
+
273
+ kanten2 = "xxx4";
274
+
275
+ }
276
+
277
+
278
+
279
+
280
+
281
+ if ("青" == selectedtarColor)
282
+
283
+ {
284
+
285
+ tarColor = "B";
286
+
287
+ }
288
+
289
+ else if ("緑" == selectedtarColor)
290
+
291
+ {
292
+
293
+ tarColor = "G";
294
+
295
+ }
296
+
297
+ else if ("紫" == selectedtarColor)
298
+
299
+ {
300
+
301
+ tarColor = "P";
302
+
303
+ }
304
+
305
+ else if ("赤" == selectedtarColor)
306
+
307
+ {
308
+
309
+ tarColor = "R";
310
+
311
+ }
312
+
313
+ else if ("黄" == selectedtarColor)
314
+
315
+ {
316
+
317
+ tarColor = "Y";
318
+
319
+ }
320
+
321
+
322
+
323
+
324
+
325
+ var graphics = Graphics.FromImage(image1);
326
+
327
+ for (x = 0; x <= CELL_CNT_x; x++)
328
+
329
+ {
330
+
331
+ for (y = 0; y <= CELL_CNT_y; y++)
332
+
333
+ {
334
+
335
+ //float hue = pixelColor.GetHue(); // 色相
336
+
337
+ //float saturation = pixelColor.GetSaturation(); // 彩度を取得
338
+
339
+ //float brightness = pixelColor.GetBrightness(); // 明度を取得
340
+
341
+ if (IsDraw(tarColor, kanten1, kanten2, keisuuType, x, y) == true)
342
+
343
+ {
344
+
345
+ int drawX = x * BASELINE_x; // 400
346
+
347
+ int drawY = ReviewGuiY(y * BASELINE_y, image1.Height - 1); // サイズ200の場合,0~199までであるため、最大地199
348
+
349
+
350
+
69
- keisuu = KeisuuReader.Read(filepath, Encoding.UTF8);
351
+ //image1.SetPixel(drawX, drawY, Color.Red);
352
+
353
+ graphics.FillEllipse(new SolidBrush(Color.Red), drawX, drawY, BASELINE_x, BASELINE_y); // 塗りつぶす
354
+
355
+ }
356
+
357
+ }
358
+
359
+ }
360
+
361
+
362
+
363
+ // Set the PictureBox to display the image.
364
+
365
+
366
+
367
+ pictureBox1.Image = image1;
368
+
369
+
70
370
 
71
371
  }
72
372
 
373
+
374
+
73
- catch (Exception ex)
375
+ private int ReviewGuiY(int y, int maxY)
74
376
 
75
377
  {
76
378
 
77
- System.Console.WriteLine(ex);
78
-
79
- MessageBox.Show(ex.Message);
379
+ return maxY - y;
80
380
 
81
381
  }
82
382
 
83
383
 
84
384
 
85
- }
385
+
86
-
87
-
88
-
89
-
90
-
386
+
91
- private void button1_Click(object sender, EventArgs e)
387
+ private bool IsDraw(string tarColor, string kanten1, string kanten2, string keisuuType, float y, float x)
92
388
 
93
389
  {
94
390
 
391
+
392
+
95
-
393
+ double m, n;
394
+
96
-
395
+ m = double.Parse(textBox1.Text);
396
+
97
-
397
+ n = double.Parse(textBox2.Text);
398
+
399
+
400
+
98
-
401
+ x = x / 10;
402
+
403
+ y = y / 10;
404
+
99
- // Retrieve the image.
405
+ double h = m; // 刻み値
100
-
101
- Bitmap image1 = new Bitmap(@"C:\Users\peanuts\Source\Repos\WindowsFormsApp12\WindowsFormsApp12\Resources\blue.png");
406
+
102
-
103
- //Bitmap image1 = new Bitmap(MAXLINE + 1, MAXLINE +1); // サイズはとても重要(200だったら、201である必要がある)
104
-
105
-
106
-
107
- int CELL_CNT_x = 100; // 座標1セル当た100個必要
407
+ double j = n; // 範囲
108
-
109
- int CELL_CNT_y = 100; // 座標1セル当たり100個必要
408
+
110
-
111
- int BASELINE_x = image1.Width / CELL_CNT_x + 1; // x軸の最大の長さを100等分する
409
+
112
-
113
- int BASELINE_y = image1.Height / CELL_CNT_y; // y軸の最大の長さを100等分する
114
-
115
-
116
-
117
- int x, y;
118
-
119
-
120
-
121
- string keisuuType = "kkk1";
122
-
123
- string kanten1 = "xxx1";
124
-
125
- string kanten2 = "xxx2";
126
-
127
- string tarColor = "B";
128
-
129
- string selectedkeisuutype = (comboBoxkeisuuType.SelectedItem.ToString());
130
-
131
- string selectedtarColor = (comboBox1.SelectedItem.ToString());
132
-
133
- if ("基本色" == selectedkeisuutype)
134
-
135
- {
136
-
137
- keisuuType = "kkk1";
138
-
139
- kanten1 = "xxx1";
140
-
141
- kanten2 = "xxx2";
142
-
143
- }
144
-
145
-
146
-
147
- else if ("強調色" == selectedkeisuutype)
148
-
149
- {
150
-
151
- keisuuType = "kkk2";
152
-
153
- kanten1 = "xxx3";
154
-
155
- kanten2 = "xxx4";
156
-
157
- }
158
410
 
159
411
 
160
412
 
161
-
162
-
163
- if ("青" == selectedtarColor)
164
-
165
- {
166
-
167
- tarColor = "B";
168
-
169
- }
170
-
171
- else if ("緑" == selectedtarColor)
172
-
173
- {
174
-
175
- tarColor = "G";
176
-
177
- }
178
-
179
- else if ("紫" == selectedtarColor)
180
-
181
- {
182
-
183
- tarColor = "P";
184
-
185
- }
186
-
187
- else if ("赤" == selectedtarColor)
188
-
189
- {
190
-
191
- tarColor = "R";
192
-
193
- }
194
-
195
- else if ("黄" == selectedtarColor)
196
-
197
- {
198
-
199
- tarColor = "Y";
200
-
201
- }
202
-
203
-
204
-
205
-
206
-
207
- var graphics = Graphics.FromImage(image1);
208
-
209
- for (x = 0; x <= CELL_CNT_x; x++)
210
-
211
- {
212
-
213
- for (y = 0; y <= CELL_CNT_y; y++)
214
-
215
- {
216
-
217
- //float hue = pixelColor.GetHue(); // 色相
218
-
219
- //float saturation = pixelColor.GetSaturation(); // 彩度を取得
220
-
221
- //float brightness = pixelColor.GetBrightness(); // 明度を取得
222
-
223
- if (IsDraw(tarColor, kanten1, kanten2, keisuuType, x, y) == true)
224
-
225
- {
226
-
227
- int drawX = x * BASELINE_x; // 400
228
-
229
- int drawY = ReviewGuiY(y * BASELINE_y, image1.Height - 1); // サイズ200の場合,0~199までであるため、最大地199
230
-
231
-
232
-
233
- //image1.SetPixel(drawX, drawY, Color.Red);
234
-
235
- graphics.FillEllipse(new SolidBrush(Color.Red), drawX, drawY, BASELINE_x, BASELINE_y); // 塗りつぶす
236
-
237
- }
238
-
239
- }
240
-
241
- }
242
-
243
-
244
-
245
- // Set the PictureBox to display the image.
246
-
247
-
248
-
249
- pictureBox1.Image = image1;
413
+ ** // double z= の式でエラーが出ました。
414
+
415
+ double z = keisuu[keisuuType][kanten1]["a0"][tarColor]
416
+
417
+ + (keisuu[keisuuType][kanten1]["a1"][tarColor] * x)
418
+
419
+ + (keisuu[keisuuType][kanten1]["a2"][tarColor] * y)
420
+
421
+ + (keisuu[keisuuType][kanten1]["a3"][tarColor] * x * x)
422
+
423
+ + (keisuu[keisuuType][kanten1]["a4"][tarColor] * x * y)
424
+
425
+ + (keisuu[keisuuType][kanten1]["a5"][tarColor] * y * y);
426
+
427
+ **
428
+
429
+ double z1 = keisuu[keisuuType][kanten2]["a0"][tarColor]
430
+
431
+ + (keisuu[keisuuType][kanten2]["a1"][tarColor] * x)
432
+
433
+ + (keisuu[keisuuType][kanten2]["a2"][tarColor] * y)
434
+
435
+ + (keisuu[keisuuType][kanten2]["a3"][tarColor] * x * x)
436
+
437
+ + (keisuu[keisuuType][kanten2]["a4"][tarColor] * x * y)
438
+
439
+ + (keisuu[keisuuType][kanten2]["a5"][tarColor] * y * y);
440
+
441
+
442
+
443
+ double z2 = z - z1;
444
+
445
+
446
+
447
+ double dAbs = System.Math.Abs(z2); //zの絶対値取得
448
+
449
+
450
+
451
+ if (dAbs % h <= j)
452
+
453
+ {
454
+
455
+ return true; // 何かの条件による計算結果の結果、描画条件を満たした。
456
+
457
+ }
458
+
459
+ else
460
+
461
+ {
462
+
463
+ return false; // 何かの条件による計算結果の結果、描画上限を満たさなかった。
464
+
465
+ }
250
466
 
251
467
 
252
468
 
253
469
  }
254
470
 
255
-
256
-
257
- private int ReviewGuiY(int y, int maxY)
258
-
259
- {
260
-
261
- return maxY - y;
262
-
263
- }
264
-
265
-
266
-
267
-
268
-
269
- /// <summary>
270
-
271
- /// X座標とY座標の位置から描画する条件に一致している確認する。
272
-
273
- /// </summary>
274
-
275
- /// <param name="tarColor">ターゲットカラー</param>
276
-
277
- /// <param name="keisuuType">係数タイプ</param>
278
-
279
- /// <param name="x">明度(saturation)0~100</param>
280
-
281
- /// <param name="y">彩度(brightness)0~100</param>
282
-
283
- /// <returns>出力条件を満たした場合True</returns>
284
-
285
- private bool IsDraw(string tarColor, string kanten1, string kanten2, string keisuuType, float y, float x)
286
-
287
- {
288
-
289
-
290
-
291
- double m, n;
292
-
293
- m = double.Parse(textBox1.Text);
294
-
295
- n = double.Parse(textBox2.Text);
296
-
297
-
298
-
299
- x = x / 10;
300
-
301
- y = y / 10;
302
-
303
- double h = m; // 刻み値
304
-
305
- double j = n; // 余り範囲
306
-
307
-
308
-
309
- // 予測値zを求める
310
-
311
- // 予測式:z=a? +a? x+a? y+a? x2+a? xy+a? y2
312
-
313
- // x :明度 y :彩度 a ?? ? :係数 z :予測値
314
-
315
- // 予測式は着色する部分{基本色、強調色}、色相{Blue、Green、Purple、Red、Yellow}、
316
-
317
- // 観点を表す言葉{にぎやかで活気があること、静かで落ち着きがあること}、
318
-
319
- // 値の種類{評価値の平均、評価値の標準偏差}ごとに作成する
320
-
321
- // Wは観点の重視度(Tracberツール)
322
-
323
- // double zは活気 z1は落ち着き
324
-
325
-
326
-
327
- ** // double z= の式でエラーが出ました。
328
-
329
- double z = keisuu[keisuuType][kanten1]["a0"][tarColor]
330
-
331
- + (keisuu[keisuuType][kanten1]["a1"][tarColor] * x)
332
-
333
- + (keisuu[keisuuType][kanten1]["a2"][tarColor] * y)
334
-
335
- + (keisuu[keisuuType][kanten1]["a3"][tarColor] * x * x)
336
-
337
- + (keisuu[keisuuType][kanten1]["a4"][tarColor] * x * y)
338
-
339
- + (keisuu[keisuuType][kanten1]["a5"][tarColor] * y * y);
340
-
341
- **
342
-
343
- double z1 = keisuu[keisuuType][kanten2]["a0"][tarColor]
344
-
345
- + (keisuu[keisuuType][kanten2]["a1"][tarColor] * x)
346
-
347
- + (keisuu[keisuuType][kanten2]["a2"][tarColor] * y)
348
-
349
- + (keisuu[keisuuType][kanten2]["a3"][tarColor] * x * x)
350
-
351
- + (keisuu[keisuuType][kanten2]["a4"][tarColor] * x * y)
352
-
353
- + (keisuu[keisuuType][kanten2]["a5"][tarColor] * y * y);
354
-
355
-
356
-
357
- double z2 = z - z1;
358
-
359
-
360
-
361
- double dAbs = System.Math.Abs(z2); //zの絶対値取得
362
-
363
-
364
-
365
- if (dAbs % h <= j)
366
-
367
- {
368
-
369
- return true; // 何かの条件による計算結果の結果、描画条件を満たした。
370
-
371
- }
372
-
373
- else
374
-
375
- {
376
-
377
- return false; // 何かの条件による計算結果の結果、描画上限を満たさなかった。
378
-
379
- }
380
-
381
-
382
-
383
- }
384
-
385
471
 
386
472
 
387
473
  }

1

naosita

2018/11/15 19:20

投稿

coco_
coco_

スコア19

test CHANGED
File without changes
test CHANGED
@@ -82,9 +82,7 @@
82
82
 
83
83
 
84
84
 
85
-
86
-
87
- }
85
+ }
88
86
 
89
87
 
90
88