# Sort points based on image color

I have a grid of points and I need to sort them by the color of an image. This image contains exactly 6 colors and I need to sort this grid of points into 6 lists. Any advise?
SortListImageSample.gh (14.9 KB)

Not at a computer now but I think you can use “create set” for this

Its is more simple than that. I tested set but as you may use a jpeg there are more than 6 colors !
Points groups seems to work

But it seems you have a scale problem

Do that on the image to have the right position

SortListImageSample.gh (15.5 KB)

Then you could replace with your grid…

SortListImageSample_v2.gh (18.4 KB)

2 Likes

the maybe fastest way to solve the scaling problem could be surface closest point on the reparametrized (flat) box of the bounding box containing the points themselves

@ThomasE @inno @laurent_delrieu @siemen: Thanks! this is getting closer. I need to be able to retrieve only the points associated with a specific color. Can this be done with the Branch component? How would you do this?

Yes but you surely need to simplify the branch T !

SortListImageSample.gh (15.5 KB)

1 Like

It looks that way and perhaps if you can round color values, that would be true. But I count 211 colors.

Wow, all you guys are fast And from only a glance at the code images, more clever than me. Oh well, here it is anyway. I tried a variety of things, including points, but ended up with square surfaces.

SortListImageSample_2024Jan23a.gh (27.0 KB)

1 Like

@ThomasE you win the prize. Simple, native GH components, six colors (FSim to round colors).

Bravo Brilliant

I took another look at your code (below) because I want to remember some of its details.

At one point, I had exactly the same bits before Image Sampler, using pDecon and Bounds to ReMap points to the “0 To 1” domain. But it’s what comes after Image Sampler that blows me away. The Pt (Point) param remaps color values to X, Y and Z values in the “0 To 1” domain. WOW Who would have guessed that? Then using dupPt (removeDuplicatePts from Kangaroo2) to isolate six points representing the six unique colors is brilliant.

By the way, CullPt (Cull Duplicates) also works when ‘Leave One’ is selected.

And those six unique points are then treated as colors by Custom Preview! Wow.

I’m still not sure what FSim (Find similar member) does or how it works, though am familiar with MIndex and CSet to get branches of geometry.

Very impressive piece of work, thanks!

1 Like

No [-1 1]

1 Like

That’s even more bizarre.

By the way @laurent_delrieu, I didn’t look at your code file(s) for two reasons I saw in your images:

1. You are using the same PTComponentLibrary as @ryan.odom, which I don’t have.
2. You changed the internal domains of Image Sampler which I never do.

I’d like to know how PGroups works here, and I sorta get that it also takes advantage of the colors to points phenomenon, but I’m not going to install PTComponentLibrary to find out.

I just remembered this concept

I did find it necessary to use plugins, especially the most popular ones, although I have never found PanellingTools useful to my workflow.

Relax Kangaroo it’s native.

Interesting but I see no code in that thread? And it used GH2 in 2016 Eight years ago…