views:

52

answers:

2

can anyone help me to find out the top 1% (or say top 100 pixels)brightest pixels with their locations of a gray image in opencv. because cvMinMaxLoc() gives only brightest pixel location. Any help is greatly appreciated.

A: 

Try using cvThreshold instead.

Mark
@Mark:thresholding doesnt help,you need to find out brightest pixels and their location.
ajith
How doesn't it help? Threshold it first to boost their intensity to max, and then use your cvMinMaxLoc to find where they are.
Mark
cvMinMaxLoc gives only one brightest pixel's location,hw can i find out other loc with same intensity?
ajith
Oh.. my bad. I thought you meant that it gave all the pixels with the (same) brightest intensity. I don't know... what format are you hoping to get back? A list of x,y coordinates? Why not just use a binary threshold as I suggested, and then loop over the image however you please? Actually, if you're going to loop it, you can do the thresholding yourself at the same time.
Mark
yeah...finding (x,y)coordinates of all those brightest pixels...kind of sorting but with the locations...
ajith
i'm pretty sure I just looped it in my project.
Mark
k..can you send me that part? [email protected]
ajith
do you really want me to send you a for loop? seriously? `for(int y=0;y<height;++y){for(int x=0; x<width;++x){if(image[x][y]>threshold){do_something_with_coords(x,y);}}}`
Mark
ha ha...:)i thought yo using some fn like minmaxLoc...anyway will see,ty
ajith
+1  A: 

this is a simple yet unneficient/stupid way to do it:

for i=1:100
  get brightest pixel using cvMinMaxLoc 
  store location
  set it to a value of zero
end

if you don't mind about efficiency this should work.

you should also check cvInRangeS to find other pixels of similar values defining low and high thresholds.

dnul