Image Sampling using Grasshopper!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] whatever you're watching the Aussie beam guru and today we're covering how to sample images using grasshopper in runner so previously I've actually covered some image sampling techniques in dynamo and Revit and I will revisit these as well with a bit more knowledge that I have now but today we're looking at the alternative method in grasshopper which is much more effective in my experience so I guess I'm why sample images I'll just quickly touch on some reasons why you might do this so just it's pretty obvious to most people but an image basically represents a set of pixels which is really like a 3d matrix of data each pixel contains such starters hue saturation and brightness and also red green blue channels and the Alpha value in some cases as well as this images can represent data so you can use maps for example depth maps or also heat maps or temperature maps so it's really valuable sometimes to be able to interpret in the image and extrapolate particular data out of its pixels in order to make sense of this from a design perspective and as well as this we can obviously do things like surface transpositions so taking data and applying it to a surface such as a facade so you can see a lot of examples here I'm one of which people will look at today which is the protrusion of elements from a surface based on a depth map I'll be using Renault 5 today I believe that Renault sticks will work similarly I hope to be in runner 6 soon I had a few people criticizing and commenting on the fact I'm using around a 5 so bear with me and I'll being Ronnie 6 as soon as possible today's sample we're just going to use a depth map and the image of the Mona Lisa so if you look up depth map Mona Lisa you'll you'll find this image on the right and obviously the one on the left is in a lot of places so we're going to use this to apply depth to an image and also process some of the data in a few different ways so without further ado we'll just jump into Runner and a grasshopper so I've just got a new Rhino file here and I've just opened up grasshopper by typing in a grasshopper in the command bar so let's get started so the first thing we're going to do is just build an origin point so I'm just going to go to construct a point and by default this should come with XYZ at 0 and you can see we've got a point in Rhino now I will expand the run I canvass soon what we need to do now is we've trying to set up a rectangular array so there'll be a few things we need to establish this array so we need the geometry which in this case is our point we need our cell and we need XY counter so currently our geometry you'll see is interpreting a XY count of three and six and the cell is currently just a ten by five rectangle let's actually create a rectangle that has controllable size essentially this is going to be our pixel per se so we're going to create a rectangle and we're going to feed this in as our cell and obviously we need to control some of the aspects of this rectangle so let's just make it a square cuz it's a pixel and we're just making a number slider and I'll go between 0 15 and 100 so it'll be a valley or 15 at the moment and you'll see now this space is out the grid that we're creating by the size of the pixel so this lets you scale your rectangular array essentially I might just make Rhino a little bit bigger and what we want to do now also is set up some sliders to control the X and the y count will also set our plane as the XYZ point it's not necessary if you're working on a ground plane but it might be a different application if you're working on an angle or a vector for example so that's quite important ok we're also going to set up some sliders for our aspect ratio of how we're going to interpret our image which is going to be the size of our rectangular array so we're just going to do between 0 and I'll just set my default value to 50 up to 150 and I'll make two of these because we need our X and our Y count so we're gonna feed these in here and this will essentially control the size of that rectangular array so you see at the moment we have 50 by 50 I might just down sample myself a little bit let's say we'll go to 35 30 there we go so now we've got a little a slightly smaller grid to work with so essentially now we have geometry of our rectangular grid so we can move on with this so I think the next thing that I'll do is I'll establish a bounding box of the entire rectangular array so I'm just gonna get a bounding box now and I want to get the entire set of elements so I'm just going to right-click on and change per object to Union box and we're going to get the entire bounding box of this whole element which essentially gives me a surface that I can extrapolate to what we need to do now is do what's called three parameters all of these points on the surface will UV coordinate so U and V is basically a how far along the surface a point is placed and U and V values always need to be between 0 and 1 so we're going to be using a function called free parameterize I'll show you how this works so first we need to get a surface closest point I just realized I actually don't have my my bifocals on I'm just gonna go turn these on and put them in the corner so bifocals is a great little tool that turns on the names of nodes great for education so sorry that I've just forgotten till then what we're gonna do now is we're gonna take our surface as our bounding box however we're gonna right click on it and activate refer amateur eyes so this will actually interpret the surface between the domain of 0 and 1 so what we'll do is take overall bounding box in the orientation plane coordinates just in case you are not working at the world orientation and then our point in this case is our geometry and what we should end up with is a whole list of UV coordinates as well as the points themselves but they've been remapped of the domain of 0 to 1 so this will let us work with pixel ranges within an image okay so what we need to do now is we're gonna take a yeah we're gonna take a rectangle as well and we're gonna create a bunch of pixels so we're gonna make some some more rectangles to carry forward with later so all of our rectangles we want to place at our geometry and we'll make that our X and our Y size the size of our pixels and we're gonna use these later so each of our pixels now also has a rectangle that we can use later on and it's mapped in the same list order as the pixel values that we're gonna extract from my image so we can use these later what I'll do just turn off the preview for these for now I'll just also turn off the preview for a few other things I'll turn off my bounding box turn off my array and I'll turn off my closest points so my closest points essentially have been remapped at this point so what we're gonna do now is use a really important node to this tutorial which is the image sampler so I'm just going to click and drag one off the canvas from up here in input and what you'll need to do is just double click on it or you can right-click and file path but I'm just gonna go file path and I'm gonna first get off this get just the image of the Mona Lisa and you'll see you get a whole bunch of options for how you can work with this now you can remap your domain manually if you didn't want to Reaper amateur as your domain but I find that Reaper amateur izing is so much more efficient because your image can change size and you don't have to set your domain manually just really important the way that you interpret your image can change as well you can flip your image you can tile it you can clamp it so there's a lot of options there and you can also extrapolate different channels of your image so I can just say I only focus on the red channel for example and the value that will come out is the red pixel value green blue alpha I believe this is hue saturation and brightness so I can just do brightness and there you go now I can see how black or white in an interpretation of how dark or light the images what I want in this case first of all is just my RGB values so I'm just going to be sampling my UV points and what I should get is a list of values sorry I need to get a panel instead I should get a list of RGB values and there you go so these are essentially my pixel values for my whole image and we get 900 samples as we'd expect so that's one thing I'm going to sample the other image I'd like to sample is my depth map so I'm going to use that to control a different aspect of my image so I'm just going to double click this and locate my death map as well in this case I will just interpret the brightness of the image and instead we'll get a different value as I output for this image in this case so now you see we get a number between 0 & 1 so obviously 0 being a darker value and 1 being a lighter value so we can use this to control the depths of things such as the height of a of a on a box which is what we're going to do in this case so the first thing we're going to do is just take a very basic function and I'm just going to color in the pixels of the grid to the color of the image so I'll just create a custom preview node and I'll take my original points from back here as my geometry and I'll make them the color of my image and there you go you can see that we very roughly get a pixel version just as points you can see that the logic of how the points and the you these are essentially in the same positions in relation to the image so that's really important to understand because now you can really work with these in quite creative ways so the first thing we're going to do is we're going to remap the domain of our depth so we're going to basically take a remap numbers node and we're going to remap our brightness through a a base and a top number so essentially we're gonna be controlling the height and the depth of a set of boxes so we're gonna give a image actual 3d depth which is pretty cool so we're gonna go between 0 up to 300 and we'll just start a value of 150 so this is at the top of our range and then likewise half the bottom of our range as well sorry and what we're gonna do is construct a domain out of these because we'll have a source domain and we'll have a target domain so by default our source domain should be 0 to 1 and you can see there it is and that's true and correct because I our brightness node gives us the domain between 0 & 1 so we've already got our source set up we need to do now is construct a new domain for our target blocking my keyboard and construct them in and we'll have a start and an end so I'll start and I'll end and this will be my target domain now figure - I'm Apps domain or I'm apt number list you can see that it's remapped it - where it stands in the new domain range so we can use this to control the height of boxes and so what I'll do in this case is just take a box rectangle and I'm going to call back on these rectangles here call on this on my rectangle and for my height I'm going to call on this map list of heights and now you can see we actually end up with a set of boxes note that currently my image is inverted so my depth is the wrong direction so the reason why you set these sliders up for domain is you can essentially change the direction that the domain influences the image so the domains can work in a backwards or forwards direction so depending how you want to want to protrude or extrude your image you can work with the domain to do this you can also find another really quick technique to invert your image so what I found is really handy and one that I haven't seen in any tutorials it's just just to set up a little expression so I'm going to get a expression and I want two values here so I want X and I want Y and my expression I will make this the absolute value so ABS of why technics and essentially we can use this to control whether we're looking at the top or the bottom of our range sorry just keeps okay so what we're gonna do is feed in numbers between zero and one instead into our expression and I'm gonna create what's called a value list and essentially a value list lets you pick a range of items that the user can nominate so in this case we're going to make standard people 0 and inverted equal 1 so now when the user picks standard or inverted we can feed in wire and it will essentially flip our values per se because we're working with an absolute value you'll see if I go from standard to inverted notice that my numbers change from which side of one they're on so this lets us an invert our domain very quickly because what I can do now is feed this you as my value instead and you'll see I can invert or I can go standard and I can literally flip that relationship straight away without having to worry about mucking around with my domain I'm so pretty cool right so now that we've got these boxes essentially I can just turn the preview off for these just use my radial menu and instead of feeding in our points I'll feed in our boxes there you go and you'll see that now we've got a 3d extruded version of the Mona Lisa obviously I can increase my pixel count to add detail you can see how we can abstract an image into a geometric form using the image sampler so pretty cool there's another common technique people often use in image sampling that I've noticed in tutorials which is to take a bunch of circles and change the radius to set an aperture or amount of light or space that's being left through the circle so we can do a circle I think it's circle by circle by plane and radius I don't know if it's called CPR it's not I think it's just a standard circle no yes a circle by plane and radius in this case our plane is our point right geometry what I might do is just disable this node you'll see already we've got a basic circle at the middle of each or at the center of each point what we want to do now is we'll set up a radius from our map to values obviously you can see that our numbers aren't quite right here so it's probably good for us to set up a division node here and we'll just feed our map value in here and we'll just add a slider from one and we'll just go to five up to 15 that's us set the the amount of downsizing of those circles so as I increase this you'll see that my circles get more refined and you'll see that depending on the value at certain points so if it's closer it's a bigger circle if it's further away it's a smaller one you'll see that now we can interpret our image in a different way again which is really cool and obviously I can go again and feed my geometry into Maya : ode and just disable my preview you'll see now I've also got color as an aspect of how I'm sampling the image so pretty Cora and probably the last thing I'll show you which I haven't seen too many tutorials cover because I know there's a lot of tutorials and image something so I've tried to bring together a lot of things that I've seen in separate sessions is that we'll deconstruct our points because I basically want to remap my points to be at a height so essentially the top of the box but in the same XY positions so I'm going to take a deconstruct points and I'll take my my points and I'll get that x y&z component I'll go to construct one and I'll take the X and the y component of my points but for my Z component I'll take my remap to range and you'll see now I've got a set of points at the same height that the boxes would be at in this case I'm just going to disable my circle node and what we can do with these is actually create a surface from points so I'm going to get a surface from points and I'll take these points for my you count I need to go back to the start of my scripts and take my sampling value you'll see now I have a surface that follows these points as well so now we have a single surface we can work with rather than a set of boxes what I can do with this is just turn off the preview and I can divide the domain using a divide the main squared and I'll divide the domain of my surface by my you count and my feet count from the start so my you count down aware that slow come from and also take my feet out and what I can do with this is apply this to a node called I so trim which essentially divides the surface using a Cartesian grid mapped across the face of the surface see my surface and my domain squared and then if I turn off the preview of my points you'll see essentially I've got a surface maps at the UV values across the face of off this overall surface built from the points so if I turn off this preview from here I believe that these all get broken into individual cells and I can take my geometry and not color to them and there you go now I've got a single surface that's wave formed but divided into cells that also respects the domain of I've done so a few ways that you can apply image values using a few different maps and obviously this is a very literal example of image sampling I'm taking an image and I'm turning the image into another 3d image but you could apply this to a facade there's a lot of ways you could do this and keep in mind that I've see all your controls are still active so I can invert my image and you can see that my my image will invert in height as well and I can change the depth using my domain as well so quite powerful it's very flexible and it's very quick as you can see so hopefully that helps give you some tools that you can play with and hopefully in future videos I'll cover some more practical applications for these tools but thanks for watching today hopefully that really helps give you some things to use in grasshopper I'm really enjoying using the tool so far and look forward to sharing more with you in the future I'll be looking at how to process images using Python as well because this is a very quick way to interpret images into CSV files for example and I'm going to be reading their CSV files into dynamo because the image processing nodes in dynamo don't work very well at the moment there's a few bugs with them so I'm going to be showing you a tutorial where you can use Python to get around the images the image issues in dynamo so thanks for watching today if you've got any feedback or comments feel free to leave it down below hopefully I'll be using Ronnie's six soon so if anyone's got any issues with that just look just you're aware I'll be there soon hopefully and if you're not already following on subscribing feel free to do so and hopefully I'll see you in future videos thanks you
Info
Channel: Aussie BIM Guru
Views: 3,193
Rating: 5 out of 5
Keywords: aussie, bim, guru, cad, computational, tutorial, demonstration, how to, educational, rhino, rhinoceros, grasshopper, grasshopper 3d, image, pixel, pixels, sample, image sample, image sampler, sampler
Id: jnQeIMq2rn4
Channel Id: undefined
Length: 20min 24sec (1224 seconds)
Published: Sun Dec 08 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.