Labeling colors from Image sampler - trouble with 'list item'

hi there,

I have read about ‘list item’ being tricky to use, i think i have run into this problem with my current project.

So, here is my problem:

I want to use Image sampler to pick RGB values at given locations. Then search through that RGB list and rename the point locations with a tag using a descriptive name for the color (in place of the RGB value).

I have gotten as far as labeling the locations with the RGB value but cannot get the ‘color name’ to populate in the correct location. (as shown in the screen grabs, the image contains x3 lines of green, light green at the bottom - mid green - dark green at the top.)

My method is to use ‘member index’ to search the list for the RGB values and then replace the RGB values using ‘list item’ with color names from another list with the same indices.

that is where it all falls down. - am i using List index correctly here? is there another way to swap out values from one list with inputs from another?

An ideas would be greatly appreciated.



colour namer_small (9.4 KB)

Thanks Rickson!
i like your style.

Actually, we are close but not quite there.
I need to ref the indices of the supplied RGB values - so i can give the name to the correct RGB value.
So i want to search through the list generated by the Image sampler, find the known value and tag it with a known name.

I need to incorporate the location data of the RGB value that is generated in the image sampler.

if that makes sense?
really appreciating the help!.

Not 100% making sense.

This finds a known value and replaces with a known name.

Thanks again for your reply.

i have tweaked my example to illustrate my problem more clearly.

As you can see in the screen grab the color names are placed in locations based on the order of the
indices in the list not the location of the color found by the image sampler.

i want to see the colors named correctly as the image sampler finds them.
the RGB values in the known list will not be ordered as per the colors found by the image sampler. (in the final project there will be x256 known color names in my Known list and about x4000 colors in the base image to label with the x256 possible color names.)

Again, thanks for your time - i hope i have made myself a bit clearer this time…

x9%20colour_test%20image colour namer_x9 colour (14.4 KB)

Your colors fr the image sampler are not the same colors from your list of color names.
Compare the RGB values of both list. It seems your concept of color has very wide range of similar colors in it.
GH wants the exact value(RGB,CMYK,HSL,HSV…)to identify a color. And make sure to match your surface u&v direction to image sampler’s x&y direction.

colour namer_x9 colour (15.6 KB)

Thanks for your input HS_Kim,
i have picked through your uploaded file.

i couldn’t quite work out where the RBG data in the red group has come from.
I follow what you were saying about the having list values that match as GH will only see perfect values.
perhaps i made an error in my upload.

Any who - what i did notice is the supplied color names work in GH when you internalize them in a ‘color’ widget. that has help a great deal - the list Item seems to recognize the list correctly now.

what is the best way to check the size and location of the image being sampled in the image sampler?
i have been setting out my points base on importing the same image with a ‘file path’ but i am unsure how the two relate to each other. the image sampler gives you a pixel dimension - i am assuming it is located at 0,0 and the pixel dimensions will be the same as the import image. this could be cause for error too.

again thanks for your help - certainly making head way!

The color data from red group comes from your color name list. GH extract RGB value from color name(red = 255,0,0).
But the RGB color red from your image is 243,0,0.

Probably the easiest way is to reparameterize your referenced surface like I did in my posting and set the X and Y domain of image sampler to 0 to 1 and use the uv output values. And also you should prepare the surface which has a right UV direction to the image sampler’s XY domain.

1 Like

Hey HS_Kim,
thanks for the clarity, i understand all that now and have applied it to my larger project.
The bug i am currently dealing with is RGB values that are ever so slightly different to the known list which is causing the tag to skip an incidence. - which mean i get a name list that is shorter the RGB value list that is spat out of the image sampler.
(it would be way better if the tag output said ‘Null’ or ‘blank’ in this scenario.)

To get around the issue of the accuracy of the RGB value (captured in image sampler) I am keen to build in the ability for the tag to find the nearest RGB value in the known list and tag that.

I am going to have a think about how to do this and then post my best effort - i am anticipating failure…

thanks again for you time…