Skip to content

ketaro-m/SeamCarving

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SeamCarving

Image Resizing by Seam Carving algorithm.

Description

Some non-square pictures don't fit SNS profile portraits, and they need to be resized. Seam Carving technique resizes images preserving important features, unlike rescaling or cropping.

fig1.pngfig3.png

Demo

Demo movie -> https://youtu.be/alv-BUySOPs

Environment

Prerequisite

install Java OpenJDK 13.0.2

# install Homebrew (if needed)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# update packages, install cask, and allow cask to look up versions
brew update
brew tap homebrew/cask
brew tap homebrew/cask-versions
# install Java
brew cask install java

Usage

First, compile files with the following command

$ javac -classpath .:./opencv4/library/opencv-430.jar image/*.java

then, run the main file. You can input any aspect ratio (width:height).

$ java -Djava.library.path=./opencv4/library -classpath .:./opencv4/library/opencv-430.jar: image.Main [filename] [width] [height]

In the pop-up window titled "Drag regions you want to preserve.", you can manually select partial image areas to protect or destroy by dragging them.

fig4.png

You can change your curcor size and protect/destroy mode by typing the following commands in the command line. (default; medium/protect)

Commands Functions
s small cursor size
m medium cursor size
l large cursor size
+ protect mode
- destroy mode

When you finish selecting protect/destroy regions, click Enter-key in the command line.
Once the program has sucessfully run, the input image will be resized with the aspect ratio you entered.

fig2.png

(Top: Not selecting any region, Buttom: Selecting people to protect)
You can save it from "File->Save" tab at the top of the image window.

Demo mode

If you want to see how the algorithm works, checkout to the demo commit node and recompile files and rerun the program.

$ git checkout demo
$ javac -classpath .:./opencv4/library/opencv-430.jar image/*.java
$ java -Djava.library.path=./opencv4/library -classpath .:./opencv4/library/opencv-430.jar: image.Main [filename] [width] [height]

About

Image Resizing by Seam Carving

Resources

Stars

Watchers

Forks

Packages

No packages published