本文整理汇总了C#中Range.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Range.Add方法的具体用法?C# Range.Add怎么用?C# Range.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.CreateTabContainer("StromaDetection");
this.TabContainer.Enabled = true;
(new Button
{
Text = "execute cell core segmentation",
Parent = this.TabContainer,
Dock = DockStyle.Top
}).Click += delegate
{
if (null == this.DisplayedImage) return;
ProcessResult result = null;
var progressDialog = new ProgressDialog { Message = "executing cell core segmentation", ProgressBarStyle = ProgressBarStyle.Marquee, AllowCancel = false };
progressDialog.BackgroundTask += () =>
{
var segmentation = new CellCoreSegmentation();
var executionParams = new ProcessExecutionParams(this.DisplayedImage);
result = segmentation.Execute(executionParams);
};
progressDialog.CenterToScreen();
progressDialog.ShowDialog();
this.SetLayers(result.Layers.ToArray());
};
(new Button
{
Text = "execute threshold segmentation",
Parent = this.TabContainer,
Dock = DockStyle.Top
}).Click += delegate
{
if (null == this.DisplayedImage) return;
var m = new Map(this.DisplayedImage.Width, this.DisplayedImage.Height);
using (var gp = new GrayscaleProcessor(this.DisplayedImage.Clone() as Bitmap, RgbToGrayscaleConversion.Mean))
{
for (var x = 0; x < this.DisplayedImage.Width; x++)
{
for (var y = 0; y < this.DisplayedImage.Height; y++)
{
m[x, y] = gp.GetPixel(x, y) < this.threshold.Value ? 1u : 0u;
}
}
}
var layer = new ConnectedComponentCollector().Execute(m);
layer.Name = "threshold " + this.threshold.Value + " segmentation";
var layers = this.GetLayers().ToList();
layers.Add(layer);
this.SetLayers(layers.ToArray());
};
this.threshold = new NumericUpDown
{
Parent = new GroupBox
{
Parent = this.TabContainer,
Dock = DockStyle.Top,
Text = "threshold",
Height = 40
},
Dock = DockStyle.Fill,
Minimum = 0,
Maximum = 255,
Increment = 16,
Value = 128,
DecimalPlaces = 0
};
(new Button
{
Text = "display edges",
Parent = this.TabContainer,
Dock = DockStyle.Top
}).Click += delegate
{
this.SetDisplayedImage(this.edges);
};
(new Button
{
Text = "execute edge detection",
Parent = this.TabContainer,
Dock = DockStyle.Top
}).Click += delegate
{
if (null == this.stainH || null == this.stainE) return;
this.responseH = Filtering.ExecuteSobel(this.stainH);
this.responseE = Filtering.ExecuteSobel(this.stainE);
var substracted = new double[this.responseH.Size.Width, this.responseH.Size.Height];
var substractedRange = new Range<double>();
for (var x = 0; x < this.responseH.Size.Width; x++)
{
for (var y = 0; y < this.responseH.Size.Height; y++)
{
var value = Math.Max(0, this.responseE.Gradient[x, y] - this.responseH.Gradient[x, y]);
substracted[x, y] = value;
substractedRange.Add(value);
}
//.........这里部分代码省略.........
示例2: Main
private static void Main(string[] args)
{
#region init
if (0 == args.Length)
{
Console.WriteLine("no slide name");
return;
}
var slideName = args[0];
var processinHelper = new Processing(slideName);
var slide = processinHelper.Slide;
#endregion init
TiledProcessInformation<uint[]> haematoxylinHistogram;
TiledProcessInformation<uint[]> eosinHistogram;
if (!File.Exists(processinHelper.DataPath + "haematoxylinHistogram.tpi") || !File.Exists(processinHelper.DataPath + "eosinHistogram.tpi"))
{
if (!Directory.Exists(processinHelper.DataPath + "deconvolution")) Directory.CreateDirectory(processinHelper.DataPath + "deconvolution");
var tissueData = TiledProcessInformation<bool>.FromFile(processinHelper.DataPath + "tissueData.tpi");
haematoxylinHistogram = new TiledProcessInformation<uint[]>(tissueData.Partitioner, tissueData.WsiUri);
eosinHistogram = new TiledProcessInformation<uint[]>(tissueData.Partitioner, tissueData.WsiUri);
var partitioner = tissueData.Partitioner;
var dict = new Dictionary<Point, WsiRect>();
foreach (var tile in tissueData.Partitioner)
dict.Add(tissueData.Partitioner.CurrentIndices, tile);
var stopwatch = new Stopwatch();
foreach (var tile in partitioner)
{
var tissueTile = dict[partitioner.CurrentIndices];
if (!tissueData[tissueTile]) continue;
stopwatch.Start();
using (var tileImage = slide.GetImagePart(tile))
{
var hHistogramValue = new uint[256];
var hValues = new List<double>();
using (var gpH = new ColorDeconvolution().Get1stStain(tileImage, ColorDeconvolution.KnownStain.HaematoxylinEosin))
{
foreach (var intensity in gpH.GetPixels())
{
hHistogramValue[intensity]++;
hValues.Add(intensity);
}
haematoxylinHistogram.AddDataToCurrentTile(hHistogramValue);
gpH.Dispose();
gpH.Bitmap.Save(processinHelper.DataPath + "deconvolution\\" + partitioner.CurrentIndices + ".h.png");
}
var eHistogramValue = new uint[256];
var eValues = new List<double>();
using (var gpE = new ColorDeconvolution().Get2ndStain(tileImage, ColorDeconvolution.KnownStain.HaematoxylinEosin))
{
foreach (var intensity in gpE.GetPixels())
{
eHistogramValue[intensity]++;
eValues.Add(intensity);
}
eosinHistogram.AddDataToCurrentTile(eHistogramValue);
gpE.Dispose();
gpE.Bitmap.Save(processinHelper.DataPath + "deconvolution\\" + partitioner.CurrentIndices + ".e.png");
}
NumericVector hHistogram = RConnector.Engine.CreateNumericVector(hValues);
RConnector.Engine.SetSymbol("hHistogram", hHistogram);
NumericVector eHistogram = RConnector.Engine.CreateNumericVector(eValues);
RConnector.Engine.SetSymbol("eHistogram", eHistogram);
var handle = RConnector.StartOutput();
RConnector.Engine.Evaluate("hist(eHistogram, col=rgb(1,0,0,0.5),xlim=c(0,255), main=\"" + partitioner.CurrentIndices + "\", xlab=\"HE\")");
RConnector.Engine.Evaluate("hist(hHistogram, col=rgb(0,0,1,0.5), add=T)");
var output = RConnector.EndOutput(handle);
output.Save(processinHelper.DataPath + "deconvolution\\histogram" + partitioner.CurrentIndices + ".png");
}
stopwatch.Stop();
Console.WriteLine(partitioner.CurrentIndices + ":" + (stopwatch.ElapsedMilliseconds / 1000d) + "s");
stopwatch.Reset();
}
haematoxylinHistogram.ToFile(processinHelper.DataPath + "haematoxylinHistogram.tpi");
eosinHistogram.ToFile(processinHelper.DataPath + "eosinHistogram.tpi");
}
else
{
haematoxylinHistogram = TiledProcessInformation<uint[]>.FromFile(processinHelper.DataPath + "haematoxylinHistogram.tpi");
eosinHistogram = TiledProcessInformation<uint[]>.FromFile(processinHelper.DataPath + "eosinHistogram.tpi");
}
var hRange = new Range<uint>();
foreach (var tile in haematoxylinHistogram.Partitioner)
{
if (null == haematoxylinHistogram[tile]) continue;
uint sum = 0;
for (uint i = 0; i < 256; i++)
{
sum += haematoxylinHistogram[tile][i] * (255 - i);
}
hRange.Add(sum);
}
Func<uint[], Color> h2pixel = h =>
{
if (null == h) return Color.Gray;
uint sum = 0;
for (uint i = 0; i < 256; i++)
{
//.........这里部分代码省略.........
示例3: processInput
private static void processInput()
{
int Radius = 2;
int NoiseLevel = 10;
Console.WriteLine("Processing Input...");
foreach (var import in importItems)
{
Console.WriteLine();
Console.WriteLine(import.FileName);
Console.WriteLine("Slide extrahieren...");
var processingHelper = new Processing(import.FileName);
var slide = processingHelper.Slide;
Console.WriteLine("Ausschnitt aus Slide extrahieren mit originaler Auflösung...");
int partImageWidth = import.LowerRight.X - import.UpperLeft.X;
int partImageHeight = import.LowerRight.Y - import.UpperLeft.Y;
Bitmap partImage = slide.GetImagePart(
import.UpperLeft.X, import.UpperLeft.Y,
partImageWidth, partImageHeight,
partImageWidth, partImageHeight
);
#region global tissue detection
Console.WriteLine("Gewebe suchen und in separatem Layer speichern...");
var bitmapProcessor = new BitmapProcessor(partImage);
ObjectLayer overviewLayer = new TissueDetector().Execute(bitmapProcessor, Radius, NoiseLevel);
bitmapProcessor.Dispose();
Console.WriteLine("Gewebe-Layer in Ausschnitt zeichnen + speichern...");
DrawObjectsToImage(partImage, overviewLayer, Color.Black);
partImage.Save(processingHelper.DataPath + "ImagePartTissue.png");
#endregion global tissue detection
#region Deconvolution
Console.WriteLine("Execute deconvolution 3...");
var gpX = new ColorDeconvolution().Get3rdStain(partImage, ColorDeconvolution.KnownStain.HaematoxylinEosin);
gpX.Dispose();
Bitmap gpX_bmp = gpX.Bitmap;
gpX_bmp.Save(processingHelper.DataPath + "ImagePartColor3.png");
Console.WriteLine("Execute deconvolution 2...");
var gpE = new ColorDeconvolution().Get2ndStain(partImage, ColorDeconvolution.KnownStain.HaematoxylinEosin);
gpE.Dispose();
Bitmap gpE_bmp = gpE.Bitmap;
gpE_bmp.Save(processingHelper.DataPath + "ImagePartColor2.png");
Console.WriteLine("Execute deconvolution 1...");
var gpH = new ColorDeconvolution().Get1stStain(partImage, ColorDeconvolution.KnownStain.HaematoxylinEosin);
gpH.Dispose();
Bitmap gpH_bmp = gpH.Bitmap;
gpH_bmp.Save(processingHelper.DataPath + "ImagePartColor1.png");
#endregion Deconvolution
#region execute edge detection
Console.WriteLine("Execute edge detection...");
SobelResponse responseH = Filtering.ExecuteSobel(gpH_bmp);
SobelResponse responseE = Filtering.ExecuteSobel(gpE_bmp);
var substracted = new double[responseH.Size.Width, responseH.Size.Height];
var substractedRange = new Range<double>();
for (var x = 0; x < responseH.Size.Width; x++)
{
for (var y = 0; y < responseH.Size.Height; y++)
{
var value = Math.Max(0, responseE.Gradient[x, y] - responseH.Gradient[x, y]);
substracted[x, y] = value;
substractedRange.Add(value);
}
}
double[,] nonMaximumSupression = Filtering.ExecuteNonMaximumSupression(substracted, responseE.Orientation);
Bitmap edges = Visualization.Visualize(nonMaximumSupression, Visualization.CreateColorizing(substractedRange.Maximum));
edges.Save(processingHelper.DataPath + "ImagePartEdges.png");
#endregion execute edge detection
exportItems.Add(
new Ausgabe {
Identify = import.Identify,
Result = false,
Message = "kein Fehler"
}
);
}
}
示例4: UpdateActualRange
/// <summary>
/// Updates the actual range displayed on the axis.
/// </summary>
private void UpdateActualRange()
{
Action action = () =>
{
Range<IComparable> dataRange = new Range<IComparable>();
if (ProtectedMaximum == null || ProtectedMinimum == null)
{
if (Orientation == AxisOrientation.None)
{
if (ProtectedMinimum != null)
{
this.ActualRange = OverrideDataRange(new Range<IComparable>(ProtectedMinimum, ProtectedMinimum));
}
else
{
this.ActualRange = OverrideDataRange(new Range<IComparable>(ProtectedMaximum, ProtectedMaximum));
}
}
else
{
IEnumerable<Range<IComparable>> values =
this.RegisteredListeners
.OfType<IRangeProvider>()
.Select(rangeProvider => rangeProvider.GetRange(this));
foreach (Range<IComparable> range in values)
{
dataRange = dataRange.Add(range);
}
this.ActualRange = OverrideDataRange(dataRange);
}
}
else
{
this.ActualRange = new Range<IComparable>(ProtectedMinimum, ProtectedMaximum);
}
};
// Repeat this after layout pass.
if (this.ActualLength == 0.0)
{
#pragma warning disable 4014
this.Dispatcher.RunAsync(CoreDispatcherPriority.High, new DispatchedHandler(action));
#pragma warning restore 4014
}
action();
}
示例5: UpdateActualRange
/// <summary>
/// Updates the actual range displayed on the axis.
/// </summary>
private void UpdateActualRange()
{
Action action = () =>
{
Range<IComparable> dataRange = new Range<IComparable>();
if (ProtectedMaximum == null || ProtectedMinimum == null)
{
if (Orientation == AxisOrientation.None)
{
if (ProtectedMinimum != null)
{
this.ActualRange = OverrideDataRange(new Range<IComparable>(ProtectedMinimum, ProtectedMinimum));
}
else
{
this.ActualRange = OverrideDataRange(new Range<IComparable>(ProtectedMaximum, ProtectedMaximum));
}
}
else
{
IEnumerable<Range<IComparable>> values =
this.RegisteredListeners
.OfType<IRangeProvider>()
.Select(rangeProvider => rangeProvider.GetRange(this));
foreach (Range<IComparable> range in values)
{
dataRange = dataRange.Add(range);
}
this.ActualRange = OverrideDataRange(dataRange);
}
}
else
{
this.ActualRange = new Range<IComparable>(ProtectedMinimum, ProtectedMaximum);
}
};
action();
}