diff --git a/TIASshot/CameraBase.cs b/TIASshot/CameraBase.cs index 808e917..edcab74 100644 --- a/TIASshot/CameraBase.cs +++ b/TIASshot/CameraBase.cs @@ -56,15 +56,15 @@ new int[] { 1, 3, 3 }, // G new int[] { 2, 3, 3 }, // B new int[] { 0, 1, 3 }, // RG + new int[] { 0, 2, 3 }, // RB new int[] { 1, 2, 3 }, // GB - new int[] { 2, 0, 3 }, // BR new int[] { 0, 0, 3 }, // RR new int[] { 1, 1, 3 }, // GG new int[] { 2, 2, 3 }, // BB - new int[] { 0, 0, 1 }, // RRG new int[] { 0, 0, 2 }, // RRB - new int[] { 1, 1, 2 }, // GGB + new int[] { 0, 0, 1 }, // RRG new int[] { 1, 1, 0 }, // GGR + new int[] { 1, 1, 2 }, // GGB new int[] { 2, 2, 0 }, // BBR new int[] { 2, 2, 1 }, // BBG new int[] { 0, 1, 2 }, // RGB @@ -81,10 +81,9 @@ /// public CameraBase(Form1 form) { _form = form; - Config.Load(); UpdateRate = Config.GetFloat("Calib/UpdateRate"); - TCC_SRGB = LoadMatFromCsv(Config.GetString("File/TccSrgbTable")); - TCC_XYZ = LoadMatFromCsv(Config.GetString("File/TccXyzTable")); + TCC_SRGB = LoadMatFromCsv(Config.GetString("File/TccSrgbRef")); + TCC_XYZ = LoadMatFromCsv(Config.GetString("File/TccXyzRef")); ChannelList = Config.GetString("Calib/ConversionChannels") .Split(',') .Select(x => int.Parse(x.Trim())) @@ -105,11 +104,11 @@ return false; } if (TCC_SRGB is null) { - ErrorMsg = $"ファイル({Config.GetString("File/TccSrgbTable")})の読み込みに失敗しました.\r\n終了します."; + ErrorMsg = $"ファイル({Config.GetString("File/TccSrgbRef")})の読み込みに失敗しました.\r\n終了します."; return false; } if (TCC_XYZ is null) { - ErrorMsg = $"ファイル({Config.GetString("File/TccXyzTable")})の読み込みに失敗しました.\r\n終了します."; + ErrorMsg = $"ファイル({Config.GetString("File/TccXyzRef")})の読み込みに失敗しました.\r\n終了します."; return false; } return true; @@ -145,13 +144,13 @@ /// protected void SaveImages(Mat img, int idx) { - var filename = Config.GetString("File/ImageRgb"); + var filename = Config.GetString("File/RgbImage"); filename = filename.Replace("{NO}", $"{idx + 1:0000}"); Cv2.ImWrite(Path.Combine(_saveFolder, filename), img); foreach (var channel in ChannelList) { using (var converted = ConvertImage(img, _convRGB2SRGB[channel])) { - filename = GetFilenameWithChannel("File/ImageSrgb", channel); + filename = GetFilenameWithChannel("File/SrgbImage", channel); filename = filename.Replace("{NO}", $"{idx + 1:0000}"); Cv2.ImWrite(Path.Combine(_saveFolder, filename), converted); } @@ -275,23 +274,33 @@ // データ保存 SetSaveFolder("校正"); SetInfo("校正データ", _saveFolder); - Cv2.ImWrite(Path.Combine(_saveFolder, Config.GetString("File/TccSave")), img); - Cv2.ImWrite(Path.Combine(_saveFolder, Config.GetString("File/TccRois")), imgRois); - SaveMatToCsv(Path.Combine(_saveFolder, Config.GetString("File/TccRgb")), tccRgb); + Cv2.ImWrite(Path.Combine(_saveFolder, Config.GetString("File/TccImage")), img); + Cv2.ImWrite(Path.Combine(_saveFolder, Config.GetString("File/TccRoisImage")), imgRois); + SaveMatToCsv(Path.Combine(_saveFolder, Config.GetString("File/TccRgbValues")), tccRgb); _convRGB2SRGB.Clear(); foreach (var channel in ChannelList) { var convRGB2SRGB = CalcConvertMatrix(tccRgb, TCC_SRGB, channel); - SaveMatToCsv(Path.Combine(_saveFolder, GetFilenameWithChannel("File/ConvSrgbSave", channel)), convRGB2SRGB); + SaveMatToCsv(Path.Combine(_saveFolder, GetFilenameWithChannel("File/ConvRgb2Srgb", channel)), convRGB2SRGB); var convRGB2XYZ = CalcConvertMatrix(tccRgb, TCC_XYZ, channel); - SaveMatToCsv(Path.Combine(_saveFolder, GetFilenameWithChannel("File/ConvXyzSave", channel)), convRGB2XYZ); + SaveMatToCsv(Path.Combine(_saveFolder, GetFilenameWithChannel("File/ConvRgb2Xyz", channel)), convRGB2XYZ); + if (channel == 17) { + var convOld = new Mat(convRGB2XYZ.Size(), MatType.CV_64FC1); + for (var row = 0; row < convRGB2XYZ.Rows; row++) { + var rowFrom = (row + 1) % convRGB2XYZ.Rows; // 1行ずらす + for (var col = 0; col < convRGB2XYZ.Cols; col++) { + convOld.At(row, col) = convRGB2XYZ.At(rowFrom, col); + } + } + SaveMatToCsv(Path.Combine(_saveFolder, GetFilenameWithChannel("File/ConvRgb2XyzOld", channel)), convOld); + } var tccSrgb = ConvertColor(tccRgb, convRGB2SRGB); - SaveMatToCsv(Path.Combine(_saveFolder, GetFilenameWithChannel("File/TccSrgb", channel)), tccSrgb); + SaveMatToCsv(Path.Combine(_saveFolder, GetFilenameWithChannel("File/TccSrgbValues", channel)), tccSrgb); var convSrgb2Xyz = CalcConvertMatrix(tccSrgb, TCC_XYZ, channel); - SaveMatToCsv(Path.Combine(_saveFolder, GetFilenameWithChannel("File/ConvSrgb2XyzSave", channel)), convSrgb2Xyz); + SaveMatToCsv(Path.Combine(_saveFolder, GetFilenameWithChannel("File/ConvSrgb2Xyz", channel)), convSrgb2Xyz); // 変換精度検証 var diff = Math.Sqrt(Cv2.Norm(TCC_SRGB, tccSrgb, NormTypes.L2)); diff --git a/TIASshot/Form1.Designer.cs b/TIASshot/Form1.Designer.cs index 120fe04..f2c0245 100644 --- a/TIASshot/Form1.Designer.cs +++ b/TIASshot/Form1.Designer.cs @@ -47,6 +47,8 @@ this.btnOpenDataFolder = new System.Windows.Forms.Button(); this.btnLightSW = new System.Windows.Forms.Button(); this.icImagingControl1 = new TIS.Imaging.ICImagingControl(); + this.txtConvElemNum = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picPreview)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picDisplay)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.icImagingControl1)).BeginInit(); @@ -160,7 +162,7 @@ // txtSaveFolder // this.txtSaveFolder.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.txtSaveFolder.Location = new System.Drawing.Point(78, 463); + this.txtSaveFolder.Location = new System.Drawing.Point(78, 418); this.txtSaveFolder.Name = "txtSaveFolder"; this.txtSaveFolder.ReadOnly = true; this.txtSaveFolder.Size = new System.Drawing.Size(205, 23); @@ -170,7 +172,7 @@ // this.label3.AutoSize = true; this.label3.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label3.Location = new System.Drawing.Point(12, 440); + this.label3.Location = new System.Drawing.Point(12, 395); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(123, 16); this.label3.TabIndex = 11; @@ -258,7 +260,7 @@ // btnOpenDataFolder // this.btnOpenDataFolder.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.btnOpenDataFolder.Location = new System.Drawing.Point(15, 459); + this.btnOpenDataFolder.Location = new System.Drawing.Point(15, 414); this.btnOpenDataFolder.Name = "btnOpenDataFolder"; this.btnOpenDataFolder.Size = new System.Drawing.Size(57, 27); this.btnOpenDataFolder.TabIndex = 20; @@ -290,11 +292,32 @@ this.icImagingControl1.TabIndex = 22; this.icImagingControl1.Visible = false; // + // txtConvElemNum + // + this.txtConvElemNum.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.txtConvElemNum.Location = new System.Drawing.Point(173, 463); + this.txtConvElemNum.Name = "txtConvElemNum"; + this.txtConvElemNum.ReadOnly = true; + this.txtConvElemNum.Size = new System.Drawing.Size(110, 23); + this.txtConvElemNum.TabIndex = 23; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Font = new System.Drawing.Font("MS UI Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.label9.Location = new System.Drawing.Point(12, 466); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(148, 16); + this.label9.TabIndex = 24; + this.label9.Text = "変換行列の説明変数"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(753, 634); + this.Controls.Add(this.label9); + this.Controls.Add(this.txtConvElemNum); this.Controls.Add(this.icImagingControl1); this.Controls.Add(this.btnLightSW); this.Controls.Add(this.btnOpenDataFolder); @@ -356,6 +379,8 @@ private System.Windows.Forms.Button btnOpenDataFolder; private System.Windows.Forms.Button btnLightSW; private TIS.Imaging.ICImagingControl icImagingControl1; + private System.Windows.Forms.TextBox txtConvElemNum; + private System.Windows.Forms.Label label9; } } diff --git a/TIASshot/Form1.cs b/TIASshot/Form1.cs index df72fae..e42a0d2 100644 --- a/TIASshot/Form1.cs +++ b/TIASshot/Form1.cs @@ -41,6 +41,8 @@ /// /// private void Form1_Load(object sender, EventArgs e) { + Config.Load(); + _camera = new Lucam(this, picPreview); if (!_camera.Connect()) { Debug.WriteLine(_camera.ErrorMsg); @@ -72,6 +74,7 @@ txtMultiShotsInterval.Text = Config.GetString("Shot/MultiShotInterval"); txtDataName.Text = Config.GetString("Shot/SubjectName"); txtSaveFolder.Text = Config.GetString("File/SaveFolder"); + txtConvElemNum.Text = Config.GetString("Calib/ConversionChannels"); EnableShots(false); //_lucam.StartStopPreview(); diff --git a/TIASshot/Properties/AssemblyInfo.cs b/TIASshot/Properties/AssemblyInfo.cs index 53d0db9..5ee4463 100644 --- a/TIASshot/Properties/AssemblyInfo.cs +++ b/TIASshot/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ // ビルド番号 // リビジョン // -[assembly: AssemblyVersion("1.4.0.0")] -[assembly: AssemblyFileVersion("1.4.0.0")] +[assembly: AssemblyVersion("1.5.0.0")] +[assembly: AssemblyFileVersion("1.5.0.0")] diff --git a/TIASshot/config.xml b/TIASshot/config.xml index bebe4b6..0205db9 100644 --- a/TIASshot/config.xml +++ b/TIASshot/config.xml @@ -18,27 +18,28 @@ 0.8 100 5 - 4,10,17 + 17 - 5 - 100 + 10 + 500 無記名 C:\TIAS_Data - tcc_srgb.csv - tcc_xyz.csv - TCC.png - TCC_ROIs.jpg - Shot{NO}.png - sRGB{CN}_{NO}.jpg + tcc_srgb.csv + tcc_xyz.csv + TCC.png + TCC_ROIs.jpg + Shot{NO}.png + sRGB{CN}_{NO}.jpg Info.csv - TCC_RGB.csv - TCC_sRGB{CN}.csv - Conv_RGB-sRGB{CN}.csv - Conv_RGB-XYZ{CN}.csv - Conv_sRGB-XYZ{CN}.csv + TCC_RGB.csv + TCC_sRGB{CN}.csv + Conv_RGB-sRGB{CN}.csv + Conv_RGB-XYZ{CN}.csv + Conv_sRGB-XYZ{CN}.csv + Conv_RGB-XYZold.csv Silicon Labs CP210x