Replies: 6 comments 3 replies
-
Hi @kipcole9, Sure, you can just use max() on a boolean image. In python, perhaps: # find pixels which equal a value
# image=[a,b,c] will make a three-band image with 255 in band 0 for band elements equal to a
# we want all three bands to be 255, so we need to AND all the bands together
matches = (image == [1, 2, 3]).bandand()
# you can ask max() to find up to N max points
# for large values of N (over 100? I don't know) it would probably be better to use a histogram
[value, opts] = matches.max(size=100, x_array=True, y_array=True)
coordinates = zip(opts["x_array"], opts["y_array"]) So that'll make a list of the form |
Beta Was this translation helpful? Give feedback.
-
nip4 is an easy way to experiment with these operations, eg.: Though the syntax is haskell-ish, which can be annoying. |
Beta Was this translation helpful? Give feedback.
-
Thank you John, as always. And nip4 looks great - even on a Mac. I still struggle to wrap my head around it but I'm not giving up. Can I bother you for a pseudo code version? Equality images, band-and'ing - thats all fine. But I have no idea what |
Beta Was this translation helpful? Give feedback.
-
Much clearer (for me) John, thank you very much indeed. I didn't think of using |
Beta Was this translation helpful? Give feedback.
-
I've experimented with this approach quite a bit. It seems that There would need something like an option to return only those coordinates that are actually the maximum in order for this to work for my use case I think. |
Beta Was this translation helpful? Give feedback.
-
Sometimes I just feel really stupid (nothing you can do about that!). Thanks again John. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Other then writing the image data to a binary and looping over the data, is there a more
libvips
way to ascertain what pixel coordinates match a given colour?Beta Was this translation helpful? Give feedback.
All reactions