Email Updates RSS Subscribe
Line

This blog is created and maintained by the technical team at Hook in an effort to preserve and share the insights and experience gained during the research and testing phases of our development process. Often, much of this information is lost or hidden once a project is completed. These articles aim to revisit, expand and/or review the concepts that seem worth exploring further. The site also serves as a platform for releasing Flash tools developed internally to help streamline ad development.

Launch
Line

Hook is a digital production company that develops interactive content for industry leading agencies and their brands. For more information visit www.byhook.com.

Line

Kutout – An application for cutting out images

Line
Posted on March 30th, 2010 by Norm McGarry
Line

Demo
Download
Documentation

Kutout is an as3 (Actionscript 3) open-source library and sample application for image extraction and object extraction from images in Flash. The methodology behind the approach was taken from the java implementation of a pre-existing open-source solution called SIOX (Simple Interactive Object Extraction). The solution and all source-code is being released under the Apache Licence, version 2.0.

“When Thomas Edison worked late into the night on the electric light, he had to do it by gas lamp or candle. I’m sure it made the work seem that much more urgent.” George Carlin

The algorithm has four necessary steps.

  1. Define a region to extract in the image. The algorithm takes the pixels outside of the region and applies a confidence to the pixels as a certain background. It applies an unknown confidence to the pixels inside the selection region.
  2. Paint the foreground. The algorithm then needs reference to what is considered the object. When you paint the foreground area, it gives these pixels a confidence of a foreground. You can paint as much or as little as you like, as long as the algorithm has some sort of foreground reference.
  3. Paint the background. The algorithm also requires a reference to the background. Technically Step 1 applies some background reference so the algorithm should run without this step, but regardless, it helps to paint around the image.
  4. Run the algorithm and repair. We’ve included some methods in the implementation to help repair the segmentation. Some objects are nearly impossible to segment based on only foreground and background color reference due to the complex nature of colors and their surroundings, so repair tools are always necessary. The repair tools also use the results from the algorithm to help you repair. They compare the confidence of the pixels compared to the confidence of the foreground to determine if the pixels could be actually part of the image. You can control the sensitivity of this tool and adjust how accurate and close the confidence must be. Sometimes the smart pixel refinement methods do not seem to repair perfectly, so in our sample app, setting the sensitivity to zero will apply a hard brush for painting and erasing.

Now that we’ve summarized the functionality briefly, we’ll give you some visual examples of how we approached the functionality in our sample application, Kutout.

Step 1.

Kutout Image Extraction in Flash - Step 1

Choose an image from the thumbnail browser, or upload one of your own by clicking the "Add an image" button.

Step 2.

Kutout Image Extraction in Flash - Step 2

Select an area to crop around the object you want to extract.

Step 3.

Roughly paint the foreground area of the object you want to extract. For best results, be conservative and try to stay in the lines. Highlighting the background as a foreground is a no-no.

Roughly paint the foreground area of the object you want to extract. For best results, be conservative and try to stay in the lines. Highlighting the background as a foreground is a no-no.

Step 4.

Roughly paint the area that you consider the background around the object you are trying to extract. Try to stay in the lines and don't paint any of the foreground as a background!

Roughly paint the area that you consider the background around the object you are trying to extract. Try to stay in the lines and don't paint any of the foreground as a background!

Step 5a.

Now you should have a Kutout image! Just use the three brushes on the left to fix up any mistakes the algorithm made.

Now you should have a Kutout image! Just use the three brushes on the left to fix up any mistakes the algorithm made.

Step 5b.

Success! Now click Save to save your image as a png.

Success! Now click Save to save your image as a png.

Example

Kutout is a very complex app which makes use of many interface tools that help to make the algorithm work. For examples of how to implement painting tools and cropping tools, please see the application source code and documentation. For a brief overview on how the application works, below is an abstract overview of the core methods to produce the functionality. All values are arbitrary and just used for code examples purposes.

//first we create the canvas
var bitmap:Bitmap; //this should already be a populated image object
var canvas:Canvas = new Canvas();
canvas.initFromBitmapData(bitmap.bitmapData);
addChild(canvas);
 
//next we create the controller
var segmentationController:SegmentationController = new SegmentationController(canvas);
 
//now we can perform a crop
var area:Rectangle = new Rectangle(50,50,300,300);
segmentationController.applySelection(area, SegmentationConfidence.UNKNOWN_REGION_CONFIDENCE);
 
//now we'll paint a little foreground
var centerPoint:Point = new Point(150,150);
var radius:Number = 100;
segmentationController.setCircleConfidence(centerPoint, radius, SegmentationConfidence.FOREGROUND_CONFIDENCE);
 
//now we'll paint a little background
centerPoint = new Point(270,270);
radius = 30;
segmentationController.setCircleConfidence(centerPoint, radius, SegmentationConfidence.BACKGROUND_CONFIDENCE);
 
