Activity › Forums › Adobe After Effects › How to determine size of object in composition after mask applied
-
How to determine size of object in composition after mask applied
Posted by Phil Johnson on March 14, 2013 at 8:08 amHi
I hope someone can help me.
I’d like to know how I can determine the exact dimensions of an object/layer in the composition window after I’ve applied a mask to it.
Like this: https://2share.co.za/Files/d674a913-cb21-4635-9771-aef66ac27146AE1.jpg this is the original file, but I want to cut out the gadget in the cornerlike this https://2share.co.za/Files/d674a913-cb21-4635-9771-aef66ac27146AE1.jpg
Now I want to know what the size of the gadget alone is in the composition. I can’t check in the project window because it’ll give me the original size of the layer.
I hope it is possible. Please help.
Thank you.
Darby Edelen replied 13 years, 5 months ago 4 Members · 5 Replies -
5 Replies
-
Paul Roper
March 14, 2013 at 9:04 amIt depends on what you want to achieve – if you just want to find out the dimensions of this one layer, just bring up your rulers (command/ctrl r), and keep an eye on the info palette while dragging some rulers onto the composition, and do some subtraction to find the result.
However, if you need to do this many times and pass that value to another layer or something, you’ll have to write an expression. Unfortunately the .width function does not take into account masks, so using thisComp.layer(“intel_temperatures.tif”).width will not be useful. You could use the sampleImage function (it’d look something like: thisComp.layer(“intel_temperatures.tif”).sampleImage([200,200],[.5, .5])
…which gets the value of the colour (and more importantly in this application, the alpha value which will tell you when you’ve reached the edge of the image) of the pixel(s) of a layer at (in this example) x=200, y=200, with a sample radius of 1 pixel (extending .5 pixels in each direction).You’d have to make a fairly laborious if….then loop to sample each pixel. It’s too complex for me to go into now, but there are quite a few tutorials out there. Or maybe if you repost the question in the expression section, you’ll get lucky and someone will help you further.
– Paul
-
Phil Johnson
March 14, 2013 at 9:23 amThank you very much. I used the rulers method and it served my pupose. Thanks for you help. 🙂
-
John Cuevas
March 14, 2013 at 11:31 amAnother method you could have use(if you need to do this in the future) is the Crop to Region of Interest. Select the Region of Interest(ROI) button under your comp window(next to the Full/Half/Quarter Resolution Toggle) and make your ROI the gadget. Then under the composition tab, choose Crop Comp to Region of Interest, press Cntl+K to get the dimensions, and a cntl+z to return to your regular comp size.
Johnny Cuevas, Editor
Thinkck.com“I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work.”
—THOMAS EDISON on inventing the light bulb. -
Phil Johnson
March 14, 2013 at 5:07 pmThanks guys. You really helped me. It’s all done now. Thanks again. I will keep this crop method in mind for future use.
I used the ruler method, it’s not 100% accurate, but it worked for what I wanted to do.
Next time I’ll use the ROI crop method. -
Darby Edelen
March 14, 2013 at 6:03 pmThere are a couple of ways to do this.
My recommendation would be to select your mask and press cmd-shift-m/ctrl-shift-m (Mac/PC). This will give you a dialog that has the offsets of the mask’s bounding box. In order to get the width/height you’ll need to do some math:
Height = Bottom – Top
Width = Right – LeftThese pixels are in the layer’s transform space so if the layer has been scaled to 50% you’ll need to multiply your results by 0.5 to get the size of the mask in the composition.
This is pretty easy but requires some simple arithmetic.
The other option is to start by pre-composing the masked layer with “Move All Attributes” selected. This will move the mask into the pre-comp.
Then go into the pre-comp and draw out a Region of Interest (see the AE help) that bounds the area. Under the Composition menu you can then use Composition > Crop Comp to Region of Interest.
In your parent composition the size of the pre-comp layer should now be the size of the region of interest you drew out. Of course this technique depends on you drawing an accurate region of interest, but it’s pretty fast and mindless.
Darby Edelen
Reply to this Discussion! Login or Sign Up