Grasshopper

algorithmic modeling for Rhino

hi everybody

I am checking the colors of an image from a image sampler.

I managed to get the white colors (which are points in a parcel) with this:

List<On3dPoint> catchers = new List<On3dPoint>();

    for (int i = 0; i < parcela.Count; i++)
    {
      if ((parcela[i].R.Equals(255) == true && parcela[i].G.Equals(255) == true && parcela[i].B.Equals(255) == true) && (RhUtil.RhinoPointInPlanarClosedCurve(puntos[i], perimetro) != 0))
      {
        catchers.Add(puntos[i]);
      }
    }
    captadores = catchers;


but I´d also like to extract the greyish ones

how could I code it?
it seemed that colours are like boolean values, aren´t they?

thanks



Views: 333

Replies to This Discussion

Hi Miguel,

I'm not able to test everything from the code posted... in case I miss your goal, could you please post a small definition of what you are trying to do? However, the code here should check if a RGB color is in any way "grayish" (pure white and pure black are included).

In the first part of the "if":
//checks if red, green and blue values are the same
(parcela[i].R == parcela[i].G && parcela[i].R == parcela[i].B)

otherwise, this code is a little more extensible:
//checks if saturation is less than 12%
(parcela[i].GetSaturation() < 0.12f)

Hope this helps,

- Giulio
___________________
giulio@mcneel.com
McNeel Europe, Barcelona
thanks for your quick reply!

good idea checking if RGB are same value, but I think I didn´t explain myself becase actually I have a grayscale image, like the one I´m attaching, I think it´s better to go for the GetSaturation method.

could you explain it a bit more? how could I get only the most "blackish grays"?
Attachments:
Colors are expressed in RGB in the Color struct. In this case, is it possible that you are in fact looking for the darker colors in fact? You could use this code:

//checks if brightness is less than 12%
(parcela[i].GetBrightness() < 0.12f)


- Giulio
___________________
giulio@mcneel.com
McNeel Europe, Barcelona
ok, thanks giulio!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service