Image Averaging in C# - Grasshopper2024-03-29T12:19:46Zhttps://www.grasshopper3d.com/forum/topics/image-averaging-in-c?commentId=2985220%3AComment%3A1779758&feed=yes&xn_auth=noFantastic! :) I don't know an…tag:www.grasshopper3d.com,2017-07-06:2985220:Comment:17797632017-07-06T19:41:02.072ZWP Leehttps://www.grasshopper3d.com/profile/WeiPienLee
Fantastic! :) I don't know any better, had to process a lot of images and videos in my life. Interpolation also include, check. Tnx
Fantastic! :) I don't know any better, had to process a lot of images and videos in my life. Interpolation also include, check. Tnx I've never once used Image in…tag:www.grasshopper3d.com,2017-07-06:2985220:Comment:17797582017-07-06T19:09:34.858ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>I've never once used Image in my life. I guess it makes sense if all you want to do is render images to the screen.</p>
<p></p>
<p>Incidentally, if you're doing a lot of pixel access stuff, GH_MemoryBitmap is way faster than GetPixel/SetPixel. Also harder to use, but you can get orders of magnitude performance increase.</p>
<p>I've never once used Image in my life. I guess it makes sense if all you want to do is render images to the screen.</p>
<p></p>
<p>Incidentally, if you're doing a lot of pixel access stuff, GH_MemoryBitmap is way faster than GetPixel/SetPixel. Also harder to use, but you can get orders of magnitude performance increase.</p> Yes, that was the case. I got…tag:www.grasshopper3d.com,2017-07-06:2985220:Comment:17796062017-07-06T17:23:55.307ZWP Leehttps://www.grasshopper3d.com/profile/WeiPienLee
Yes, that was the case. I got it to work with bitmap type. I still find it weird that the image type doesn't have a way to access the data (raw or not). I could be wrong but it's definitively not obvious on the ms msdn class webpage.
Yes, that was the case. I got it to work with bitmap type. I still find it weird that the image type doesn't have a way to access the data (raw or not). I could be wrong but it's definitively not obvious on the ms msdn class webpage. I think the problem here is o…tag:www.grasshopper3d.com,2017-07-06:2985220:Comment:17796652017-07-06T17:08:39.257ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>I think the problem here is one of inheritance. Image is the more generic type, while Bitmap derives from Image. Images can be WMF and EMF files as well, and those are vector based formats. Bitmaps deal strictly with pixels.</p>
<p></p>
<p>The FromFile method is actually defined on Image, not Bitmap, and as such it returns an Image type. Since an Image doesn't know anything about pixels, it doesn't provide the GetPixel/SetPixel functionality.</p>
<p>I think the problem here is one of inheritance. Image is the more generic type, while Bitmap derives from Image. Images can be WMF and EMF files as well, and those are vector based formats. Bitmaps deal strictly with pixels.</p>
<p></p>
<p>The FromFile method is actually defined on Image, not Bitmap, and as such it returns an Image type. Since an Image doesn't know anything about pixels, it doesn't provide the GetPixel/SetPixel functionality.</p> given the conversation above,…tag:www.grasshopper3d.com,2017-07-06:2985220:Comment:17797392017-07-06T16:23:07.841ZWP Leehttps://www.grasshopper3d.com/profile/WeiPienLee
<p>given the conversation above, it might be time to get rid of the "var" to protect myself;)</p>
<p>var are type placeholders in C# and therefore i didn't know that a got a return image instead. Also I didn't instantiate so "new" might also be the problem.</p>
<p></p>
<p>As always, tnx</p>
<p>given the conversation above, it might be time to get rid of the "var" to protect myself;)</p>
<p>var are type placeholders in C# and therefore i didn't know that a got a return image instead. Also I didn't instantiate so "new" might also be the problem.</p>
<p></p>
<p>As always, tnx</p> tnx, i didn't pay attention e…tag:www.grasshopper3d.com,2017-07-06:2985220:Comment:17797362017-07-06T16:19:27.809ZWP Leehttps://www.grasshopper3d.com/profile/WeiPienLee
<p>tnx, i didn't pay attention enough about the return value</p>
<p>tnx, i didn't pay attention enough about the return value</p> In think the two problems mig…tag:www.grasshopper3d.com,2017-07-06:2985220:Comment:17797332017-07-06T15:28:46.291ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>In think the two problems might be related. Instead of using var, specifically set the type of <em>im</em> to be a Bitmap. (You may also want to import the System.Drawing namespace)</p>
<blockquote><p>Bitmap im = new Bitmap("filename");</p>
</blockquote>
<p>In think the two problems might be related. Instead of using var, specifically set the type of <em>im</em> to be a Bitmap. (You may also want to import the System.Drawing namespace)</p>
<blockquote><p>Bitmap im = new Bitmap("filename");</p>
</blockquote> FromFile returns an Image typ…tag:www.grasshopper3d.com,2017-07-06:2985220:Comment:17796352017-07-06T15:24:43.010ZVicente Solerhttps://www.grasshopper3d.com/profile/VicenteSoler
<p><em>FromFile</em> returns an <em>Image</em> type. <em>GetPixel</em> is part of the <em>Bitmap</em> type.</p>
<p>There are 3 constructors to create a <em>Bitmap</em> from an <em>Image</em>:</p>
<p><a href="https://msdn.microsoft.com/en-us/library/system.drawing.bitmap" target="_blank" rel="nofollow">https://msdn.microsoft.com/en-us/library/system.drawing.bitmap</a>(v=vs.110).aspx</p>
<p></p>
<p>There's another one that allows you to create a Bitmap directly from a file.</p>
<p><em>FromFile</em> returns an <em>Image</em> type. <em>GetPixel</em> is part of the <em>Bitmap</em> type.</p>
<p>There are 3 constructors to create a <em>Bitmap</em> from an <em>Image</em>:</p>
<p><a href="https://msdn.microsoft.com/en-us/library/system.drawing.bitmap" target="_blank" rel="nofollow">https://msdn.microsoft.com/en-us/library/system.drawing.bitmap</a>(v=vs.110).aspx</p>
<p></p>
<p>There's another one that allows you to create a Bitmap directly from a file.</p> Anyone knows why the method G…tag:www.grasshopper3d.com,2017-07-06:2985220:Comment:17795812017-07-06T13:47:09.960ZWP Leehttps://www.grasshopper3d.com/profile/WeiPienLee
<p>Anyone knows why the method GetPixel is not available when developing a GH add-on?</p>
<p>I've used the latest rhino visual studio wizard to setup a GH add-on solution and use the assemblies listed below to create a custom component. There are 2 issues:</p>
<ol>
<li>VS wants to simplify the member access of the "Bitmap" to the "Image" class</li>
<li>GetPixel method is not recognized.</li>
</ol>
<blockquote><p>using System;<br></br>using System.Collections.Generic;<br></br>using…</p>
</blockquote>
<p>Anyone knows why the method GetPixel is not available when developing a GH add-on?</p>
<p>I've used the latest rhino visual studio wizard to setup a GH add-on solution and use the assemblies listed below to create a custom component. There are 2 issues:</p>
<ol>
<li>VS wants to simplify the member access of the "Bitmap" to the "Image" class</li>
<li>GetPixel method is not recognized.</li>
</ol>
<blockquote><p>using System;<br/>using System.Collections.Generic;<br/>using Grasshopper;<br/>using Grasshopper.Kernel;<br/>using Rhino.Geometry;<br/>using Grasshopper.Kernel.Types;</p>
<p>...</p>
<p> var im = System.Drawing.Bitmap.FromFile("some_filename");</p>
<p> var color = im.GetPixel(1,1);</p>
</blockquote> Thank you so much! I am learn…tag:www.grasshopper3d.com,2016-11-16:2985220:Comment:16403452016-11-16T03:27:26.305ZCC Chianghttps://www.grasshopper3d.com/profile/CCChiang
<p>Thank you so much! I am learning C# - thus the basic errors. We'll use the corrected script for now and work on applying image transformations. Thanks again!</p>
<p>Thank you so much! I am learning C# - thus the basic errors. We'll use the corrected script for now and work on applying image transformations. Thanks again!</p>