What's new

straighten an irregularly curved line


Hans Bernhard

New Member
Messages
2
Likes
0
Imagine the picture posted is a piece of yarn...Is there a way in photoshop to "stretch" this yarn into a straight line. In other words, is there a way to copy the color gradient and apply it to a straight line with all of the relative distances between colors preserved?
 

Attachments

Hans Bernhard

New Member
Messages
2
Likes
0
at first glance this looked right but I am noticing the colors are not spaced correctly. Your line looks as if you are merely following the color changes correctly but the relative distances are off. For example, the 2 green sections at the end surround a blue section which should be much longer if this were truly a piece of string stretched into a straight line. I tried to attach below a very crude example of what I am trying to do more precisely. I just eyballed this one but you can see how the color distances are generally preserved

Color gradient test straight.jpg
 
Last edited:

IamSam

Administrator
Staff member
Administrator
Messages
19,675
Likes
12,090
Sorry Hans, I was not attempting to make it exact. I just made a quick representation and I was just seeing if this was what you were referring to. If it were, I was just going to suggest making a custom gradient to simulate the color pattern more precisely and adding it to a straight selection. It seems as though you picked up on that. Good job.
 

Tom Mann

Guru
Messages
7,223
Likes
4,342
Your problem can not be done in Photoshop with any reasonable degree of precision because PS lacks a good simple programming interface to advanced mathematical procedures. Rather, it is best done in a mathematical programming language such as Mathematica, Matlab, or any similar language that has decent graphical output capabilities.

What you want to do is closely related to a classic mathematical problem known as "rectification of a curve" (ie, finding the length of a specified section of a curve). The solution to this problem was first given in the mid-1600's (http://www.maa.org/publications/per...reasures-van-heuraets-rectification-of-curves ).

A basic summary of "rectification" is given in this Wikipedia article:
http://en.m.wikipedia.org/wiki/Arc_length

Most of the articles you will see on this topic assume that the curve is specified by analytical functions (eg, equations). However, from the way you described the problem, it sounds like you need to do it when the curve is specified by data points, eg., (x, y) coordinates, not equations. You can find quite a few articles on this by Googling {numerical rectification of a curve}. The algorithms described in these articles will, of course, have to be modified for your particular variant of the problem, ie, the segments of "different colors", but that should be relatively easy to do by anyone with a good mathematical background.

If you need this done accurately, and there are either a lot of these curves, or each one is long, I really don't see any good alternative for you. If math and mathematical programming at the junior or senior undergraduate level (in either math, physics, or engineering) is not your strong point, I would suggest that you team up with someone with those qualifications.

However, if you have to do only a small number of relatively short curves, and you can stand accuracies (ie, of the start and end points of each color segment) of order 10 or 20%, there is an old fashioned, completely manual procedure that I can describe if you are interested.

Cheers,

Tom M
 
Last edited:

Top