public void Constructor_ValueTest() { //Arrange var exposureTime = 5; var imageType = CaptureSequence.ImageTypes.BIAS; var filter = new FilterInfo("Red", 1234, 3); var binning = new BinningMode(2, 3); var exposureCount = 20; //Act var seq = new CaptureSequence(exposureTime, imageType, filter, binning, exposureCount); //Assert Assert.AreEqual(binning.X, seq.Binning.X, "Binning X value not as expected"); Assert.AreEqual(binning.Y, seq.Binning.Y, "Binning X value not as expected"); Assert.AreEqual(false, seq.Dither, "Dither value not as expected"); Assert.AreEqual(1, seq.DitherAmount, "DitherAmount value not as expected"); Assert.AreEqual(exposureTime, seq.ExposureTime, "ExposureTime value not as expected"); Assert.AreEqual(filter, seq.FilterType, "FilterType value not as expected"); Assert.AreEqual(-1, seq.Gain, "Gain value not as expected"); Assert.AreEqual(imageType, seq.ImageType, "ImageType value not as expected"); Assert.AreEqual(0, seq.ProgressExposureCount, "ProgressExposureCount value not as expected"); Assert.AreEqual(exposureCount, seq.TotalExposureCount, "TotalExposureCount value not as expected"); Assert.AreEqual(true, seq.Enabled, "Enabled value not as expected"); }
protected override void SetDefaultValues() { flatCount = 10; histogramTolerance = 0.1; histogramMeanTarget = 0.5; stepSize = 0.5; binningMode = new BinningMode(1, 1); darkFlatCount = 0; }
private static BinningMode clampRange(BinningMode value, BinningMode supported) { if ((value & supported) == value) { return(value); } return(BinningMode.Disable); }
public FakeHAL() { BitsPerPixel = 14; TEST_InterFrameInterval = 100; CCDWidth = 512; CCDHeight = 512; ImageWidth = CCDWidth; ImageHeight = CCDHeight; SupportedBinning = new BinningMode[] { BinningMode.Binning1x1 }; BinningMode = BinningMode.Binning1x1; }
// Size public void SetBinning(string binningX, string binningY) { BinningMode modeX = (BinningMode)Enum.Parse(typeof(BinningMode), binningX); BinningMode modeY = (BinningMode)Enum.Parse(typeof(BinningMode), binningY); if (IsOpen) // needed? { currentBinningX = clampRange(modeX, supportedBinning); currentBinningY = clampRange(modeY, supportedBinning); camStatus = cam.Size.Binning.Set(currentBinningX | currentBinningY); configureOutput(); } }
public void TestAddBinning() { BinningMode result = null; var binning = new BinningMode(1, 1); _mockFlatDeviceSettings.Setup(m => m.AddBrightnessInfo(It.IsAny <FlatDeviceFilterSettingsKey>(), It.IsAny <FlatDeviceFilterSettingsValue>())) .Callback((FlatDeviceFilterSettingsKey key, FlatDeviceFilterSettingsValue value) => { result = key.Binning; }); _mockProfileService.Setup(m => m.ActiveProfile.FlatDeviceSettings).Returns(_mockFlatDeviceSettings.Object); _sut.AddBinningCommand.Execute(binning); _mockFlatDeviceSettings.Verify(m => m.AddBrightnessInfo(It.IsAny <FlatDeviceFilterSettingsKey>(), It.IsAny <FlatDeviceFilterSettingsValue>()), Times.Once); Assert.That(result, Is.EqualTo(binning)); }
public void TestWizardGridMustChangeWithNewProfile() { const int gain = 30; const short position = 2; var binningMode = new BinningMode(1, 1); var settingsValue = new FlatDeviceFilterSettingsValue(0.7, 0.5); _mockProfileService .Setup(m => m.ActiveProfile.FlatDeviceSettings.GetBrightnessInfo( It.IsAny <FlatDeviceFilterSettingsKey>())).Returns(settingsValue); _mockProfileService .Setup(m => m.ActiveProfile.FlatDeviceSettings.GetBrightnessInfoBinnings()) .Returns(new List <BinningMode> { binningMode }); _mockProfileService .Setup(m => m.ActiveProfile.FlatDeviceSettings.GetBrightnessInfoGains()) .Returns(new List <int> { gain }); _mockFilterWheelSettings.Setup(m => m.FilterWheelFilters) .Returns(new ObserveAllCollection <FilterInfo> { new FilterInfo { Position = position } }); _mockFilterWheelSettings.Raise(m => m.PropertyChanged += null, new PropertyChangedEventArgs("FilterWheelFilters")); var result1 = _sut.WizardGrid; Assert.That(result1, Is.Not.Null); Assert.That(result1.Blocks.Count, Is.EqualTo(1)); Assert.That(result1.Blocks[0].Columns[0].Settings[0].Key.Position, Is.EqualTo(position)); _mockFilterWheelSettings.Setup(m => m.FilterWheelFilters) .Returns(new ObserveAllCollection <FilterInfo> { null }); _mockFilterWheelSettings.Raise(m => m.PropertyChanged += null, new PropertyChangedEventArgs("FilterWheelFilters")); var result2 = _sut.WizardGrid; Assert.That(result2, Is.Not.Null); Assert.That(result2.Blocks.Count, Is.EqualTo(1)); Assert.That(result2.Blocks[0].Columns[0].Settings[0].Key.Position, Is.Null); }
public void TestBinningModesReturnsCorrectName() { var binningMode = new BinningMode(1, 1); _mockProfileService .Setup(m => m.ActiveProfile.FlatDeviceSettings.GetBrightnessInfoBinnings()) .Returns(new List <BinningMode> { binningMode }); var result = _sut.BinningModes; Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result, Is.EquivalentTo(new List <string> { binningMode.Name })); }
public void TestWizardGridWithFilters() { const int gain = 30; const short position = 2; var binningMode = new BinningMode(1, 1); var settingsValue = new FlatDeviceFilterSettingsValue(0.7, 0.5); var settingsKey = new FlatDeviceFilterSettingsKey(position, binningMode, gain); _mockProfileService .Setup(m => m.ActiveProfile.FlatDeviceSettings.GetBrightnessInfo( It.IsAny <FlatDeviceFilterSettingsKey>())).Returns(settingsValue); _mockProfileService .Setup(m => m.ActiveProfile.FlatDeviceSettings.GetBrightnessInfoBinnings()) .Returns(new List <BinningMode> { binningMode }); _mockProfileService .Setup(m => m.ActiveProfile.FlatDeviceSettings.GetBrightnessInfoGains()) .Returns(new List <int> { gain }); _mockFilterWheelSettings.Setup(m => m.FilterWheelFilters) .Returns(new ObserveAllCollection <FilterInfo> { new FilterInfo { Position = position } }); _mockFilterWheelSettings.Raise(m => m.PropertyChanged += null, new PropertyChangedEventArgs("FilterWheelFilters")); var result = _sut.WizardGrid; Assert.That(result, Is.Not.Null); Assert.That(result.Blocks.Count, Is.EqualTo(1)); Assert.That(result.Blocks[0].Columns.Count, Is.EqualTo(2)); Assert.That(result.Blocks[0].Binning, Is.EqualTo(binningMode)); Assert.That(result.Blocks[0].Columns[0].Header, Is.EqualTo(Loc.Instance["LblFilter"])); Assert.That(result.Blocks[0].Columns[0].Settings[0].ShowFilterNameOnly, Is.True); Assert.That(result.Blocks[0].Columns[0].Settings[0].Key.Position, Is.EqualTo(position)); Assert.That(result.Blocks[0].Columns[1].Header, Is.Null); Assert.That(result.Blocks[0].Columns[1].Settings[0].ShowFilterNameOnly, Is.False); Assert.That(result.Blocks[0].Columns[1].Settings[0].Key, Is.EqualTo(settingsKey)); Assert.That(result.Blocks[0].Columns[1].Settings[0].Brightness, Is.EqualTo(settingsValue.Brightness)); Assert.That(result.Blocks[0].Columns[1].Settings[0].Time, Is.EqualTo(settingsValue.Time)); }
public Array Binning(Array data, int binx, int biny, BinningMode binningMode) { int width = data.GetLength(0); int height = data.GetLength(1); int binWidth = width / binx; int binHeight = height / biny; var result = Array.CreateInstance(typeof(int), binWidth, binHeight); for (int x = 0; x < binWidth; x++) { for (int y = 0; y < binHeight; y++) { var binBlockData = new List <int>(); for (int x2 = x * binx; x2 < x * binx + binx; x2++) { for (int y2 = y * biny; y2 < y * biny + biny; y2++) { binBlockData.Add((int)data.GetValue(x2, y2)); } } int value = 0; switch (binningMode) { case BinningMode.Sum: value = GetSum(binBlockData, binx, biny); break; case BinningMode.Median: value = GetMedian(binBlockData); break; } result.SetValue(value, x, y); } } return(result); }
public void ReduceExposureCount_ProgressReflectedCorrectly() { //Arrange var exposureTime = 5; var imageType = CaptureSequence.ImageTypes.BIAS; var filter = new FilterInfo("Red", 1234, 3); var binning = new BinningMode(2, 3); var exposureCount = 20; var seq = new CaptureSequence(exposureTime, imageType, filter, binning, exposureCount); var exposuresTaken = 5; //Act for (int i = 0; i < exposuresTaken; i++) { seq.ProgressExposureCount++; } //Assert Assert.AreEqual(exposuresTaken, seq.ProgressExposureCount, "ProgressExposureCount value not as expected"); Assert.AreEqual(exposureCount, seq.TotalExposureCount, "TotalExposureCount value not as expected"); }
public static string BinningModeToStr(BinningMode m) { string ret = VisionLabPINVOKE.BinningModeToStr((int)m); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public static void Binning(DoubleImage src, DoubleImage dest, int height, int width, BinningMode mode) { VisionLabPINVOKE.Binning__SWIG_11(DoubleImage.getCPtr(src), DoubleImage.getCPtr(dest), height, width, (int)mode); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public static void Binning(Int8Image src, Int8Image dest, char height, char width, BinningMode mode) { VisionLabPINVOKE.Binning__SWIG_2(Int8Image.getCPtr(src), Int8Image.getCPtr(dest), height, width, (int)mode); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
/// <summary> /// Computes the Histogram of a sequence of int values that are obtained /// by invoking a transform function on each element of the input sequence. /// </summary> /// <typeparam name="TSource">The type of the elements of source.</typeparam> /// <param name="source">A sequence of values to calculate the Histogram of.</param> /// <param name="binCount">The number of bins into which to segregate the data.</param> /// <param name="selector">A transform function to apply to each element.</param> /// <param name="mode">The method used to determine the range of each bin</param> /// <returns>The Histogram of the sequence of int values.</returns> public static IEnumerable <Bin> Histogram <TSource>(this IEnumerable <TSource> source, int binCount, Func <TSource, int> selector, BinningMode mode = BinningMode.Unbounded) { if (source == null) { throw new ArgumentNullException("source"); } if (selector == null) { throw new ArgumentNullException("selector"); } return(source.Select(t => selector(t)).Histogram(binCount, mode)); }
/// <summary> /// Computes the Histogram of a sequence of nullable int values. /// </summary> /// <param name="source">A sequence of nullable int values to calculate the Histogram of.</param> /// <param name="binCount">The number of bins into which to segregate the data.</param> /// <param name="mode">The method used to determine the range of each bin</param> /// <returns>The Histogram of the sequence of nullable int values.</returns> public static IEnumerable <Bin> Histogram(this IEnumerable <int?> source, int binCount, BinningMode mode = BinningMode.Unbounded) { if (source == null) { throw new ArgumentNullException("source"); } return(source.AllValues().Histogram(binCount, mode)); }
/// <summary> /// Computes the Histogram of a sequence of int values. /// </summary> /// <param name="source">A sequence of int values to calculate the Histogram of.</param> /// <param name="binCount">The number of bins into which to segregate the data.</param> /// <param name="mode">The method used to determine the range of each bin</param> /// <returns>The Histogram of the sequence of int values.</returns> public static IEnumerable <Bin> Histogram(this IEnumerable <int> source, int binCount, BinningMode mode = BinningMode.Unbounded) { if (source == null) { throw new ArgumentNullException("source"); } var minMax = source.MinMax(); var bins = BinFactory.CreateBins((double)minMax.Min, (double)minMax.Max, binCount, mode); foreach (var value in source) { var bin = bins.First(b => b.Contains((double)value)); bin.Count++; } return(bins); }
private void queryFeatures(int instanceId) { if (FProcessor[instanceId].IsOpen) { #region binning/subsampling FOutBinningXModes[instanceId].SliceCount = 0; FOutBinningYModes[instanceId].SliceCount = 0; FOutSubsamplingXModes[instanceId].SliceCount = 0; FOutSubsamplingYModes[instanceId].SliceCount = 0; int numsupported = Enum.GetValues(typeof(BinningXMode)).Length; // it's the same for all 4 enums Array bxModes = Enum.GetValues(typeof(BinningXMode)); Array byModes = Enum.GetValues(typeof(BinningYMode)); Array sxModes = Enum.GetValues(typeof(SubsamplingXMode)); Array syModes = Enum.GetValues(typeof(SubsamplingYMode)); for (int i = 0; i < numsupported; i++) { BinningXMode bx = (BinningXMode)bxModes.GetValue(i); BinningMode bmodeX = (BinningMode)Enum.Parse(typeof(BinningMode), bx.ToString()); if ((bmodeX & FProcessor[instanceId].supportedBinning) == bmodeX) { FOutBinningXModes[instanceId].Add <string>(bmodeX.ToString()); } BinningYMode by = (BinningYMode)byModes.GetValue(i); BinningMode bmodeY = (BinningMode)Enum.Parse(typeof(BinningMode), by.ToString()); if ((bmodeY & FProcessor[instanceId].supportedBinning) == bmodeY) { FOutBinningYModes[instanceId].Add <string>(bmodeY.ToString()); } SubsamplingXMode sx = (SubsamplingXMode)sxModes.GetValue(i); SubsamplingMode smodeX = (SubsamplingMode)Enum.Parse(typeof(SubsamplingMode), sx.ToString()); if ((smodeX & FProcessor[instanceId].supportedSubsampling) == smodeX) { FOutSubsamplingXModes[instanceId].Add <string>(smodeX.ToString()); } SubsamplingYMode sy = (SubsamplingYMode)syModes.GetValue(i); SubsamplingMode smodeY = (SubsamplingMode)Enum.Parse(typeof(SubsamplingMode), sy.ToString()); if ((smodeY & FProcessor[instanceId].supportedSubsampling) == smodeY) { FOutSubsamplingYModes[instanceId].Add <string>(smodeY.ToString()); } } #endregion binning/subsampling FOutgainAutoSupported[instanceId] = FProcessor[instanceId].gainAutoSupported; FOutgainBoostSupported[instanceId] = FProcessor[instanceId].gainBoostSupported; FOutWhitebalance[instanceId] = FProcessor[instanceId].whitebalanceSupported; queryRequest = false; } }
public static IEnumerable <Bin> CreateBins(double min, double max, int binCount, BinningMode mode) { if (binCount <= 0) { throw new InvalidOperationException("binCount must be greater than 0"); } if (mode == BinningMode.Unbounded) { return(CreateBinsUnbounded(min, max, binCount)); } if (mode == BinningMode.ExpandRange) { return(CreateBinsExpandRange(min, max, binCount)); } Debug.Assert(mode == BinningMode.MaxValueInclusive); return(CreateBinsMaxInclusive(min, max, binCount)); }