Esempio n. 1
0
        private void calcStatistics_Click(object sender, EventArgs e)
        {
            VisualTask.Run(this, "Calculating statistics", log =>
            {
                for (int ch = 0; ch < 4; ch++)
                {
                    double mean, sigma;
                    currentImage.RawImage.CalcStatistics(ch, currentZoomRect.X, currentZoomRect.Y, currentZoomRect.Width, currentZoomRect.Height, out mean, out sigma);
                    var stat = string.Format("{0}: M = {1:0.0} S = {2:0.0} G = {3:0.00}", currentImage.RawImage.Color(ch),
                                             mean, sigma, sigma * sigma / (mean - 128));
                    log.TraceBold(Color.LightBlue, stat);
                }

                /*for( int ch = 0; ch < 4; ch++ ) {
                 *      var hyst = diffHystogram( currentImage.RawImage, ch );
                 *      int total = 0;
                 *      for( int i = 0; i < hyst.Length; i++ ) {
                 *          total += hyst[i];
                 *      }
                 *      int sum = 0;
                 *      int p98 = -1;
                 *      for( int i = 0; i < hyst.Length; i++ ) {
                 *          sum += hyst[i];
                 *          if( 100 * sum / total > 98 ) {
                 *              p98 = i;
                 *              break;
                 *          }
                 *      }
                 *      var stat = string.Format( "{0}: MaxDiff = {1} 98% < {2}", currentImage.RawImage.Color( ch ),
                 *          hyst.Length - 1, p98 );
                 *      log.TraceBold( Color.LightBlue, stat );
                 *  }*/
            });
        }
Esempio n. 2
0
 public static void Run(Form owner, string caption, Action <ILog> action)
 {
     using (var log = new VisualTask(owner, caption)) {
         try {
             action(log);
         } catch (OperationCanceledException) {
         } catch (Exception ex) {
             log.TraceError(ex);
         }
     }
 }
Esempio n. 3
0
 private void zoomSaveStackToPng_Click(object sender, EventArgs e)
 {
     VisualTask.Run(this, "Saving zoomed stack to PNG", log =>
     {
         foreach (var item in EnumerateImageSaveAs(currentZoomRect))
         {
             var filePath = prepareFilePath(item.FilePath, "PNG", ".png");
             item.Image.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
             log.Trace(filePath);
         }
         log.TraceFinished();
     });
 }
Esempio n. 4
0
 private void saveStackTo16BitTIFF_Click(object sender, EventArgs e)
 {
     VisualTask.Run(this, "Saving zoomed stack to 16-bit PNG", log =>
     {
         foreach (var item in EnumerateRaw(currentZoomRect))
         {
             using (var zoomed = item.RawImage.ExtractRgbImage(item.Rect)) {
                 var filePath = prepareFilePath(item.FilePath, "TIFF", ".16-bit.tif");
                 Export.Save16BitTiff(filePath, zoomed.GetRgbPixels16(), item.Rect.Width, item.Rect.Height);
                 log.Trace(filePath);
             }
         }
         log.TraceFinished();
     });
 }
Esempio n. 5
0
 private void zoomSaveStackToCFA_Click(object sender, EventArgs e)
 {
     VisualTask.Run(this, "Saving zoomed stack to CFA", log =>
     {
         foreach (var item in EnumerateRaw(currentZoomRect))
         {
             var filePath = prepareFilePath(item.FilePath, "CFA", ".cfa");
             Rectangle r  = item.Rect;
             r.Inflate(10, 10);
             using (var zoomed = item.RawImage.ExtractRawImage(r)) {
                 zoomed.SaveCFA(filePath);
             }
             log.Trace(filePath);
         }
         log.TraceFinished();
     });
 }