By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,158 Members | 975 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,158 IT Pros & Developers. It's quick & easy.

Remove pointer from list

P: n/a
Dear cpp-ians,

I am writing code for a image segmentation program. For this purpose I
want to make a list (or array) of all pixels and take a random pixel
out of the list. Once the pixel is handled, I want to remove it from
the list and take again a random pixel out of the new list (with the
previous pixel removed).

I have an image of 1450 x 1650 pixels. Every pixel is a pointer to a
structure:

struct group
{
float value; // the gray value of the original image
struct meta_group * group; // the image segment it belongs to
struct pixel * pixel_list; // the first pixel of a list of all pixels
of the image segment
struct pixel * edge_list; // the first pixel of a list of all border
pixels of the image segment
};

Now I want:

* to put all those pointers in a list
* take a random pointer out of the list and do some processing on it
* remove it from the list
* take a new random pointer from the list (with the previous pointer
removed).

Can anyone help me on how to program it? What function should I use to
remove the pointer from the list or array?

Thanx in advance!

Kind regards,
Stef

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
koperenkogel wrote:

Dear cpp-ians,
* to put all those pointers in a list
* take a random pointer out of the list and do some processing on it
* remove it from the list
* take a new random pointer from the list (with the previous pointer
removed).

Can anyone help me on how to program it? What function should I use to
remove the pointer from the list or array?


put all pointers into a vector
now 'shuffle' that vector, bring it into a random order (there
is an STL algorithm to do that)
and work straight to the vector using a simple loop.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #2

P: n/a
Ok, very nice idea and it works!

Thanx!

Stef

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.