I spotted a blog post the other day about a new feature in Office 2010 that enables you to ‘crop’ a subject out of an image. The feature is called Background Removal and is part of Excel, PowerPoint and Word 2010:
The need for this type of functionality crops up in Visio from time to time and both Chris Roth and I have come up with mask workarounds for this in past:
The Office 2010 Engineering post above is the first on the subject and more details will be coming up in a future post so of course check back there for the correct approach in using the tool. For this post I’m just going to share how to use the output to create a Visio shape (and Master).
One scenario where background removal might be useful is within an Org Chart solution, so I’ve used a photo of President Obama I came across on Flickr as an example. This particular one came from Matt Ortega who’s kindly filed it under a Creative Commons licence, which means you can make derivative works.
Walkthrough – creating an image in Excel 2010
- Open a 2010 version of Excel, PowerPoint or Word and select Insert / Picture from the ribbon. Select your image file and click OK. This will add the image to your document:
- With your inserted image selected, click the Background Removal button.
- A target subject is calculated and a marquee added:
- As you can see Office does a good job at recognising the main subject and paints everything not to be included magenta. The next step is to include the magenta areas you want to be used and exclude those non-magenta areas that you don’t (the area between Obama’s right arm and hand, for example). The ribbon controls that help you do this can be seen below:
- If you click on the Mark to Include toggle button, you can then click on the image in the magenta areas that you want to include. (The reverse happens when you use the Mark to Remove toggle button.) The resulting magenta area changes with each click, and with a little help from the Ctrl+Z (undo) key combination you should end up with the effect you’re after:
- If you zoom in a bit you can see the plus and minus markers that I’ve added more clearly:
- Click the Close Background Removal button and you’ll be left with a perfect outline of Obama and no background.
- From here you can add various effects, such as drop shadow and reflection, as per the Office 2010 Engineering post. You can also crop the image to the correct size and once you’re done just press Ctrl+C to copy the image to the clipboard.
Walkthrough – creating a master in Visio 2007
[Note - that this of course works in Visio 2010 and I assume 2003, although I haven’t tested the latter.]
- So moving over to Visio, create a new document and press Ctrl+V to paste the image into the page.
- Resize the resulting shape.
- Click File / Shapes… / Show Document Stencil, and then drag your new shape onto the now visible Document stencil to create your master.
- You can now drag your master onto your page as normal and add Shape Data or any other standard functionality as you would do for any other Visio shape. The result looks like this:
Note the master icon is rendered with transparency as well and although in 2007 the resolution isn’t perfect, Visio 2010 improves on this to create a great looking thumbnail image as well. (Checkout this post: Visio 2010 Master Icons Get A Facelift – VisGuy.com for more details.)
I think the new Background Removal tool is a great addition, not least because I had a go at doing something similar a couple years ago using GDI+ and it’s not simple - I certainly didn’t close to the results of this tool!