esiegel / seamcarve

Content Aware Seamcarving (partial) implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Content Aware Image Seam Carving

Exploration using Qt5, C++11, Tup, and a bit of functional programing.

This is an implementation of seam carving, described in this paper and shown in this video. Seam carving is an image processing algorithm to resize images by removing unimportant pixels in continuous seams. This differs from standard resizing algorithms which typically just average neighboring pixels. This technique can be very useful with images that have large similar sections, like a sky.

This is by no means the goto implementation; for that you should use the cair library. For me, seam carving was alluring because it is relatively straight forward and also visually really cool. Most importantly, it served as a platform for learning C++, Qt, and tup, all of which are things that I had zero experience with before this project.

Running

After seamcarve is compiled, you can run the executable as follows:

build/seamcarve [-i PATH_TO_IMG]

DEMO

BUILDING

Originally, I had chosen cmake as the build tool, but I found it's magic not well suited for actually understanding the build process. Eventually I chose tup. Tup is extremely good at managing a dependency tree and knowing exactly which rules need reprocessing. This makes incremental builds extremely easy, and makes compiling more tolerable. Tup uses a FUSE file system to monitor changes to files. This indirection, while usually helpful, can complicate things.

Installing tup on osx

brew install tup
chmod u+s $(which tup)
chown root $(which tup)

The last two lines are necessary in order to allow tup the ability to create chroot directories. Refer to this issue, which explains how chroot is used as a workaround to compiling with debug symbols.

Other dependencies

This project also depends on Qt5, boost, and a modern version of llvm/clang for compilation (Not all of these are hard requirements, just how the TupFile is currently defined). You may also need to edit the TupFile so that your dependencies can be found.

brew install qt5
brew install boost

Compilation

Compiling the program by running:

tup init
tup

Looking at the TupFile you'll notice that I avoided the typical Qt workflow. Instead of using the IDE QtCreator and qmake, I chose to use all its internals individually:

  • uic - compiles Qt UI files into cpp headers. This header defines the gui layout.
  • moc - a meta compiler that transforms source with Qt's special syntax into implementation. Used for slots and signals.
  • clang++ - a compiler with, among other things, awesome error messages. Very useful when using templated code. If you like, you can gcc without a problem.

About

Content Aware Seamcarving (partial) implementation


Languages

Language:C++ 100.0%