The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Fast image enlargement through seam insertion in OCaml

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eigen Class

Posts: 358
Nickname: eigenclass
Registered: Oct, 2005

Eigenclass is a hardcore Ruby blog.
Fast image enlargement through seam insertion in OCaml Posted: Oct 24, 2007 3:45 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eigen Class.
Original Post: Fast image enlargement through seam insertion in OCaml
Feed Title: Eigenclass
Feed URL: http://feeds.feedburner.com/eigenclass
Feed Description: Ruby stuff --- trying to stay away from triviality.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eigen Class
Latest Posts From Eigenclass

Advertisement

I have implemented the last major feature missing in my content-aware image resizer based on seam carving/insertion, image enlargement via seam insertion. It took a whole 50 lines of OCaml code which you can find below. My program now does everything the Gimp LiquidRescale plug-in does, so a direct comparison can be done.

Looking at the rendering part only, I have needed under 500 lines of OCaml code *1. LiquidRescale's render.{c,h} comprise over 2100 lines of code. On my box, seam carving and insertion in OCaml are both over 5 times faster than LiquidRescale's (remember I'm not comparing my code to a Python script; LiquidRescale is written in C).

Here's a tiny sample of what seam insertion is about. Given this image

buildings_orig.jpg

if you just rescale it, it will look like this

buildings_expanded.jpg

The image can be enlarged while preserving the aspect ratios of the salient objects using seam insertion:

buildings_inserted.jpg

Content-aware image enlargement is not as flashy as object removal with seam carving, but it's still somewhat useful.

How seam insertion works

Seam insertion is very easy once you have seam carving, since it can be trivially built atop it as reflected also by the code, where seam insertion is performed by a functor which abstracts over the seam carving module:

 module Make(Carving: Seamcarving.S) = struct ... end

This means that I automatically get biased seam insertion, as I already had biased seam carving, which is used to remove objects from an image (see my first post for an explanation of the seam carving algorithm itself).

There are basically two steps to image enlargement through seam insertion:


Read more...

Read: Fast image enlargement through seam insertion in OCaml

Topic: Ruby In Steel 1.1.5 Released Previous Topic   Next Topic Topic: Libraries. This is where Ruby is head and shoulders above Python.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use