73348

Put Image in contour (OpenCV)

Question:

I teach OpenCV, and I want to write a small test app. And have a question. What algorithm would you advise to fill the contour (close to a rectangle) with image?

Thanks a lot!

Answer1:

Assuming you know the location of the rectangle you would like to fill, you could simply set a ROI (region of interest) and perform some processing on that region (maybe a grayscale conversion), or even copy another image to that location. I've already demonstrated <a href="https://stackoverflow.com/questions/10881397/setting-roi-with-mouse-from-a-rectangle-on-a-video/10883266#10883266" rel="nofollow">how to set a ROI and perform some processing on that area</a>.

If you want to add 2 images I suggest you check <a href="http://opencv.itseez.com/doc/tutorials/core/adding_images/adding_images.html" rel="nofollow">the official tutorial</a>, <a href="http://www.developerstation.org/2011/02/adding-two-images-in-opencv.html" rel="nofollow">this post</a>, and <a href="http://dasl.mem.drexel.edu/~noahKuntz/openCVTut2.html" rel="nofollow">this demo</a>: the magic happens through cvSetImageROI() and cvAddWeighted().

Answer2:

A combination of <a href="http://opencv.willowgarage.com/documentation/cpp/geometric_image_transformations.html#cv-warpperspective" rel="nofollow">warp</a> to deform the src image to match the shape of the contour and <a href="http://opencv.willowgarage.com/documentation/cpp/core_operations_on_arrays.html?highlight=addweighted" rel="nofollow">addWeighted</a> to replace destination image pixels with the source in the new shape

Recommend

  • how to get sub image by using OpenCV in java api
  • How to convert images color space in Keras?
  • How to overlay small animation on camera stream in opencv
  • MultiCrops in same image
  • how can i know if the image is in RGB or BGR format?
  • modernizr check for grayscale filters IE 10
  • smoothing image in Matlab
  • Regex for Specific Tag
  • Python PIL to extract number from image
  • How can we prepend rows to a react native list-view?
  • Using MouseListener to select a range of cells in a grid
  • How to explicitly/implicitly implemented interface members in C++/CLI?
  • Optimizing the print function in Matlab
  • Zoom in and out of jPanel
  • Security issues with PHP's Readfile method
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • What's the purpose of QString?
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • Firefox Extension - Monitor refresh and change of tab
  • Unable to get column index with table.getColumn method using custom table Model
  • Stop Bash Script if Hive Fails
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • Saving Changes After In-App Purchase Has Been Purchased
  • OOP Javascript - Is “get property” method necessary?
  • Transactional Create with Validation in ServiceStack Redis Client
  • Jackson Parser: ignore deserializing for type mismatch
  • Hardware Accelerated Image Scaling in windows using C++
  • Python urlparse: small issue
  • Cancel a live stream “fast motion” catch-up in Flash
  • FileReader+canvas image loading problem
  • When to use `image` and when to use `Matrix` in Emgu CV?
  • Javascript Callbacks with Object constructor
  • How can I use Kendo UI with Razor?
  • To display the title for the current loaction in map in iphone
  • Suggestions to manage Login/Logout transitions
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • python draw pie shapes with colour filled
  • reshape alternating columns in less time and using less memory