Jump to content

  • Log In with Google      Sign In   
  • Create Account


Question on texture


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 yasmin_bd   Members   -  Reputation: 121

Like
0Likes
Like

Posted 25 January 2013 - 11:05 AM

I need  some help about extracting vertices from an image. I have extracted the boundaries of an image from adobe photoshop as shown in the figure. I pasted it on a XZ plane ABCD as texture. Now I need to extract vertices ( for example, v1, v2 etc.) of the boundaries at different positions. How could that be done. Could any one give me some suggestions? Can I convert the boundaries to a set of connected straight
lines?



 

Attached Thumbnails

  • texturecoodinate.jpg


Sponsor:

#2 __SKYe   Members   -  Reputation: 950

Like
0Likes
Like

Posted 25 January 2013 - 06:09 PM

Ok, let's see if i understood correctly.

 

You have an image with an arbitrary size (let's say 128x256), and then you load that image in OpenGL as a texture.

Your question being, let's say you want to find the pixel at location (32, 16), in the OpenGL texture coordinates range [0.0 - 1.0].

 

If this is your question, knowing the absolute position (in pixels), you can calculate 32/128 for the X position and 16/256 for the Z position,

That will give you the values (0.25, 0.0625).

 

Keep in mind that the pixel in [0.0 - 1.0] range might not correspond exactly to the image pixel, due to floating point precision.

And of course you should substitute the image dimensions  in the example for the actual dimensions.

 

If this was not your question, than could you explain further?



#3 BornToCode   Members   -  Reputation: 904

Like
0Likes
Like

Posted 25 January 2013 - 06:53 PM

Ok, let's see if i understood correctly.
 
You have an image with an arbitrary size (let's say 128x256), and then you load that image in OpenGL as a texture.
Your question being, let's say you want to find the pixel at location (32, 16), in the OpenGL texture coordinates range [0.0 - 1.0].
 
If this is your question, knowing the absolute position (in pixels), you can calculate 32/128 for the X position and 16/256 for the Z position,
That will give you the values (0.25, 0.0625).
 
Keep in mind that the pixel in [0.0 - 1.0] range might not correspond exactly to the image pixel, due to floating point precision.
And of course you should substitute the image dimensions  in the example for the actual dimensions.
 
If this was not your question, than could you explain further?

 

I believe the Op is trying to convert the 2d image to some polygonal mesh. 



#4 __SKYe   Members   -  Reputation: 950

Like
0Likes
Like

Posted 25 January 2013 - 07:42 PM

My bad, completely wrong, but i'm still very confused, and i can't see how he is supposed to convert that to a mesh...

 

Can you explain what do you mean by "Convert the boundaries to a set of connected lines" ?

What are V1 and V2? Are they the vertices where the dotted line intersect the flowery like image?

 

If you could rephrase your question, it would help a lot, i'm completely lost...



#5 yasmin_bd   Members   -  Reputation: 121

Like
0Likes
Like

Posted 26 January 2013 - 12:20 PM

Thank you very much for taking time to answer my question.

 

I think I failed to make you understand properly due to my poor knowledge in this field.
 

I get the image. Now I need to extract boundaries from the image in terms of ( x, y, z) coordinates. The final result should be the boundary connected with a set of vertices. Yes,I  need to convert the image boundary to a polygon connected by a set of small straight lines lying on xz plane.

 

I don't have idea how to proceed. I wanted to proceed as follows. If there is any better suggestion, please let me know.

  • I would like to paste the image on some rectangle [(-1,0, -1) to (1,0, 1)] on xz plane.
  • Then I was looking for some technique which help me extract the (x, z) coordinate for a pixel value in the boundary of the image. I don't know how to do this part.
  • Then gradually connecting the coordinates to form the planar polygon.

But I don't know how to proceed. How to correspond each pixel to (x, z) coordinate. Then form the edges of the polygon.

 

I need some suggestion.



#6 KulSeran   Members   -  Reputation: 2169

Like
0Likes
Like

Posted 26 January 2013 - 03:53 PM

1) take your image, and flood-fill it (before hand in photoshop or in code) so that it's a 2 bit representation of white == object black == background.

2) scan over your image and record a list of <x,y> points that are white that have a black neighbor.

3) Now you have all the points to make your polygon. You'll need to order the points to get the outline of your object. If you want to draw it as a solid object, You'll have to decompose the final shape (looks concave to me) into convex polygons first. Something like http://www.cs.man.ac.uk/~toby/alan/software/ could help for the second part.



#7 yasmin_bd   Members   -  Reputation: 121

Like
0Likes
Like

Posted 26 January 2013 - 05:49 PM

Thank you very much for the reply.I have never done any subject like image processing and I have very little knowledge about it. I need some more clarification.

 

  • Can I floodfill using code? Please explain a bit the algorithm.
  • Suppose I have managed to extract the image in the following format: 2 bit representation of white == object black == background.Now how to proceed to step 2. i understand I need check the eight neighbours of white pixel to identify, but  how can i check the neighbours of pixel  in the code? Please clarify it by some simple line of code.
  • I don't need solid object, I just need the boundary, a white pixel may have more than one black boundary pixel. How to process this case? 

Thanks again in advance.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS