Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
seto77 committed May 19, 2022
1 parent d608e36 commit 321b19a
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 37 deletions.
4 changes: 2 additions & 2 deletions Crystallography.Controls/Crystallography.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2022.05.19.1730</AssemblyVersion>
<FileVersion>2022.05.19.1730</FileVersion>
<AssemblyVersion>2022.05.19.1837</AssemblyVersion>
<FileVersion>2022.05.19.1837</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
4 changes: 2 additions & 2 deletions Crystallography.OpenGL/Crystallography.OpenGL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2022.05.19.1730</AssemblyVersion>
<FileVersion>2022.05.19.1730</FileVersion>
<AssemblyVersion>2022.05.19.1837</AssemblyVersion>
<FileVersion>2022.05.19.1837</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
2 changes: 1 addition & 1 deletion Crystallography/BetheMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ public double[][] GetHRTEMImage(Beam[] beams, Size size, double res, double cs,
}
else//Managed
{
Parallel.For(0, width * height, n =>s
Parallel.For(0, width * height, n =>
{
PointD r = new(-(n % width - cX) * res + shift.X, -(height - n / width - 1 - cY) * res + shift.Y), _vec = new(double.NaN, double.NaN);
var sums = new Complex[defLen];
Expand Down
4 changes: 2 additions & 2 deletions Crystallography/Crystallography.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2022.05.19.1730</AssemblyVersion>
<FileVersion>2022.05.19.1730</FileVersion>
<AssemblyVersion>2022.05.19.1837</AssemblyVersion>
<FileVersion>2022.05.19.1837</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
61 changes: 60 additions & 1 deletion ReciPro/FormImageSimulator.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 20 additions & 18 deletions ReciPro/FormImageSimulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ private void simulatePotential(bool realtimeMode = false)

setPseudoBitamap(result);
toolStripStatusLabel1.Text += $"Drawing: {sw.ElapsedMilliseconds - temp} msec.";
TrackBarAdvancedMin_ValueChanged(new object(), 0);
}

public void SimulateHRTEM(bool realtimeMode = false)
Expand Down Expand Up @@ -382,21 +383,14 @@ public void SimulateHRTEM(bool realtimeMode = false)
var temp = sw.ElapsedMilliseconds;
toolStripStatusLabel1.Text += $"Generation of HRTEM images: {sw.ElapsedMilliseconds} msec, ";

SkipEvent = true;
trackBarAdvancedMax.Value = trackBarAdvancedMin.Maximum = trackBarAdvancedMax.Maximum = numericBoxIntensityMax.Value;

trackBarAdvancedMin.Value = trackBarAdvancedMin.Minimum = trackBarAdvancedMax.Minimum = 0;
trackBarAdvancedMax.UpDown_Increment = trackBarAdvancedMin.UpDown_Increment = numericBoxIntensityMax.Value / 100.0;
SkipEvent = false;

//作成したイメージをPseudoBitmapに変換
var pseudo = radioButtonHorizontalDefocus.Checked ? new PseudoBitmap[tLen, dLen] : new PseudoBitmap[dLen, tLen];
var mat = FormMain.Crystal.RotationMatrix * FormMain.Crystal.MatrixReal;
for (int t = 0; t < tLen; t++)
for (var d = 0; d < dLen; d++)
{
//ノーマライズ
totalImage[t][d] = Normalize(totalImage[t][d], true, true);//checkBoxNormalizeHigh.Checked, checkBoxNormalizeLow.Checked);
totalImage[t][d] = Normalize(totalImage[t][d], checkBoxIntensityMin.Checked);//checkBoxNormalizeHigh.Checked, checkBoxNormalizeLow.Checked);
//PseudoBitmapを生成
pseudo[radioButtonHorizontalDefocus.Checked ? t : d, radioButtonHorizontalDefocus.Checked ? d : t]
= new PseudoBitmap(totalImage[t][d], width)
Expand All @@ -421,22 +415,28 @@ public void SimulateHRTEM(bool realtimeMode = false)
pseudo = newPseudo;
}

SkipEvent = true;
trackBarAdvancedMax.Value = trackBarAdvancedMin.Maximum = trackBarAdvancedMax.Maximum = numericBoxIntensityMax.Value;
trackBarAdvancedMin.Value = trackBarAdvancedMin.Minimum = trackBarAdvancedMax.Minimum = 0;
trackBarAdvancedMax.UpDown_Increment = trackBarAdvancedMin.UpDown_Increment = (trackBarAdvancedMax.Value - trackBarAdvancedMin.Value) / 100.0;
SkipEvent = false;

//ScalableBoxに転送
setPseudoBitamap(pseudo);
toolStripStatusLabel1.Text += $"Drawing: {sw.ElapsedMilliseconds - temp} msec.";
TrackBarAdvancedMin_ValueChanged(new object(), 0);

}

public double[] Normalize(double[] image, bool normalizeHigh = true, bool normalizeLow = true)
public double[] Normalize(double[] image, bool normalizeLow = true)
{
double coeff = numericBoxIntensityMax.Value/ image.Max();
//if (normalizeHigh && normalizeLow)
image = image.Select(d => d * coeff).ToArray();
//else if (normalizeLow)
// image = image.Select(d => (d - min) * 1000).ToArray();
//else if (normalizeHigh)
// image = image.Select(d => d * 65535.0 / max).ToArray();
//else
// image = image.Select(d => d * 1000).ToArray();
double min = image.Min(), max = image.Max();
double destMin = numericBoxIntensityMin.Value, destMax = numericBoxIntensityMax.Value;

if (normalizeLow)
image = image.Select(d => (d - min) / (max - min) * (destMax - destMin) + destMin).ToArray();
else
image = image.Select(d => d * destMax / max).ToArray();

return image;
}
Expand Down Expand Up @@ -1045,6 +1045,8 @@ private void panel2_Paint(object sender, PaintEventArgs e)

}

private void checkBoxIntensityMin_CheckedChanged(object sender, EventArgs e) => numericBoxIntensityMin.Enabled = checkBoxIntensityMin.Checked;

private bool TrackBarAdvancedMin_ValueChanged(object sender, double value)
{
if (SkipEvent) return false;
Expand Down
Loading

0 comments on commit 321b19a

Please sign in to comment.