Remove pointer from list

K

koperenkogel

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
 
K

Karl Heinz Buchegger

koperenkogel said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top