Jump to content
  • Advertisement
Sign in to follow this  

algorithm for shape boundary growing

This topic is 4338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I have a very urgent requirement as the whole validaity of my project depends on doing this correctly. I am a curve defined by a set of floating point numbers. So each x, y pair describes a point on the curve and the curve is created by simple joining these point pairs. Now, my probem is that the curve should snap to each pixel that it touches. So, if we consider the x part of the coordinates... then the points lying on the "left side" of the curve should round off to the lower value... So, if you have x value like 63.5 on the left side, it should become 63.0. and if you have points on the "right side" of the curve, it should round off to the upper value... So, if you have value like 130.5 on the right side, it should become 131.0 Similar logic should follow for the y values. My initial idea was to increment/decrement the values by 1.0 and see if that pixel lies in my region. If the pixel to the right lies in the region, then I take the floor of the value, else I take the ceiling. This worked for most of ther curves but every now and then I come across curves that does not work with this primitive algorithm. Also, there will be points that do not have the nearest pixel lying on the curve. I was wondering if there is an algorithm for growing a curve so that it snaps to the touched pixel... So basically it just grows like a bubble in all directions by the required amount. Is it possible to achieve something like this by looking at the derivative between 2 points? I have been thinking about this for a while now but am yet to come up with a good idea. So, I am turning to all you graphic gods out there for some inspiration :) Any leads or maybe reference to some C++/Java/ package that might do something like this would be really appreciated. Thanks for any help you might give me here. I would really appreciate it. xarg

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!