zveris Posted August 19, 2004 Share Posted August 19, 2004 hi, is there a way to look at pic in COP, find a pixel with specific color and move point to the uv location of that pixel? Suppose I have a grid on SOP's, where every point has custom attribute corresponding to some color. Now I want to load image sequence and the points in the grid should move to the corresponding colors in the image sequence. Any ideas highly appreciated. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted August 19, 2004 Share Posted August 19, 2004 Well there may be a better way, but here's one off the top of my head. Create two grids one with the same number of rows and columns as pixels in your image and the other as you like. Using a point sop and the pic expression assign point colours from your image onto the first grid. Then you would need to write a VOP that takes your grid and the one with the image assigned to it and compare them. For each point in your grid you would import the Cd attribute and then loop through every point in the reference grid looking for the colour Cd when you find it you import it's position and reassign your grid P to the value. Of course you would hit problems if the colour you wanted came up more than once, but I'll leave you to decide what to do in that instance. Quote Link to comment Share on other sites More sharing options...
zveris Posted August 19, 2004 Author Share Posted August 19, 2004 For each point in your grid you would import the Cd attribute and then loop through every point in the reference grid looking for the colour Cd when you find it you import it's position and reassign your grid P to the value. 13347[/snapback] Sibarrick, thanks for reply and idea. Sounds good, but could you help me out here with this looping trough the points bussines. Suppose in vex editor I put two imprt atribut nodes, to get colors from the grids, I wire them to compare node. What should I use from that point? Whcich node will make a loop trough the points? thanks again Quote Link to comment Share on other sites More sharing options...
crunch Posted August 20, 2004 Share Posted August 20, 2004 hi,is there a way to look at pic in COP, find a pixel with specific color and move point to the uv location of that pixel? Suppose I have a grid on SOP's, where every point has custom attribute corresponding to some color. Now I want to load image sequence and the points in the grid should move to the corresponding colors in the image sequence. Any ideas highly appreciated. 13346[/snapback] You might be able to use point clouds to do this. First, create a point cloud which has a point for each pixel and has the color of the pixel assigned to it. Next, for a each point in that you want to move, you can run the VEX code vector search_color; vector destP; // Query the point cloud to find the single pixel which has the color // closest to the color I'm looking for. The search radius is 10. If your color space // is all less than 10, this will find the closest point. int handle = pcopen("op:/obj/pointcloud/point1", "Cd", search_color, 10, 1); while (pciterate(handle)) { // For the point which has the color that I'm looking for, // look up it's position. pcimport(handle, "P", destP); } P = destP; Instead of searching for the point position in the cloud, you're searching for the nearest color, then looking up the position of that point and moving the point to that position. Of course, you could also "blend" the current position to the destination position (lerp). Or you could set the velocity based on the target position etc. This only works if you have a unique color for each pixel though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.