Giter VIP home page Giter VIP logo

imageclipper's Introduction

Introduction

(2014/05/20) The maintainer was changed to Joakim Soderberg. Go to https://github.com/JoakimSoderberg/imageclipper

It is often required to crop images manually fast for computer vision researchers to gather training and testing image sets, e.g., cropping faces in images.

This simple multi-platform (Windows and Linux were verified) software helps you to clip images manually fast.

What You Can Do

  • Open images in a directory sequentially
  • Open a video, frame by frame
  • Clip (save) and go to the next image by one button (SPACE)
  • Move and resize your selected region by vi-like hotkeys or right mouse button
  • Rotate and shear deform (affine transform) the rectangle region

Table of Contents

Download

Windows binary and source codes

Drag and Drop a folder (including pictures) or a picture or a video file on exe. You can also execute it on the command prompt. No installer is included for this simple software.

PS. It may be required to install [http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647&DisplayLang=en Microsoft Visual C++ 2005 SP1 Redistributable Package] (if you have never installed this or Visual Studio 2005 itself). I am looking for how not to require users to install it. Not to use VC++ 2005?

How to compile for Linux is written below.

Application Usage

  • (Windows) Drag and drop a folder or an image file or a video file on imageclipper.exe.
  • (Windows and Linux) Execute as a command line tool. See Command Usage section too.

snapshot

Mouse Usage

    Left  (select)          : Select or initialize a rectangle region.
    Right (move or resize)  : Move by dragging inside the rectangle.
                            : Resize by draggin outside the rectangle.

Keyboard Usage

    s (save)                : Save the selected region as an image.
    f (forward)             : Forward. Show next image.
    SPACE                   : Save and Forward.
    b (backward)            : Backward. 
    q (quit) or ESC         : Quit.
    r (rotate) R (counter)  : Rotate rectangle in clockwise.
    e (expand) E (shrink)   : Expand the recntagle size.
    h (left) j (down) k (up) l (right) : Move rectangle. (vi-like keybinds)
    y (left) u (down) i (up) o (right) : Resize rectangle (Move right-bottom boundaries).
    n (left) m (down) , (up) . (right) : Shear deformation.

Saved file format

The clipped images are saved as

<dirname>/imageclipper/<basename>_<rotation_degree>_<left_x>_<top_y>_<width>_<height>.png

such as

../myimages/imageclipper/lena.jpg_0359_0109_0093_0065_0090.png

where the original filename is

../myimages/lena.jpg. 

A directory named "imageclipper" is created under the image file's directory and cropped images are stored on there.

This filename format can be configured via command line options. See [#Command_Usage Command Usage] section.

Experimental Feature (Continuous Color Region)

You can choose a rectangular region surrounding a continuous color region.

    Middle or SHIFT + Left  : Initialize the watershed marker. Drag it.

You can use Right mouse and hotkeys to move or resize the watershed marker.

watershed

Command Usage

ImageClipper - image clipping helper tool.
Command Usage: imageclipper.exe [option]... [reference]
  <reference = .>
    <reference> would be a directory or an image or a video filename.
    For a directory, image files in the directory will be read sequentially.
    For an image (a file having supported image type extensions listed below),
    it starts to read a directory from the specified image file.
    For a video (a file except images), the video is read.

  Options
    -f <output_format = imgout_format or vidout_format>
        Determine the output file path format.
        This is a syntax sugar for -i and -v.
        Format Expression)
            %d - dirname of the original
            %i - filename of the original without extension
            %e - filename extension of the original
            %x - upper-left x coord
            %y - upper-left y coord
            %w - width
            %h - height
            %r - rotation degree
            %. - shear deformation in x coord
            %, - shear deformation in y coord
            %f - frame number (for video)
        Example) ./$i_%04x_%04y_%04w_%04h.%e
            Store into software directory and use image type of the original.
    -i <imgout_format = %d/imageclipper/%i.%e_%04r_%04x_%04y_%04w_%04h.png>
        Determine the output file path format for image inputs.
    -v <vidout_format = %d/imageclipper/%i.%e_%04f_%04r_%04x_%04y_%04w_%04h.png>
        Determine the output file path format for a video input.
    -h
    --help
        Show this help

  Supported Image Types
      bmp|dib|jpeg|jpg|jpe|png|pbm|pgm|ppm|sr|ras|tiff|exr|jp2

You may make a batch file (Windows) or a shell script or an alias (Linux) to setup default values. Use of -i and -v rather than -f would be useful in that case.

How to Compile on Linux

You need to install OpenCV and Boost libraries.

Install OpenCV

Download OpenCV source codes (.tar.gz)

root user

tar zxvf opencv-1.0.0.tar.gz; cd opencv-1.0.0
./configure
make
make install

general user

tar zxvf opencv-1.0.0.tar.gz; cd opencv-1.0.0
./configure --prefix=$HOME/usr
make
make install
export PATH=$HOME/usr/bin/:$PATH
export LD_LIBRARY_PATH=$HOME/usr/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$HOME/usr/lib/pkgconfig:$PKG_CONFIG_PATH
export MANPATH=$HOME/usr/man:$MANPATH

