Arctic Eddie Posted September 27, 2011 Share Posted September 27, 2011 (edited) I'm going to do some dark frame noise measurements of several cameras as a function of temperature and ISO setting. I've been looking for a simple software program to display the sum of all pixel counts. However, nothing was located so it appears I'll have to learn how to write a PDN plugin. Using Code Lab, I've got the calculations performed but cannot find a way of displaying the results. Suggestions are appreciated. My code is shown below. #region UICode // Maybe something to trigger a data window #endregion void Render(Surface dst, Surface src, Rectangle rect) { Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; // ??????????????? Is this needed long redsum = 0; long grnsum = 0; long blusum = 0; ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; // Add up the data redsum = redsum + (long)CurrentPixel.R; grnsum = redsum + (long)CurrentPixel.G; blusum = redsum + (long)CurrentPixel.B; } } // Print the result someplace } Edited September 28, 2011 by Arctic Eddie Link to comment Share on other sites More sharing options...
Rick Brewster Posted September 27, 2011 Share Posted September 27, 2011 The Paint.NET effects system is not designed to support image analysis. The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Arctic Eddie Posted September 27, 2011 Author Share Posted September 27, 2011 Is there any way to print out a numerical value? Link to comment Share on other sites More sharing options...
BoltBait Posted September 27, 2011 Share Posted September 27, 2011 You may want to read this page: http://boltbait.com/pdn/codelab/help/overview.asp along with the tutorials for CodeLab. Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
Rick Brewster Posted September 28, 2011 Share Posted September 28, 2011 You'd have to print it out to a debug window or something ... System.Console.WriteLine()*, which I think you can monitor with something like Debug View ( http://technet.micro...ernals/bb896647 ). It's fine if you're just doing the analysis for your own self. Not really a good solution if you're trying to make something that other people can use. You'd be better off just writing a program from scratch to load the image and analyze its contents. You can load images pretty easily using GDI+ from System.Drawing, or WPF/WIC from System.Windows.Media.Imaging. (I recommend the latter. GDI+ is ick, for many reasons I won't go into in this fairly short reply.) * I'm not sure exactly which one DebugView can monitor. Maybe System.Console.Error.WriteLine(). Almost certainly not System.Diagnostics.Debug.WriteLine(), as that only works for debug builds. Otherwise it's a no-op. The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted September 28, 2011 Share Posted September 28, 2011 If you just want to find out the info, messagebox would be my suggestion. I believe you can call it from Codelab if you specify the full namespace: System.Windows.Forms.MessageBox.Show("click me"); Note: Don't just bung it in, or you'll have to "click me" hundreds of times put a qualifier in there (if x==100 && y ==100 then...) If you really, really need to write a string to the canvas this little effect shows you how: void Render(Surface dst, Surface src, Rectangle rect) { PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); Graphics g = new RenderArgs(dst).Graphics; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.Clip = new Region(rect); ColorBgra PC = (ColorBgra)EnvironmentParameters.PrimaryColor; SolidBrush B1 = new SolidBrush(Color.FromArgb(PC.A, PC.R, PC.G, PC.); Font F = new Font("Courier New", 8); // Copy existing image (source) to destination for(int y = rect.Top; y < rect.Bottom; y++) for (int x = rect.Left; x < rect.Right; x++) dst[x,y] = src[x,y]; Point point1 = new Point(0,0); // these work, but are not limited to the canvas // int Mx = System.Windows.Forms.Control.MousePosition.X; // int My = System.Windows.Forms.Control.MousePosition.Y; // string sX = "x:"+ Mx.ToString()+ " y:" + My.ToString(); // neither is this line limited to the canvas, but combines both coords into one string string sX = System.Windows.Forms.Cursor.Position.ToString(); g.DrawString(sX, F, B1, point1); } ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
null54 Posted September 28, 2011 Share Posted September 28, 2011 DebugView should also monitor System.Diagnostics.Trace.WriteLine() which would work in Release builds. Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait Link to comment Share on other sites More sharing options...
Arctic Eddie Posted September 28, 2011 Author Share Posted September 28, 2011 I've not been able to get any of the suggestions working due to lack of knowledge of this particular coding scheme. I've used nine other languages in my total career but have not used C# or Code Labs before. However, I did find that Irfanview has a numeric readout in the histogram feature that will do exactly what I need. I just ran the test on a Panasonic FZ50 camera and got some very confusing results in RAW versus JPG. The later behaves as expected versus ISO but the former is nearly flat above ISO 100. My measuring problem is solved but now I have a camera phenomena to tackle. Thank you all for your time and effort to help me in this endeavor. Ed Link to comment Share on other sites More sharing options...
TaintedCherub Posted December 2, 2011 Share Posted December 2, 2011 I've not been able to get any of the suggestions working due to lack of knowledge of this particular coding scheme. I've used nine other languages in my total career but have not used C# or Code Labs before. However, I did find that Irfanview has a numeric readout in the histogram feature that will do exactly what I need. I just ran the test on a Panasonic FZ50 camera and got some very confusing results in RAW versus JPG. The later behaves as expected versus ISO but the former is nearly flat above ISO 100. My measuring problem is solved but now I have a camera phenomena to tackle. Thank you all for your time and effort to help me in this endeavor. Ed The free image analysis program ImageJ, available from the NIH website http://rsbweb.nih.gov/ij/, is designed for these types of image analysis. Many plugins are available designed with academic/scientific image analysis goals in mind. Link to comment Share on other sites More sharing options...
Recommended Posts