direction vector of pixels

will we be able to get the direction of pixels in an image,by means of a direction vector or something ???

Direction of a pixel? Interesting concept, individual pixels aren’t generally thought of having a direction. You’ll have to provide a bit more detail of what it is you mean, I think.

something like the orientation of the pixel… not very sure if such a thing will be available from an image

An orientation for a pixel makes no sense to me. A pixel is a infinitely small sample, and does not have any kind of direction.

How do you plan to use this “orientation” once you have it?

actually im trying to develop a algorithm which would help me in my work,which deals with detecting a road network from a satellite image and im using openGL for it and im relatively new to openGL.

so,i thought if there is anything like orientation,then i could use it to find the neighbouring pixel of the same or similar orientation and thus map the road stretch.

can u suggest me any other way to go abt the total process ???

Hi !

Then you would need a heightmap instead, you need to know the height of a pixel compared to the others, I guess you could use the color of a pixel to indicate the height of course.


Sounds like an intersting problem. Not sure that anyting in OpenGL can help you with this specific problem. My first thought would be, does the color of the pixels from the road stand out enough from the other areas of the satellite image that you could use a flood-fill type of algorithm to find all pixels of a similar color?

This is a problem in computer vision. What you need to do is find the average',minima’ and maxima' pixels in the candidate area. From these you have anaxis’ that can give you the angle of orientation of the object. Try it in your mind with an ellipse - it actually works

Explain a little more rome…

the problem is this…

a IKONOS satellite image of 1 meter resolution is given as input to the system. the user cliks a valid point on the road and the program registers this point. what i planned was to find the color values of the pixel and its depth…then parse thru all its immediate eight neighboring pixels to see if they are of similar color and depth,cos a road is almost uniformly colored.
this will continue till the road edge is reached or the image edge is reached.all the similar colored pixels can be stored in an array and later can be marked with a distinct color to show the road patch.

i brought in the depth concept,becos in few cases the pixel on the road and a pixel on the edge (a barrier or road marking) gave me the same RGB values even if they were visibly of different colors. so ,i thought maybe ,if the depth was the same ,then two distinct colored pixels wouldnt give similar RGB values.

as im jus starting up with openGL,i am stuck without knowing how to proceed after getting the pixel RGB values. any help ???

Thing is, this isn’t really an OpenGL problem. You are essentially performing a `flood fill’ within some RGB thresholds.

Hmmm, nice idea, but doubt the algorithm is particularly robust. Obviously depends on what the images in are like. Well the opengl bit that you are asking is simple enough. Create a window, use gldrawpixels to draw your sat pic, then glreadpixels to get rgb from the screen, or access your data directly may be easier.
oh, well you would need to change your sat pic to a usable opengl format. To draw you can either change your data in memory, or you can use begin(GL_POINT) with a point size of 1 to colour in a pixel. so long as you have an ortho display the same size as your sat pic.

Even so, this kind of thing would be best done on the CPU in an `image array’, rather than specifically with OpenGL. It would be much quicker that way as well.

I think what he essentially wants to do is find edge boundaries based on some seed point and then to retrieve the orientation of the feature. This is a difficult problem ANYWAY in computer vision. A road that is more or less a straight line (at any orientation) is the simplest case. More complicated cases include Junctions, Bends and roads in urban sprawl (distinguishing betwee the grey concrete and the grey roads!).

Might I suggest asking about this on There are people there who specialise in this kind of image processing application.

Oh, as a starter, as long as you are scanning radially away from your seed point, it is possible to measure and detected gross changes in gradient and hence to determine different `sections’ of a road (ie: the straight bit, a bendy bit, etc.). But as I say, this is a non-trivial problem.

Well the point is visualisation. Using an interactive piece of software is the best way to test your algorithms, especially in vision. Like I say it will depend greatly on the image that he gets from the sat. For all we know it coule be a black road in a white dessert. I would doubt if speed is an issue seen as he hasn’t even designed his algorithm. I still think there is nothing wrong with what he is doing.

speed is not a very big issue for now cos its just the starting stage…i jus need to show my professor that it works to some extent after which i get some breathing time to make it work that the deadline is closing in ,it would be great even if i could manage a flood fill over the road area…

can robbo get me a flood fill algorithm from the he mentioned ??

can someone get hold for me an alogorithm or code to parse thru neighboring pixels of a particular chosen pixel,which would proceed until the image edge is reached or a particular boundary is reached ???

Not too sure how you are hoping to complete a project on tracking/image processing if you can’t fingure out an algorithm to check neighbouring pixels.

x-1,y+1 x, y+1 x+1, y+1
x-1, y x, y x+1, y
x-1, y-1 x, y-1 x+1, y-1

if 0, 0 is bottom left. obviously do a check to see if x,y is a top, left, bottom or right pixel

i already have my algorithm for picking the neighbouring pixels,WORKING. but the thing is i gotto include the depth thing for each pixel in the procedure,becos of the problem i told before. thats where i m in a fix.

You could shade a 3 component vector to the pixel as an rgb triplet just the same way you apply a bump map. Now, bump maps are typically in tangent space and even object space maps would present problems under matrix operations. I wonder if you could use fragment dot products to reorient the texture vector fragment into world (or eye) space?