private void MeasureTrackedObject2( ITrackedObject trackedObject, MeasurementsHelper measurer, TangraConfig.PreProcessingFilter filter, bool synchronise, List<ITrackedObject> objectsInGroup, float refinedFWHM, float averageFWHM) { IImagePixel center = trackedObject.Center; int areaSize = 17; if ((objectsInGroup != null && objectsInGroup.Count > 1) || LightCurveReductionContext.Instance.NoiseMethod == TangraConfig.BackgroundMethod.Background3DPolynomial) // for double PSF fits and/or 3d polynomial background fits we need the largest area areaSize = 35; IImagePixel[] groupCenters = new IImagePixel[0]; float[] aperturesInGroup = new float[0]; if (objectsInGroup != null && objectsInGroup.Count > 1) { groupCenters = new IImagePixel[objectsInGroup.Count]; aperturesInGroup = new float[objectsInGroup.Count]; for (int i = 0; i < objectsInGroup.Count; i++) { groupCenters[i] = objectsInGroup[i].Center; aperturesInGroup[i] = objectsInGroup[i].OriginalObject.ApertureInPixels; } } int areaDigitalFilterEdge = 0; if (LightCurveReductionContext.Instance.DigitalFilter != TangraConfig.PreProcessingFilter.NoFilter) areaDigitalFilterEdge = 2; // The extra 2 pixels will be cut after the filter is applied before the measurement int centerX = (int)Math.Round(center.XDouble); int centerY = (int)Math.Round(center.YDouble); uint[,] data = m_VideoController.GetCurrentAstroImage(false).GetMeasurableAreaPixels(centerX, centerY, areaSize + areaDigitalFilterEdge); uint[,] backgroundPixels = m_VideoController.GetCurrentAstroImage(false).GetMeasurableAreaPixels(centerX, centerY, 35 + areaDigitalFilterEdge); float msrX0 = (float)trackedObject.Center.XDouble; float msrY0 = (float)trackedObject.Center.YDouble; var measuredObject = new LCMeasurement() { CurrFrameNo = (uint) m_CurrFrameNo, CurrFileName = m_CurrFileName, TargetNo = (byte) trackedObject.TargetNo, X0 = msrX0, Y0 = msrY0, PixelDataX0 = centerX, PixelDataY0 = centerY, OSDTimeStamp = m_OCRedTimeStamp, FlagsDWORD = trackedObject.GetTrackingFlags() }; IMeasurableObject measurableObject = (IMeasurableObject)trackedObject; NotMeasuredReasons rv = MeasureObject( center, data, backgroundPixels, m_VideoController.VideoBitPix, measurer, filter, LightCurveReductionContext.Instance.ReductionMethod, LightCurveReductionContext.Instance.PsfQuadratureMethod, TangraConfig.Settings.Photometry.PsfFittingMethod, trackedObject.OriginalObject.ApertureInPixels, refinedFWHM, averageFWHM, measurableObject, groupCenters, aperturesInGroup, LightCurveReductionContext.Instance.FullDisappearance); measuredObject.SetIsMeasured(rv); uint[,] pixelsToSave = trackedObject.IsOffScreen ? new uint[35, 35] // As the background may have been pre-processed for measuring, we need to take another copy for saving in the file : m_VideoController.GetCurrentAstroImage(false).GetMeasurableAreaPixels(centerX, centerY, 35); bool lockTaken = false; if (synchronise) m_WriterLock.TryEnter(ref lockTaken); try { uint flags = trackedObject.GetTrackingFlags(); measuredObject.TotalReading = (uint)Math.Round(measurer.TotalReading); measuredObject.TotalBackground = (uint)Math.Round(measurer.TotalBackground); measuredObject.PixelData = pixelsToSave; /* save the original non filtered data */ measuredObject.FlagsDWORD |= flags; measuredObject.ApertureX = measurer.XCenter; measuredObject.ApertureY = measurer.YCenter; measuredObject.ApertureSize = measurer.Aperture; m_LastTotalReading[trackedObject.TargetNo] = measuredObject.TotalReading; m_LastTotalBackground[trackedObject.TargetNo] = measuredObject.TotalBackground; m_LastApertureX[trackedObject.TargetNo] = measuredObject.ApertureX; m_LastApertureY[trackedObject.TargetNo] = measuredObject.ApertureY; m_LastApertureSize[trackedObject.TargetNo] = measuredObject.ApertureSize; m_LastOCRedTimeStamp[trackedObject.TargetNo] = measuredObject.OSDTimeStamp; LCFile.SaveOnTheFlyMeasurement(measuredObject); } finally { if (synchronise && lockTaken) m_WriterLock.Exit(); } }
private LCMeasurement ProcessSingleUnit( LCMeasurement reading, bool useLowPass, bool useLowPassDiff, int newFitMatrixSize, float newSignalAperture, bool fixedAperture, MeasurementsHelper measurer, IImagePixel[] groupCenters, float[] aperturesInGroup) { reading.ReProcessingPsfFitMatrixSize = newFitMatrixSize; TrackedObjectConfig objConfig = Footer.TrackedObjects[reading.TargetNo]; ImagePixel center = new ImagePixel(reading.X0, reading.Y0); int areaSize = groupCenters != null && groupCenters.Length > 1 ? 35 : 17; if (Context.Filter != LightCurveContext.FilterType.NoFilter) { areaSize += 2; } uint[,] data = BitmapFilter.CutArrayEdges(reading.PixelData, (35 - areaSize) / 2); var filter = TangraConfig.PreProcessingFilter.NoFilter; if (useLowPassDiff) { filter = TangraConfig.PreProcessingFilter.LowPassDifferenceFilter; } else if (useLowPass) { filter = TangraConfig.PreProcessingFilter.LowPassFilter; } NotMeasuredReasons rv = ReduceLightCurveOperation.MeasureObject( center, data, reading.PixelData, Context.BitPix, measurer, filter, Context.SignalMethod, Context.PsfQuadratureMethod, Context.PsfFittingMethod, newSignalAperture, objConfig.RefinedFWHM, Footer.RefinedAverageFWHM, reading, groupCenters, aperturesInGroup, Footer.ReductionContext.FullDisappearance); reading.SetIsMeasured(rv); reading.TotalReading = (uint)measurer.TotalReading; reading.TotalBackground = (uint)measurer.TotalBackground; reading.ApertureX = measurer.XCenter; reading.ApertureY = measurer.YCenter; reading.ApertureSize = measurer.Aperture; return(reading); }
private LCMeasurement ProcessSingleUnit( LCMeasurement reading, bool useLowPass, bool useLowPassDiff, int newFitMatrixSize, float newSignalAperture, bool fixedAperture, MeasurementsHelper measurer, IImagePixel[] groupCenters, float[] aperturesInGroup) { reading.ReProcessingPsfFitMatrixSize = newFitMatrixSize; TrackedObjectConfig objConfig = Footer.TrackedObjects[reading.TargetNo]; ImagePixel center = new ImagePixel(reading.X0, reading.Y0); int areaSize = groupCenters != null && groupCenters.Length > 1 ? 35 : 17; if (Context.Filter != LightCurveContext.FilterType.NoFilter) areaSize += 2; uint[,] data = BitmapFilter.CutArrayEdges(reading.PixelData, (35 - areaSize) / 2); var filter = TangraConfig.PreProcessingFilter.NoFilter; if (useLowPassDiff) filter = TangraConfig.PreProcessingFilter.LowPassDifferenceFilter; else if (useLowPass) filter = TangraConfig.PreProcessingFilter.LowPassFilter; NotMeasuredReasons rv = ReduceLightCurveOperation.MeasureObject( center, data, reading.PixelData, Context.BitPix, measurer, filter, Context.SignalMethod, Context.PsfQuadratureMethod, Context.PsfFittingMethod, newSignalAperture, objConfig.RefinedFWHM, Footer.RefinedAverageFWHM, reading, groupCenters, aperturesInGroup, Footer.ReductionContext.FullDisappearance); reading.SetIsMeasured(rv); reading.TotalReading = (uint)measurer.TotalReading; reading.TotalBackground = (uint)measurer.TotalBackground; reading.ApertureX = measurer.XCenter; reading.ApertureY = measurer.YCenter; reading.ApertureSize = measurer.Aperture; return reading; }