Intro to Image Sampling

Image Sampling

Using Image Channels to Drive our ALgorithm

One of the best surprises about using Grasshopper is that it is very easy to implement images into our Algorithms. 

Image Sampler

The Image Sampler component is found in the main Param tab under the panel Input. When you place the image sampler in your work space, double click on it to bring up it's option. Here you see all the things you can do with it. 

The first option you have are the domains. These are important because it helps us place the image in the correct location. Since our grid is based on a surface the is 80 mm long and 45 mm tall, we have to make our domains the same. This is how the image sampler is grabbing the information. It reads the point you give it, sees where it is in space, than finds that same point in the image, than attaches that attribute to it. To put it simpler, we told it were our points are at now it will give us back a sample from that point. 


Your First Image based ALgorithm

We will use the same algorithm we did in the previous lesson. Just in case you haven't done it, Just add a surface that is 80 mm wide and 45 mm tall. Input into the Algorithm, Add the Diamond Panel component, change the U and V to a ratio that is 16 x 9, Find the center point using the Area component.

  1. Param > input > add an image sampler component
  2. Double click on the Image Sampler to toggle menu
  3. Set X Domain to 80
  4. Set Y Domain to 45
  5. Click on File Path
  6. Load up any 1920 x 1080 picture you want
  7. Display tab > Preview > add Custom Preview Component
  8. Connect the Area output C into the Image Sampler
  9. Connect the output of the Image Sampler into the Custom Preview S input
  10. Connect the output Diamonds into the Custom Preview G input

Its Already getting Beautiful 

Here all I did was up the density of my pattern and it gave me this result. Even though this is already a pretty cool result, we are barely scratching the surface. 

Remember to try to think of the logic behind all this. We are just grabbing some information and using it for other aspects of our design. In this example, we are grabbing the color of our image and using it as a color for our pattern. Now what if we use it for other attributes, like scale.

Scaling the Diamonds

The image sampler can grab any color property you want. In our first attempt it was grabbing the rgb color. For this next step I want to use the color brightness as a way to drive my scaling

  1. Double Click on the Image Sampler
  2. Change the channel to Color Brightness 
  3. Add Scaling component
  4. Remap the numbers so you can control the scaling.
  5. Connect the remapped numbers into the scaling component.  

Don't think about this Result, think about the Base you have now 

All I am doing is giving you tools that you can rearrange in your head to make millions of creative ways to approach design. Here in this picture I made an algorithm that drew a line across the image, than used the brightness channel to alter the thickness of that line. Giving me the result you see here

What If we want more color

Transferring the colors to Illustrator isn't as easy as we think. Before we were only adding single color lines and shapes, to add color into the mix, we need to learn just a little more lesson.