//now we perform the segmentation
segmentationController.addEventListener(SegmentationEvent.SEGMENTATION_COMPLETE, handleSegmentationComplete);
segmentationController.segmentate();
 
function handleSegmentationComplete(e:SegmentationEvent):void
{
     //now we can do a little refinement...whether it be addition or subtraction refinement
     var refinePoint:Point = new Point(20,20);
     var refineRadius:Number = 5;
     var refineSensitivity:Number = 0.3;
     segmentationController.supPixelRefineAddCircle(refinePoint, refineRadius, refineSensitivity);
}


Demo

Try it for yourself! View our demo here!


Download

Here is a zip that contains the documentation, all source code, and a SWC for the library.


Documentation

Application Only

Library Only

Application and Library

Line
Facebook TwitThis Digg Reddit StumbleUpon del.icio.us
35 Responses to “Kutout – An application for cutting out images”
  1. It is a good post , I like it and please keep writing .

  2. I am so happy to read your post , I like it and thanks for sharing it .

  3. good post , i like it , thanks for sharing it . have a nice day .

  4. good arctile,I am so happy to read your post , I like it and thanks for sharing it .

  5. This is one of the ideal and good post.I like your blog foundation.This is one of the simple and attractive post.

  6. thanks for sharing it and please keep doing this good job .

  7. Wind, blown crystal snowflake Solitude, tods shoes uk,tods shoes uk bleak memory, because you and warm. Merry Christmas.

  8. I really enjoy to read this awesome blog post.
    Inspiring!

  9. 85-86 season, the Rockets franchise history at its peak in the ranks, though soon they fall apart on their own. Finals in 86 years up to 18 months after the suspension period, the Rockets the best three defenders Lucas, Lloyd and Wiggins were caught in a drug abuse problems, breaking again to the championship of the rocket impact of hope. 86-87 season the Rockets get 42-20, Western group ranked third, unknown into the playoffs.

  10. weddingdresslove.co.uk specializes in designing and manufacturing various styles of high quality wedding clothing and apparel in China. All of these products are delicate, beautiful, fashionable and also of good quality. We do both wholesale and retail business, all Wedding Clothing and Apparel are made by our own professional factory…

  11. good arctile , thanks for sharing it and please keep doing this good job .

  12. Wow, I’m obviously not being creative enough, haha…Great work!

  13. nike shox cheap
    A more suitable for you and I make friends, ha ha

  14. nike shox cheap
    as if all the world all static, eyes only you at that moment water tender feelings, only you at that moment the picturesque face, gently break the last bit of my heart weak, let me for you out.

  15. nike shox cheap his hand over the side of the carrying quilts, go on, wang Lin helpless, have to put together, can’t let the girl a man to it.

  16. Cabinet Office Minister Francis Maude branded the action “indefensible and wrong”.

  17. I am so happy to read your post , it is wonderful . I like it and thanks for sharing it .

  18. nice post , i like it , thanks for sharing it . have a nice day.

  19. food additives
    Food thickener
    Agar agar
    Cassia Gum
    Carboxy Methyl Cellulose
    Guar Gum
    Konjac glucomannan
    Pectin
    Sodium Alginate
    Xanthan Gum

  20. cocogc says:

    Iam interested in this article:
    http://www.cocogc.net

  21. The classic mulberry bayswater bags, in our signature natural vegetable tanned leather, is a timeless piece, which contains all the compartments a girl could need.

  22. I love the way you wrote this article. This is wonderful. I do hope you intend to write more of these types of articles. Thank you for this interesting content!

  23. We Sale Cheap Jerseys ,Buy Cheap NFL Jerseys, MLB Jerseys, NBA Jerseys,NHL Jerseys Wholesale From USA Authentic Quality.

  24. OPT9JAJH983FSKVSLU
    make ugg boots your company Throughout freezing climate

  25. My friend told me to check out this post and i found it pretty impressive.

  26. nike shox says:

    friends treating you better if you were nice to them, was a security system. In my reframing, those are all trust pressures. It’s a language that’s more intuitive.

  27. Thank you for taking the time to publish this information very useful!

  28. Often I just now think that people be able to write, and never obviously have significantly to talk about. There’s nothing the result. You’ll want to have anything at all to suggest, most people proclaim design and style, a individual! You definitely experience an unique option to catch the attention of many people, together with your personal video recording and then your keywords. You have got an interesting blogging site there are 12 hit!

  29. Interesting post. Thanks for sharing.

  30. kanchana says:

    ela ela

  31. [...] the most exciting topic out there especially compared to some of the other hotness on this site: Kutout – An application for cutting out images and Fuzzy Physics – 3.1: Rigid Body Dynamics, pt [...]


Leave a Reply

*

Line
Line
Pony