Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Blackest Pixel
#2
No direct way as far as I can tell. You can use several calls with Gimp histogram, adjusting the upper limit of the range until you don't get any pixels in the range:

The call  is:
Code:
mean, std_dev, median, pixels, count, percentile = pdb.gimp_drawable_histogram(drawable, channel, start_range, end_range)

The values you are interested in are count and/or percentile (as far as I can tell, count=pixels*percentile).

You use:

Code:
_,_,_,_, count,_ = pdb.gimp_drawable_histogram(drawable, HISTOGRAM_VALUE, 0.,max)

and you try max values (with a dichotomic search you'll never need more than eight calls), something like:

Code:
def blackest(drawable):
    bot,top=0.,1.
    while top-bot>.001:
        print "%5.3f < x < %5.3f" % (bot,top)
        threshold=(top+bot)/2.
        _,_,_,_,count,_ = pdb.gimp_drawable_histogram(drawable, HISTOGRAM_VALUE, 0.,threshold)
        print "%5.3f px @ %5.3f" % (count,threshold)
        if count:
            top=threshold
        else:
            bot=threshold
    return threshold


However doing a color selection on the result may select a single pixel and may not give you the result you want. What is the whole process?
Reply


Messages In This Thread
Blackest Pixel - by Dirk - 06-09-2019, 09:13 PM
RE: Blackest Pixel - by Ofnuts - 06-10-2019, 09:09 AM
RE: Blackest Pixel - by Dirk - 06-10-2019, 12:44 PM
RE: Blackest Pixel - by Ofnuts - 06-10-2019, 01:33 PM
RE: Blackest Pixel - by Dirk - 06-10-2019, 02:33 PM

Forum Jump: