<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>Questions (new posts)</title>
		<link>http://contourtextures.wikidot.com/forum/c-82441/questions</link>
		<description>Posts in the forum category &quot;Questions&quot; - Do you need help? Is anything unclear? Ask your question here!</description>
				<copyright></copyright>
		<lastBuildDate>Wed, 22 Jul 2026 04:09:44 +0000</lastBuildDate>
		
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-1074833#post-2197679</guid>
				<title>makedist.c, width / height: Re: makedist.c, width / height</title>
				<link>http://contourtextures.wikidot.com/forum/t-1074833/makedist-c-width-height#post-2197679</link>
				<description></description>
				<pubDate>Tue, 06 Jan 2015 15:50:36 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>The bug is now fixed in the Github repo for &quot;OpenGL Insights&quot;.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-1074833#post-2197664</guid>
				<title>makedist.c, width / height: Re: makedist.c, width / height</title>
				<link>http://contourtextures.wikidot.com/forum/t-1074833/makedist-c-width-height#post-2197664</link>
				<description></description>
				<pubDate>Tue, 06 Jan 2015 15:37:18 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Oups. Sorry about that. Another case of confusion from my many years of using Matlab, which uses Fortran-style memory layout for 2D arrays. I probably tested this code only with square images, or tested it without taking enough care to use the parameters according to their names.<br /> I have this code posted to many different places, some of which are beyond my control or even unknown to me, but I will update it in where I can. Thanks for the bug report!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-1074833#post-2196144</guid>
				<title>makedist.c, width / height: makedist.c, width / height</title>
				<link>http://contourtextures.wikidot.com/forum/t-1074833/makedist-c-width-height#post-2196144</link>
				<description></description>
				<pubDate>Mon, 05 Jan 2015 00:38:50 +0000</pubDate>
				<wikidot:authorName>jimhad</wikidot:authorName>				<wikidot:authorUserId>2039109</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I believe that the parameters for width and height are switched around in makedist.c in the repository for OpenGL Insights? The calls to computegradient and edtaa3 should have the parameters switched. Since you recently updated the repository maybe you would like to fix it since it took me a couple of hours of head scratching :) Great work btw!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-374611#post-2071745</guid>
				<title>C version only: Re: C version only</title>
				<link>http://contourtextures.wikidot.com/forum/t-374611/c-version-only#post-2071745</link>
				<description></description>
				<pubDate>Sat, 19 Jul 2014 10:33:30 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>The purpose of this code is to make accurate distance fields from images with properly anti-aliased edges instead of using an oversized binary image as input and downsampling the distance field. The potential improvement over a binary transform corresponds to at least a 16-fold increase in resolution, as argued in the article in Pattern Recognition Letters, but it absolutely requires you to have area-sampled anti-aliased edges in the input image.</p> <p>If you don't have proper anti-aliasing of edges, this method won't give you a better result than any of the traditional binary transforms. Look for &quot;jump flooding&quot; or &quot;sweep-and-update&quot; in the literature and you will find a selection of suitable and fast algorithms that are far better than the brute force algorithms I have sen game developers use.</p> <p>You can resize the output distance field to a smaller size, but it does not give you quite the right result. Some detail is lost. Instead, I would suggest resizing the input image before making the distance field. Make sure to use plain bilinear resampling, no fancy &quot;bicubic&quot; or more advanced sharpening stuff, and for best results, resize the input image only in integer steps, like 2x smaller. Avoid small changes in size or weird scaling factors, as that will mess up the anti-aliasing to the point where my distance transform falls flat on its face and gives downright silly results (wobbly, distorted edges, just plain wrong distances).</p> <p>Let me know if I can be of any further assistance. I would like to see this being used more.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-374611#post-2071015</guid>
				<title>C version only: Re: C version only</title>
				<link>http://contourtextures.wikidot.com/forum/t-374611/c-version-only#post-2071015</link>
				<description></description>
				<pubDate>Thu, 17 Jul 2014 23:59:49 +0000</pubDate>
				<wikidot:authorName>hogjonny</wikidot:authorName>				<wikidot:authorUserId>1547410</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I got this working &#8230; it's WAY faster then my brute force python dfGen.</p> <p>So I my working knowledge (from game dev) is that I could take say a 2048x2048&#8230; and gen a distance field at 512x512 (or lower).</p> <p>With this C version, I seem to get the same sized df out as the input.</p> <p>Is it appropriate to re-size it myself, or does that screw up the purpose and math?</p> <p>Or, can someone help point me in the right direction for changing the output size of the df in this code snippet?</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-920471#post-2067631</guid>
				<title>Improved edtaa, aka edtaa3func: Re: Improved edtaa, aka edtaa3func</title>
				<link>http://contourtextures.wikidot.com/forum/t-920471/improved-edtaa-aka-edtaa3func#post-2067631</link>
				<description></description>
				<pubDate>Fri, 11 Jul 2014 18:58:39 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Thanks for your interest!</p> <p>1) Yes, it is possible, and I have a GPU accelerated demo here:<br /> <a href="http://webstaff.itn.liu.se/~stegu/JFA/">http://webstaff.itn.liu.se/~stegu/JFA/</a><br /> You want the version that says &quot;validation&quot; at the end. The other ones may not be AA at all. I'm not sure, and I don't quite remember, because that is old code that I have not touched for years. Note that the code is a few years old, so it does not use anything above GLSL 1.2: no integer indexing, no integer texture formats and no multiple render targets, and it is written using an old version of OpenGL (2.1) to be compatible with MacOS X in the version that was current back then. It still works, though, and it's fast. However, I never got around to implementing the more accurate distance measures. This demo is equivalent to &quot;edtaafunc&quot;, without any directional dependency for the distance, it's just a linear function of the pixel value, according to equation (1) in the article.</p> <p>2) Perhaps I can make this more clear: The (u,v) is the position of the &quot;hit point&quot; measured from the center of the pixel. The &quot;hit point&quot; (black circle) is the position where a line from the external point running orthogonal to the edge would hit the edge if it were at that exact distance, with the edge direction estimated from local derivatives. It that point is not within the pixel in question, the measure is not entirely reasonable, but if it's within the pixel, the &quot;true&quot; distance is likely to be a more accurate estimate, and is used instead.<br /> Note that the &quot;improvement&quot; from the &quot;edtaa3func&quot; to the &quot;edtaa4func&quot; versions is somewhat questionable. The extra calculations improve the average accuracy, but there are corner cases at isolated pixels where they do more damage than good. You need to test it to see if it works for the kind of input images you have.</p> <p>3) The &quot;other&quot; hint to edge direction is the direction to the closest edge pixel, which is available for pixels that are not on the edge itself. I am sorry for any confusion here. What I meant to say was that the direction to the edge pixel is a better estimate of the edge direction if the edge is far away, less accurate if the edge is close, and not applicable if the pixel is on the edge. For pixels on the edge, the derivatives is all you have. For distant pixels, the vector to the edge is a better estimate. For pixels at a distance of a few pixels or less from the edge, the derivatives may be of use to improve the estimate, but not always. I have no hard decision rule here, I can just say &quot;it depends&quot;.</p> <p>Please let me know if you have any further question. Note, however, that I am currently on vacation and may take more time than usual to respond to e-mail.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-920471#post-2065616</guid>
				<title>Improved edtaa, aka edtaa3func: Improved edtaa, aka edtaa3func</title>
				<link>http://contourtextures.wikidot.com/forum/t-920471/improved-edtaa-aka-edtaa3func#post-2065616</link>
				<description></description>
				<pubDate>Tue, 08 Jul 2014 09:54:52 +0000</pubDate>
				<wikidot:authorName>zebratov</wikidot:authorName>				<wikidot:authorUserId>1925824</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Dear Prof.Gustavson,<br /> First, I tried the jump flood, which results with no AA.<br /> Second, I have read the AA EDT in the Pattern Recognition Letters.<br /> I run some tests on the produced DT and they produce nice AA effects, with limitless resolution.<br /> My Questions :<br /> 1) Is it is possible to implement it with Jump Flooding?<br /> 2) Can you please further explain the U,V you are referring to in that paper - i.e equations (6) and its illustration Fig.4 .<br /> i.e &quot; Therefore, the local gradients were used to improve the result only at the edge and very near it, where most<br /> of the larger absolute errors were located.&quot;<br /> and in fig.4, &quot;the hit point&quot; (black circle)<br /> 3) &quot;In our experiments, using the local gradient always improved<br /> the accuracy for edge pixels, where no other edge direction information was available&quot;<br /> Can you further explain this sentence - i.e: other edge direction information .</p> <p>Thank you,<br /> Zebratov</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-605008#post-1659288</guid>
				<title>License: Re: License</title>
				<link>http://contourtextures.wikidot.com/forum/t-605008/license#post-1659288</link>
				<description></description>
				<pubDate>Wed, 19 Dec 2012 12:20:10 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>As a useful compromise between openness and attribution, I have now changed the license to MIT.<br /> Why not public domain? Well, I am somewhat reluctant to release significant amounts of non-trivial code as public domain. I like openness a lot, but I have had some bad experiences in the past where people have taken my code and put it into a product without giving me as much as a word of thanks. I have no illusions of earning any money from this, but as a researcher, I am very much into getting and giving credit where credit is due.<br /> The algorithm is described in detail in the scientific article, and it should not be a huge effort to re-implement it from the description and use it for any purpose if the MIT license doesn't cut it for you. Of course, if you have a specific use in mind, I would be happy to negotiate an individual license for your particular needs. (Don't worry, I'm cheap. I just want some level of control over where my code is used commercially.)</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-605008#post-1659236</guid>
				<title>License: License</title>
				<link>http://contourtextures.wikidot.com/forum/t-605008/license#post-1659236</link>
				<description></description>
				<pubDate>Wed, 19 Dec 2012 11:04:07 +0000</pubDate>
				<wikidot:authorName>hronet</wikidot:authorName>				<wikidot:authorUserId>1513681</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Hi</p> <p>I was wondering about the use of GNUGPL - it essentially makes it impossible to use the software in any commercial product. Would it be meaningful to change it to either public domain, the MIT License, or the zlib-license?<br /> (in descending order of usefulness)</p> <p>Thanks!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-442136#post-1374505</guid>
				<title>Unity C# version: Re: Unity C# version</title>
				<link>http://contourtextures.wikidot.com/forum/t-442136/unity-c-version#post-1374505</link>
				<description></description>
				<pubDate>Wed, 15 Feb 2012 12:56:44 +0000</pubDate>
				<wikidot:authorName>Jasper Flick</wikidot:authorName>				<wikidot:authorUserId>1304472</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Glad you appreciate it!</p> <p>I have made a unity package for it. It contains the above code, an editor class that makes an editor window for it, and the GNU GPL. You can find it, along with documentation, over at catlikecoding.com/unity/products/distance-map-generator/</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-442136#post-1372887</guid>
				<title>Unity C# version: Re: Unity C# version</title>
				<link>http://contourtextures.wikidot.com/forum/t-442136/unity-c-version#post-1372887</link>
				<description></description>
				<pubDate>Mon, 13 Feb 2012 08:11:43 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Thank you very much! It's nice to see my code being used<br /> and tweaked, and to see contour rendering catching on!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-442136#post-1371186</guid>
				<title>Unity C# version: Unity C# version</title>
				<link>http://contourtextures.wikidot.com/forum/t-442136/unity-c-version#post-1371186</link>
				<description></description>
				<pubDate>Fri, 10 Feb 2012 17:15:54 +0000</pubDate>
				<wikidot:authorName>Jasper Flick</wikidot:authorName>				<wikidot:authorUserId>1304472</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Hi!</p> <p>I'm working on a text tool for the Unity3D game engine and I included a C# version of the EDTAA algorithm to create nice distance maps from font atlases. The Generate method takes the alpha channel of a source texture and generates the distances from that, either outside, inside, or both. Beyond that, it's conceptually the same code as edtaa3 and the post process part, although I approached a few things differently.</p> <p>Though it's Unity3D specific, it shouldn't be too hard to integrate the C# code into a non-Unity project.</p> <div class="code"> <pre><code>using UnityEngine; /// &lt;summary&gt; /// Utility class for generating distance maps from anti-aliased alpha maps. /// &lt;/summary&gt; public static class CCDistanceMapGenerator { /// &lt;summary&gt; /// How to fill the RGB channels of the generated distance map /// &lt;/summary&gt; public enum RGBMode { /// &lt;summary&gt; /// Set the RGB channels to 1. /// &lt;/summary&gt; White, /// &lt;summary&gt; /// Set the RGB channels to 0. /// &lt;/summary&gt; Black, /// &lt;summary&gt; /// Set the RGB channels to the computed distance. /// &lt;/summary&gt; Distance, /// &lt;summary&gt; /// Copy the source texture's RGB channels. /// &lt;/summary&gt; Source } private class Pixel { public float alpha, distance; public Vector2 gradient; public int dX, dY; } private static int width, height; private static Pixel[,] pixels; /// &lt;summary&gt; /// Generates a distance texture from the alpha channel of a source texture. /// &lt;/summary&gt; /// &lt;param name=&quot;source&quot;&gt; /// The source texture. Alpha values of 1 are considered inside, values of 0 are considered outside, and any other values are considered /// to be on the edge. Make sure the texture is readable and not compressed. /// &lt;/param&gt; /// &lt;param name=&quot;destination&quot;&gt; /// The destination texture. Must be the same size as the source texture. /// &lt;/param&gt; /// &lt;param name=&quot;maxInside&quot;&gt; /// The maximum pixel distance measured inside the boundary, resulting in an alpha value of 1. /// If set to zero, everything inside will have an alpha value of 1. /// &lt;/param&gt; /// &lt;param name=&quot;maxOutside&quot;&gt; /// The maximum pixel distance measured outside the boundary, resulting in an alpha value of 0. /// If set to zero, everything outside will have an alpha value of 0. /// &lt;/param&gt; /// &lt;param name=&quot;postProcessDistance&quot;&gt; /// Pixel distance from the boundary which will be post-processed using the boundary gradient. /// &lt;/param&gt; /// &lt;param name=&quot;rgbMode&quot;&gt; /// How to fill the destination texture's RGB channels. /// &lt;/param&gt; public static void Generate (Texture2D source, Texture2D destination, float maxInside, float maxOutside, float postProcessDistance, RGBMode rgbMode) { if(source.height != destination.height || source.width != destination.width){ Debug.LogError(&quot;Source and destination textures must be the same size.&quot;); return; } try{ source.GetPixel(0, 0); } catch{ Debug.LogError(&quot;Source texture is not read/write enabled.&quot;); return; } width = source.width; height = source.height; pixels = new Pixel[width, height]; int x, y; float scale; Color c = rgbMode == RGBMode.White ? Color.white : Color.black; for(y = 0; y &lt; height; y++){ for(x = 0; x &lt; width; x++){ pixels[x, y] = new Pixel(); } } if(maxInside &gt; 0f){ for(y = 0; y &lt; height; y++){ for(x = 0; x &lt; width; x++){ pixels[x, y].alpha = 1f - source.GetPixel(x, y).a; } } ComputeEdgeGradients(); GenerateDistanceTransform(); if(postProcessDistance &gt; 0f){ PostProcess(postProcessDistance); } scale = 1f / maxInside; for(y = 0; y &lt; height; y++){ for(x = 0; x &lt; width; x++){ c.a = Mathf.Clamp01(pixels[x, y].distance * scale); destination.SetPixel(x, y, c); } } } if(maxOutside &gt; 0f){ for(y = 0; y &lt; height; y++){ for(x = 0; x &lt; width; x++){ pixels[x, y].alpha = source.GetPixel(x, y).a; } } ComputeEdgeGradients(); GenerateDistanceTransform(); if(postProcessDistance &gt; 0f){ PostProcess(postProcessDistance); } scale = 1f / maxOutside; if(maxInside &gt; 0f){ for(y = 0; y &lt; height; y++){ for(x = 0; x &lt; width; x++){ c.a = 0.5f + (destination.GetPixel(x, y).a - Mathf.Clamp01(pixels[x, y].distance * scale)) * 0.5f; destination.SetPixel(x, y, c); } } } else{ for(y = 0; y &lt; height; y++){ for(x = 0; x &lt; width; x++){ c.a = Mathf.Clamp01(1f - pixels[x, y].distance * scale); destination.SetPixel(x, y, c); } } } } if(rgbMode == RGBMode.Distance){ for(y = 0; y &lt; height; y++){ for(x = 0; x &lt; width; x++){ c = destination.GetPixel(x, y); c.r = c.a; c.g = c.a; c.b = c.a; destination.SetPixel(x, y, c); } } } else if(rgbMode == RGBMode.Source){ for(y = 0; y &lt; height; y++){ for(x = 0; x &lt; width; x++){ c = source.GetPixel(x, y); c.a = destination.GetPixel(x, y).a; destination.SetPixel(x, y, c); } } } pixels = null; } private static void ComputeEdgeGradients () { float sqrt2 = Mathf.Sqrt(2f); for(int y = 1; y &lt; height - 1; y++){ for(int x = 1; x &lt; width - 1; x++){ Pixel p = pixels[x, y]; if(p.alpha &gt; 0f &amp;&amp; p.alpha &lt; 1f){ // estimate gradient of edge pixel using surrounding pixels float g = - pixels[x - 1, y - 1].alpha - pixels[x - 1, y + 1].alpha + pixels[x + 1, y - 1].alpha + pixels[x + 1, y + 1].alpha; p.gradient.x = g + (pixels[x + 1, y].alpha - pixels[x - 1, y].alpha) * sqrt2; p.gradient.y = g + (pixels[x, y + 1].alpha - pixels[x, y - 1].alpha) * sqrt2; p.gradient.Normalize(); } } } } private static float ApproximateEdgeDelta (float gx, float gy, float a) { // (gx, gy) can be either the local pixel gradient or the direction to the pixel if(gx == 0f || gy == 0f){ // linear function is correct if both gx and gy are zero // and still fair if only one of them is zero return 0.5f - a; } // normalize (gx, gy) float length = Mathf.Sqrt(gx * gx + gy * gy); gx = gx / length; gy = gy / length; // reduce symmetrical equation to first octant only // gx &gt;= 0, gy &gt;= 0, gx &gt;= gy gx = Mathf.Abs(gx); gy = Mathf.Abs(gy); if(gx &lt; gy){ float temp = gx; gx = gy; gy = temp; } // compute delta float a1 = 0.5f * gy / gx; if(a &lt; a1){ // 0 &lt;= a &lt; a1 return 0.5f * (gx + gy) - Mathf.Sqrt(2f * gx * gy * a); } if(a &lt; (1f - a1)){ // a1 &lt;= a &lt;= 1 - a1 return (0.5f - a) * gx; } // 1-a1 &lt; a &lt;= 1 return -0.5f * (gx + gy) + Mathf.Sqrt(2f * gx * gy * (1f - a)); } private static void UpdateDistance (Pixel p, int x, int y, int oX, int oY) { Pixel neighbor = pixels[x + oX, y + oY]; Pixel closest = pixels[x + oX - neighbor.dX, y + oY - neighbor.dY]; if(closest.alpha == 0f || closest == p){ // neighbor has no closest yet // or neighbor's closest is p itself return; } int dX = neighbor.dX - oX; int dY = neighbor.dY - oY; float distance = Mathf.Sqrt(dX * dX + dY * dY) + ApproximateEdgeDelta(dX, dY, closest.alpha); if(distance &lt; p.distance){ p.distance = distance; p.dX = dX; p.dY = dY; } } private static void GenerateDistanceTransform () { // perform anti-aliased Euclidean distance transform int x, y; Pixel p; // initialize distances for(y = 0; y &lt; height; y++){ for(x = 0; x &lt; width; x++){ p = pixels[x, y]; p.dX = 0; p.dY = 0; if(p.alpha &lt;= 0f){ // outside p.distance = 1000000f; } else if (p.alpha &lt; 1f){ // on the edge p.distance = ApproximateEdgeDelta(p.gradient.x, p.gradient.y, p.alpha); } else{ // inside p.distance = 0f; } } } // perform 8SSED (eight-points signed sequential Euclidean distance transform) // scan up for(y = 1; y &lt; height; y++){ // |P. // |XX p = pixels[0, y]; if(p.distance &gt; 0f){ UpdateDistance(p, 0, y, 0, -1); UpdateDistance(p, 0, y, 1, -1); } // --&gt; // XP. // XXX for(x = 1; x &lt; width - 1; x++){ p = pixels[x, y]; if(p.distance &gt; 0f){ UpdateDistance(p, x, y, -1, 0); UpdateDistance(p, x, y, -1, -1); UpdateDistance(p, x, y, 0, -1); UpdateDistance(p, x, y, 1, -1); } } // XP| // XX| p = pixels[width - 1, y]; if(p.distance &gt; 0f){ UpdateDistance(p, width - 1, y, -1, 0); UpdateDistance(p, width - 1, y, -1, -1); UpdateDistance(p, width - 1, y, 0, -1); } // &lt;-- // .PX for(x = width - 2; x &gt;= 0; x--){ p = pixels[x, y]; if(p.distance &gt; 0f){ UpdateDistance(p, x, y, 1, 0); } } } // scan down for(y = height - 2; y &gt;= 0; y--){ // XX| // .P| p = pixels[width - 1, y]; if(p.distance &gt; 0f){ UpdateDistance(p, width - 1, y, 0, 1); UpdateDistance(p, width - 1, y, -1, 1); } // &lt;-- // XXX // .PX for(x = width - 2; x &gt; 0; x--){ p = pixels[x, y]; if(p.distance &gt; 0f){ UpdateDistance(p, x, y, 1, 0); UpdateDistance(p, x, y, 1, 1); UpdateDistance(p, x, y, 0, 1); UpdateDistance(p, x, y, -1, 1); } } // |XX // |PX p = pixels[0, y]; if(p.distance &gt; 0f){ UpdateDistance(p, 0, y, 1, 0); UpdateDistance(p, 0, y, 1, 1); UpdateDistance(p, 0, y, 0, 1); } // --&gt; // XP. for(x = 1; x &lt; width; x++){ p = pixels[x, y]; if(p.distance &gt; 0f){ UpdateDistance(p, x, y, -1, 0); } } } } private static void PostProcess (float maxDistance) { // adjust distances near edges based on the local edge gradient for(int y = 0; y &lt; height; y++){ for(int x = 0; x &lt; width; x++){ Pixel p = pixels[x, y]; if((p.dX == 0 &amp;&amp; p.dY == 0) || p.distance &gt;= maxDistance){ // ignore edge, inside, and beyond max distance continue; } float dX = p.dX, dY = p.dY; Pixel closest = pixels[x - p.dX, y - p.dY]; Vector2 g = closest.gradient; if(g.x == 0f &amp;&amp; g.y == 0f){ // ignore unknown gradients (inside) continue; } // compute hit point offset on gradient inside pixel float df = ApproximateEdgeDelta(g.x, g.y, closest.alpha); float t = dY * g.x - dX * g.y; float u = -df * g.x + t * g.y; float v = -df * g.y - t * g.x; // use hit point to compute distance if(Mathf.Abs(u) &lt;= 0.5f &amp;&amp; Mathf.Abs(v) &lt;= 0.5f){ p.distance = Mathf.Sqrt((dX + u) * (dX + u) + (dY + v) * (dY + v)); } } } } }</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-363559#post-1314890</guid>
				<title>help for a new programmer in this area: Re: help</title>
				<link>http://contourtextures.wikidot.com/forum/t-363559/help-for-a-new-programmer-in-this-area#post-1314890</link>
				<description></description>
				<pubDate>Sat, 26 Nov 2011 22:10:45 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>In a different thread in this forum you will find a C port of the texture creation program. It takes a grayscale TGA file as input. Please have a look at that. If that is not what you want, I must ask you to explain your problem in more detail. I still do not understand what you are trying to do.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-363559#post-1314886</guid>
				<title>help for a new programmer in this area: help</title>
				<link>http://contourtextures.wikidot.com/forum/t-363559/help-for-a-new-programmer-in-this-area#post-1314886</link>
				<description></description>
				<pubDate>Sat, 26 Nov 2011 21:44:39 +0000</pubDate>
				<wikidot:authorName>htemp</wikidot:authorName>				<wikidot:authorUserId>946731</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Bonsoir,<br /> Au départ je veux vous remercie infiniment de m'avoir aidez.<br /> Je sais que je ne devais pas me plaindre, mais je ne sais pas quoi faire, je me suis bloqué dans ce domaine : je cherche et je cherche, je lis et relis sans résultat. Je reviens vers vous tous après une longue période de vous informer que j’ai rien fait. J’ai essayé d’exécuter votre programme (texture_creation), J’ai essayé de le convertir en langage C, et je n’ai jamais arrivé.<br /> Le problème est que je n’ai pas une stratégie à suivre, je vous souhaite d’avoir me guider.<br /> Je vous remercie encore une fois.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-363559#post-1275055</guid>
				<title>help for a new programmer in this area: </title>
				<link>http://contourtextures.wikidot.com/forum/t-363559/help-for-a-new-programmer-in-this-area#post-1275055</link>
				<description></description>
				<pubDate>Thu, 06 Oct 2011 09:28:57 +0000</pubDate>
				<wikidot:authorName>htemp</wikidot:authorName>				<wikidot:authorUserId>946731</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Merci,<br /> Maintenant j'essaye de programmer votre algorithme pour générer l'image d'entrée, et celle de Green pour faire une comparaison entre les deux. Et dans le futur, je vais chercher ma méthode.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-363559#post-1274675</guid>
				<title>help for a new programmer in this area: Re: help for a new programmer in this area</title>
				<link>http://contourtextures.wikidot.com/forum/t-363559/help-for-a-new-programmer-in-this-area#post-1274675</link>
				<description></description>
				<pubDate>Wed, 05 Oct 2011 21:59:27 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I can read French. I am not good at writing it, but I can understand it<br /> well enough to work my way through shorter texts. An automatic translation<br /> also makes a lot more sense if you include your French original, so<br /> feel free to write me using either language, or both!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-363559#post-1274626</guid>
				<title>help for a new programmer in this area: Re: help for a new programmer in this area</title>
				<link>http://contourtextures.wikidot.com/forum/t-363559/help-for-a-new-programmer-in-this-area#post-1274626</link>
				<description></description>
				<pubDate>Wed, 05 Oct 2011 21:26:04 +0000</pubDate>
				<wikidot:authorName>htemp</wikidot:authorName>				<wikidot:authorUserId>946731</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Thank you very much for your answers that have been targeted.</p> <p>I have some difficulty to form sentences because I write in French after I use a translator to translate them into English, that's why you can not follow me &#8230; Even I shot it a lot information from your answers.<br /> Now I tried your method programmed to generate the input image. And do a little comparison with Green. And then I'll look for another method suitable for me.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-374611#post-1271191</guid>
				<title>C version only: Re: C version only</title>
				<link>http://contourtextures.wikidot.com/forum/t-374611/c-version-only#post-1271191</link>
				<description></description>
				<pubDate>Sat, 01 Oct 2011 11:19:19 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>The bugs I saw were not with the code. Rather, it appears that<br /> the TGA files I used for testing have been corrupted. Two have<br /> noise in some scanlines (shape2 and shape3), and one refuses<br /> to parse (shape4). The code appears to work on ATI and Nvidia<br /> hardware alike. It's not fast on weak GPUs, but it's probably<br /> still faster than doing it in software.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-374611#post-1271170</guid>
				<title>C version only: Re: C version only</title>
				<link>http://contourtextures.wikidot.com/forum/t-374611/c-version-only#post-1271170</link>
				<description></description>
				<pubDate>Sat, 01 Oct 2011 10:29:00 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Now the AA version is there too (same address). Note that the code<br /> has not been touched for some time, and that it is probably not my<br /> proudest handiwork. It was a very fast hack, but it worked and<br /> seemed to give the correct results on my Nvidia card at work.<br /> Now the result seems to be wrong for some of the test images<br /> when trying it on my ATI card at home, but I don't have the<br /> time to find the bug.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://contourtextures.wikidot.com/forum/t-374611#post-1271169</guid>
				<title>C version only: Re: C version only</title>
				<link>http://contourtextures.wikidot.com/forum/t-374611/c-version-only#post-1271169</link>
				<description></description>
				<pubDate>Sat, 01 Oct 2011 10:15:39 +0000</pubDate>
				<wikidot:authorName>stegu</wikidot:authorName>				<wikidot:authorUserId>30391</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Sorry, that was the non-AA version. Still useful, but not AA.<br /> The AA version is not online yet. I'll get back to you in a few minutes on this.</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>