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.
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.
- Param > input > add an image sampler component
- Double click on the Image Sampler to toggle menu
- Set X Domain to 80
- Set Y Domain to 45
- Click on File Path
- Load up any 1920 x 1080 picture you want
- Display tab > Preview > add Custom Preview Component
- Connect the Area output C into the Image Sampler
- Connect the output of the Image Sampler into the Custom Preview S input
- 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
- Double Click on the Image Sampler
- Change the channel to Color Brightness
- Add Scaling component
- Remap the numbers so you can control the scaling.
- 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.