0

I'm having problems using pdb.gimp_by_color_select in Gimp

I've already looked at this question

Here's what I have:

# duplicate layer
duplicate_layer(image, "temp")
tempLayer = pdb.gimp_image_get_active_layer(image)
colour = (0,0,0)
operation = 0 
pdb.gimp_selection_none(tempLayer)
pdb.gimp_by_color_select(tempLayer, colour, 0, operation, True, False, 0, True)

Only it doesn't select any of the black pixels in the newly duplicated templayer as I would expect it.

Here's a snippet of the image

enter image description here

The lines are not true black (0,0,0) but I do an auto levels

# Auto layers
pdb.gimp_drawable_levels_stretch(tempLayer)

on the image beforehand

Ghoul Fool
  • 6,249
  • 10
  • 67
  • 125
  • Works for me (Gimp 2.10.14). Since you are using a threshold of zero and the composite image, have you checked that the composite image has indeed completely black pixels? Otherwise can you post the layer (or an extract) as a PNG? And do you really mean to use the composite image and not the layer? It is also best to use CHANNEL_OP_REPLACE instead of empty+CHANNEL_OP_ADD. – xenoid Mar 09 '20 at 15:04

1 Answers1

0

If you look at the picture histogram, the "black" is actually a fairly wide range, from 40 to 100 with a peak around 75:

enter image description here

And even after a level-stretch, most of your black pixels are still not completely black:

enter image description here

You would get a better result by thresholding the image around 100, if necessary using another copy of the layer (a selection applies to any any layer of the image, regardless of the layer used to obtain it).

xenoid
  • 8,396
  • 3
  • 23
  • 49