public static void GenerateImageFromLUT(FloatImg image, FloatImg zlut, float minradius, float maxradius, Vector3 pos, bool useSplineInterp, int ovs) { ImageData imgData = image.ImageData; ImageData zlutData = zlut.ImageData; QTrkDLL.GenerateImageFromLUT(ref imgData, ref zlutData, minradius, maxradius, pos, useSplineInterp, ovs); }
public FloatImg ExtractSubsection(int y, int nh) { IntPtr start = IntPtr.Add(pixels, y * 4 * w); FloatImg dst = new FloatImg(w, nh); CopyMemory(dst.pixels, start, (uint)(4 * nh * w)); return(dst); }
public void ScheduleLocalization(FloatImg img, uint frame, int zlut, uint timestamp) { ImageData d = img.ImageData; LocalizationJob job = new LocalizationJob() { frame = frame, timestamp = timestamp, zlutIndex = zlut }; QTrkDLL.QTrkScheduleLocalization(inst, d.data, d.Pitch, QTRK_PixelDataType.Float, &job); }
public FloatImg GetRadialZLUT() { int count, planes, radialsteps; QTrkDLL.QTrkGetRadialZLUTSize(inst, out count, out planes, out radialsteps); FloatImg lut = new FloatImg(radialsteps, planes * count); QTrkDLL.QTrkGetRadialZLUT(inst, lut.pixels); return(lut); }
public BeadSelectorDlg(FloatImg image, int ROI, Int2[] positions) { InitializeComponent(); if (!DesignMode) { dispImage = image.ToImage(); this.image = image; pictureBox.Image = dispImage; roiPositions = positions.ToList(); } DialogResult = System.Windows.Forms.DialogResult.Cancel; textBoxROI.Text = ROI.ToString(); }
public unsafe void CopySubimage(FloatImg dstImg, int srcx, int srcy, int dstx, int dsty, int nw, int nh) { float *src = (float *)pixels.ToPointer(); float *dst = (float *)dstImg.pixels.ToPointer(); for (int y = 0; y < nh; y++) { float *psrc = &src[w * (y + srcy) + srcx]; float *pdst = &dst[dstImg.w * (y + dsty) + dstx]; for (int x = 0; x < nw; x++) { *(pdst++) = *(psrc++); } } }
public static Int2[] FindBeads(FloatImg img, Int2 sampleCornerPos, int roi, float imgRelDist, float acceptance) { // public static extern IntPtr QTrkFindBeads(float* image, int w, int h, int smpCornerPosX, int smpCornerPosY, int roi, float imgRelDist, float acceptance); int beadCount; ImageData sampleImg = new ImageData(); ImageData imgData = img.ImageData; IntPtr beadListPtr = QTrkDLL.QTrkFindBeads(ref imgData, sampleCornerPos.x, sampleCornerPos.y, roi, imgRelDist, acceptance, out beadCount, ref sampleImg); Int2 * beadpos = (Int2 *)beadListPtr.ToPointer(); Int2[] r = new Int2[beadCount]; for (int i = 0; i < beadCount; i++) { r[i] = beadpos[i]; } QTrkDLL.QTrkFreeROIPositions(beadListPtr); return(r); }
public FloatImg[] GetRadialZLUTImages() { int count, planes, radialsteps; QTrkDLL.QTrkGetRadialZLUTSize(inst, out count, out planes, out radialsteps); IntPtr lutspace = Marshal.AllocHGlobal(sizeof(float) * count * planes * radialsteps); QTrkDLL.QTrkGetRadialZLUT(inst, lutspace); FloatImg[] luts = new FloatImg[count]; float * src = (float *)lutspace.ToPointer(); for (int i = 0; i < count; i++) { float *srcimg = &src[i * planes * radialsteps]; luts[i] = new FloatImg(radialsteps, planes, srcimg); } Marshal.FreeHGlobal(lutspace); return(luts); }
public static FloatImg RescaleAndSetLUT(QTrkInstance tracker, FloatImg original, int zplanes) { var cfg = tracker.Config; var w = cfg.config.width; var h = cfg.config.height; tracker.SetRadialZLUTSize(1, zplanes); tracker.BeginLUT(false); using (FloatImg sample = new FloatImg(w, h)) { for (int i = 0; i < zplanes; i++) { GenerateImageFromLUT(sample, original, cfg.config.ZLUT_minradius, cfg.zlut_maxradius, new Vector3(w / 2, h / 2, i / (float)zplanes * original.h), false, 1); sample.Normalize(); // if (i == zplanes/2 && jpgfile) // WriteJPEGFile(SPrintf("smp-%s",jpgfile).c_str(), img); tracker.BuildLUT(sample, i); } } tracker.FinalizeLUT(); FloatImg result = tracker.GetRadialZLUT(); return(result); }
private void buttonSelectBeads_Click(object sender, EventArgs e) { if (frameViewImage==null)return; using (var fimg = new FloatImg(frameViewImage, 0)) { var dlg = new BeadSelectorDlg.BeadSelectorDlg(fimg, Settings.ROI, beadPosList.ToArray()); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { beadPosList = dlg.ROIPositions.ToList(); Settings.ROI = dlg.ROISize; UpdateInfo(); } } }
private void buttonBuildLUT_Click(object sender, EventArgs e) { using (QTrkInstance inst = new QTrkInstance(GetTrackerConfig())) { inst.SetRadialZLUTSize(beadPosList.Count, numLUTSteps); inst.BeginLUT(true); for (int i = 0; i < numLUTSteps; i++) { string path = GetImagePath(Settings.LUTDir, i); if (!File.Exists(path)) { MessageBox.Show("File " + path + " missing"); break; } using (Bitmap bmp = new Bitmap(path)) { using (var fi = new FloatImg(bmp, 0)) { inst.ProcessLUTFrame(fi.ImageData, beadPosList.ToArray(), i); } } } inst.FinalizeLUT(); luts = inst.GetRadialZLUT(); lutViewer.LUTs = luts; } }
public static void GenerateImageFromLUT(FloatImg image, FloatImg zlut, float minradius, float maxradius, Vector3 pos, bool useSplineInterp, int ovs) { ImageData imgData= image.ImageData; ImageData zlutData=zlut.ImageData; QTrkDLL.GenerateImageFromLUT(ref imgData, ref zlutData, minradius, maxradius, pos, useSplineInterp, ovs); }
private void buttonGenerateTestLUT_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog(); if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string basePath = textLUTDir.Text; if (basePath.Length > 0) basePath += Path.DirectorySeparatorChar; using (var lut = new Bitmap(ofd.FileName)) { var cfg=GetTrackerConfig(); var cc=QTrkComputedConfig.FromConfig(cfg); FloatImg lutf = new FloatImg(lut, 0); FloatImg img = new FloatImg(cfg.width,cfg.height); for (int i = 0; i < lut.Height; i++) { QTrkUtil.GenerateImageFromLUT(img, lutf, cfg.zlut_minradius, cc.zlut_maxradius, new Vector3(cfg.width / 2, cfg.height / 2, i), false, 1); string fn = basePath + string.Format("lut{0:000}.png", i); Trace.WriteLine("Writing " + fn); using (var planeimg = img.ToImage()) planeimg.Save(fn); } lutf.Dispose(); img.Dispose(); } } }
public static void ComputeRadialProfile(float[] dst, int angularSteps, float minradius, float maxradius, Vector2 center, FloatImg src, float mean, bool normalize) { }
public static Int2[] FindBeads(FloatImg img, Int2 sampleCornerPos, int roi, float imgRelDist, float acceptance) { // public static extern IntPtr QTrkFindBeads(float* image, int w, int h, int smpCornerPosX, int smpCornerPosY, int roi, float imgRelDist, float acceptance); int beadCount; IntPtr beadListPtr = QTrkDLL.QTrkFindBeads(img.ImageData.data, img.w, img.h, sampleCornerPos.x, sampleCornerPos.y, roi, imgRelDist, acceptance, out beadCount); Int2* beadpos = (Int2*)beadListPtr.ToPointer(); Int2[] r = new Int2[beadCount]; for (int i = 0; i < beadCount; i++) r[i] = beadpos[i]; QTrkDLL.QTrkFreeROIPositions(beadListPtr); return r; }
public static void ApplyGaussianNoise(FloatImg img, float sigma) { }
public static void ApplyPoissonNoise(FloatImg img, float poissonMax, float maxValue) { ImageData imgData=img.ImageData; QTrkDLL.ApplyPoissonNoise(ref imgData, poissonMax, maxValue); }
public void SetRadialZLUT(FloatImg lut, int count, int planes) { Debug.Assert(count * planes == lut.h); QTrkDLL.QTrkSetRadialZLUT(inst, lut.pixels, count, planes); }
public void BuildLUT(FloatImg image, int plane) { ImageData data = image.ImageData; QTrkDLL.QTrkBuildLUT(inst, data.data, data.Pitch, QTRK_PixelDataType.Float, plane, null); }
public static void ComputeRadialProfile(float[] dst, int angularSteps, float minradius, float maxradius, Vector2 center, FloatImg src, float mean, bool normalize) { ImageData d = src.ImageData; QTrkDLL.ComputeRadialProfile(dst, dst.Length, angularSteps, minradius, maxradius, center, &d, mean, normalize); }
public static void ApplyPoissonNoise(FloatImg img, float poissonMax, float maxValue) { ImageData imgData = img.ImageData; QTrkDLL.ApplyPoissonNoise(ref imgData, poissonMax, maxValue); }