Install Boost

root user and Red Hat (Fedora)

yum install boost
yum install boost-dev

root user and Debian (Ubuntu)

apt-get install boost
apt-get install boost-dev

general user

Download Boost source codes (.tar.gz)

tar zxvf boost_1_36_0.tar.gz; cd boost_1_36_0
./configure --prefix=$HOME/usr
make install

Reference: Boost Getting Started on Unix Variants

Compile

Unarchive imageclipper.zip. Go to src/ directory. A Makefile is attached. Modify as follows:

If you installed boost not on $HOME/usr/: modify ~/usr/ to your path such as /usr/

If your boost version is not boost_1_36_0: modify boost-1_36 to your version.

Modify -lboost_system-gcc41-mt -lboost_filesystem-gcc41-mt to yours. Find names by $ ls /path/to/yourboost/lib. If you find names as libboost_filesystem-gcc41-mt, then => -lboost_filesystem-gcc41-mt

$ make check

I don't know why boost library uses different names under different system. It requires us to modify Makefile as above in different system.... anyway,

Finally

make

You should get an executable file "imageclipper".

How to Compile on Windows

A binary file for Windows is already attached. This section explains how to compile for those who want to modify source codes and create a modified software.

You need to install OpenCV and Boost libraries.

Install OpenCV

Download OpenCV installer and install it. I assume you have installed onto C:\Program Files\OpenCV.

Install Boost

Download boost installer and install it. I assume you have installed onto C:\Program Files\boost\boost_1_35_0.

Reference: Boost Getting Started on Windows

Setup MS Visual C++

I write details based on MS Visual Studio 2005. Change boost_1_35_0 if your version is different. Follow menus of MS Visual C++ window as:

  • Tools > Options > Projects and Solutions > VC++ directories >
    • Show Directory for: > Include Files. Now add
C:\Program Files\boost\boost_1_35_0
C:\Program Files\OpenCV\cv\include
C:\Program Files\OpenCV\cvaux\include
C:\Program Files\OpenCV\cxcore\include
C:\Program Files\OpenCV\otherlibs\highgui
  • Show Directory for: > Library Files. Now add
C:\Program Files\boost\boost_1_35_0\lib
C:\Program Files\OpenCV\lib

Compile

Unarchive imageclipper.zip and open src\imageclipper.sln, then Build for Release.

Creating a text file to locate clipped region

A text file containing locations of clipped region is sometimes required rather than clipped images themselves, e.g., as a ground truth text for testing experiments in computer vision.

Assume there exist files as follows:

$ \ls imageclipper/*_*_*
image.jpg_0068_0047_0089_0101.png
image.jpg_0087_0066_0090_0080.png
image.jpg_0095_0105_0033_0032.png
image.jpg_0109_0093_0065_0090.png
image.jpg_0117_0097_0052_0095.png

By executing the following command,

$ find imageclipper/*_*_* -exec basename \{\} \; | perl -pe \
's/([^_]*).*_0*(\d+)_0*(\d+)_0*(\d+)_0*(\d+)\.[^.]*$/$1 $2 $3 $4 $5\n/g' \
| tee clipping.txt

you can obtain a text file "clipping.txt" as follows:

image.jpg 68 47 89 101
image.jpg 87 66 90 80
image.jpg 95 105 33 32
image.jpg 109 93 65 90
image.jpg 117 97 52 95

I think this file format is a typical format for testing experiments in many computer vision tools.

For OpenCV haartraing Users

Use haartrainingformat.pl as

$ perl haartrainingformat.pl clipping.txt | tee info.dat

where clipping.txt is the text file created at the previous section to create a OpenCV haartraining suitable format such as

image.jpg 5 68 47 89 101 87 66 90 80 95 105 33 32 109 93 65 90 117 97 52 95

Or you can generate a file without creating "clipping.txt" as

$ \ls imageclipper/*_*_* | perl haartrainingformat.pl --ls --trim --basename | tee info.dat

Note that clipped images themselves are enough and better for training phase (See Tutorial: OpenCV haartraining).
Therefore, you may use this only for creation of testing data.

Usage

Helper tool to convert a specific format into a haartraining format.
Usage: perl haartrainingformat.pl [option]... [filename]
    filename
        file to be read. STDIN is also supported.
Options:
    -l
    --ls
        input is an output of ls.
    -t
    --trim
        trim heading 0 of numbers like from 00xx to xx.
    -b
    --basename
        get basenames from filenames.
    -h
    --help
        show this help.

imageclipper's People

Contributors

sonots avatar

Stargazers

Quinten Lisowe avatar  avatar Martin John Madsen avatar Derek Brown avatar Emma Saboureau avatar

Watchers

 avatar

imageclipper's Issues

Patch for Makefile to compile on gcc4.5 and dirty hack for __BEGIN__ __END___ macros aswell as gcc4.5 header compatibility

Index: imageclipper.cpp
===================================================================
--- imageclipper.cpp    (Revision 102)
+++ imageclipper.cpp    (Arbeitskopie)
@@ -21,6 +21,12 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
+/* DIRTY FIX DIRTY FIX */
+#define __BEGIN__ {
+#define __END__ goto exit; exit: ; }
+/* DIRTY FIX DIRTY FIX */
+
 #ifdef _MSC_VER // MS Visual Studio
 #pragma warning(disable:4996)
 #pragma warning(disable:4244) // possible loss of data
