Hi, for a program, I need to map the location of all the back pixels in an image into some kind of structure. The program later uses the structure to select a random pixel location. It then removes the location, to prevent it being used again. The problem is, there is a huge number of black pixels (close to 40,000) so an ordinary array takes forever to search for and eliminate the "used" pixels. Is there some other "Faster" data structure?

7 Years
Discussion Span
Last Post by Xcelled194

>Is there some other "Faster" data structure?

Yeah! but tell me about your plan and currently used "data structure".

Edited by __avd: n/a


instead of saving all the pixels separately, you could instead save less arrays containing four coordinates in which between are only the same color, or as i like to call it "same-pixel-quadrants". so if you have a piece of image that's only black containing 40.000 pixels, make much less squares covering the whole piece.


I thought of that, but the program randomly picks a point, and then does a random length flood fill, removing points from the list. My thought is to make a nested array. Then the program can randomly choose a sub array, and then a point from there.... and confine itself to those points....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.