Index: icformat.h
===================================================================
--- icformat.h  (Revision 102)
+++ icformat.h  (Arbeitskopie)
@@ -30,6 +30,7 @@

 #include <stdio.h>
 #include <string>
+#include <cstdio>

 /**
 * Convert format to string
Index: Makefile
===================================================================
--- Makefile    (Revision 102)
+++ Makefile    (Arbeitskopie)
@@ -9,7 +9,7 @@
 LINK = g++
 INSTALL = install
 CFLAGS = `pkg-config --cflags opencv` -I ~/usr/include/boost-1_36 -I.
-LFLAGS = `pkg-config --libs opencv` -L ~/usr/lib -lboost_system-gcc41-mt 
-lboost_filesystem-gcc41-mt
+LFLAGS = `pkg-config --libs opencv` -L ~/usr/lib -lboost_system-mt 
-lboost_filesystem-mt
 all: imageclipper

 imageclipper.o: imageclipper.cpp

Original issue reported on code.google.com by timo.witte on 26 Dec 2010 at 2:10

Images in a directory are not read sequentially

What steps will reproduce the problem?
1. Run imageclipper on a directory e.g. ./imageclipper img
2. Press <f> or <space>

What is the expected output? What do you see instead?
I expect the files to be opened in order according to file name. In the 
documentation it says "For a directory, image files in the directory will be 
read sequentially"

I end up seeing files in random order, which greatly slows down clipping as I 
am taking samples from video files.


What version of the product are you using? On what operating system?
I am using svn revision 102 on 64bit archlinux using the ext4 filesystem

Please provide any additional information below.

The boost directory iterator documentation states: "The Linux listing isn't 
sorted. That's because the ordering of directory iteration is unspecified."

This problem can be fixed by adding this line:

sort(param->filelist.begin(),param->filelist.end());

Which is done in the attached patch file.



Original issue reported on code.google.com by [email protected] on 20 Mar 2012 at 1:25

Attachments:

Move rectangle by Cursor key

Move rectangle by cursor key and vi-like hotkeys.  
Shift+cursor key to resize. 
When watershed marker is shown, move and resize the watershed marker. 

Original issue reported on code.google.com by [email protected] on 30 Sep 2008 at 5:38

Access Violation

What steps will reproduce the problem?
1. Whenever I run the source and crop and image, then press 's' I get:

Unhandled exception at 0x6c714edb in imageclipper.exe: 0xC0000005: Access
violation reading location 0x81067318.

Thankyou very much for any help you can give me


Original issue reported on code.google.com by [email protected] on 14 Sep 2009 at 7:57

Missing DLL for RC1

Program will not start.

What is the expected output? What do you see instead?
Expected to Run, instead getting:
----
imageclipper.exe - Unable to Locate Component
This application has failed to start because cv110.dll was not found. Re-
installing the application may fix this problem.
----

What version of the product are you using? On what operating system?
imageclipper20081208.zip (v1.00 RC1) on Windows XP

Just tried the prior version, it seems to start okay.



Original issue reported on code.google.com by [email protected] on 21 Sep 2009 at 3:12

the images are mirrored when cropped. If you click on one point on the video frame, its mirror in the image is selected instead. As you grow the rectangle, all keys work in upside mode, the pixels are mirrored

What steps will reproduce the problem?
1. upload a video (the one provided in the package)
2.
3.

What is the expected output? What do you see instead?

same results when you work with single images (not an avi)


What version of the product are you using? On what operating system?

Lenovo T500, Visual C++ Studio . Net 2008. XP

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 22 Jul 2009 at 5:59

Not working with video input.

What steps will reproduce the problem?
1. Drop the 00-1.avi in imageclipper.exe

What is the expected output? What do you see instead?
Video frame by frame should be shown. 
Instead a DOS-Window was shown, with help description.


What version of the product are you using? On what operating system?
Version: imageclipper20081208
Windows 7


Please provide any additional information below.
Commands through command line did not work also. Not responding saw.

Original issue reported on code.google.com by [email protected] on 28 Jan 2015 at 2:41

Right mouse for watershed

Right mouse (move) for watershed would be better to be movement of
watershed marker rather than movement of rectangle. 

Original issue reported on code.google.com by [email protected] on 12 Sep 2008 at 4:21

To Compile it in Linux

The following post helped me a lot!
http://askubuntu.com/questions/323047/how-to-compile-imageclipper-in-12-04

Original issue reported on code.google.com by [email protected] on 16 Mar 2014 at 7:47

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.