Thursday, February 13, 2014

How to use imageclipper on Mac OS X

In the previous tutorial I explained how to build imageclipper from source. You may have done this or just downloaded the executable file I provided. But you can't just double click it. If you do, only a help will be presented:
 Application Usage:  
  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.  
   Middle or SHIFT + Left : Initialize the watershed marker. Drag it.   
  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 (opposite) : Rotate rectangle in counter-clockwise.  
   e (expand) E (shrink)  : Expand the recntagle size.  
   + (incl)  - (decl)   : Increment the step size to increment.  
   h (left) j (down) k (up) l (right) : Move rectangle. (vi-like keybinds)  
   y (left) u (down) i (up) o (right) : Resize rectangle. (Move boundaries)  
   n (left) m (down) , (up) . (right) : Shear deformation.  
 Now reading a directory..... No image file exist under a directory .  
 ImageClipper - image clipping helper tool.  
 Command Usage: imgclipper [option]... [arg_reference]  
  <arg_reference = .>  
   <arg_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, it starts to read a directory from the specified image file.   
   (A file is judged as an image based on its filename extension.)  
   A file except images is tried to be read as a video and read frame by frame.   
  Options  
   -o <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.  
   -f  
   --frame <frame = 1> (video)  
     Determine the frame number of video to start to read.  
   -h  
   --help  
     Show this help  
  Supported Image Types  
    bmp|dib|jpeg|jpg|jpe|png|pbm|pgm|ppm|sr|ras|tiff|exr|jp2  

This already tells you a lot. But to you is it you have to do the following:

1. Create a folder and put in all the images you want to cut and the imageclipper executable.

2. Open the Terminal app and navigate to this folder.

3. Once you're in this folder, type this (or whatever your name for the executable is):
 ./imageclipper  
4. A new window should open showing the first picture in this folder.


5. With your mouse draw a rectangle of the part you want to cut. Another window will open showing you how your cut image will look like.


6. To crop it and hit s, to jump to the next image hit f. Or you hit space to combine these two steps which makes you even faster.

7. After cropping, the next image in the folder will automatically open. To leave the aplication, hit esc.

That's it. You will find you're cropped images in a separete folder called imageclipper.

Program versions:
OS: Mac OS X 10.9.1
OpenCV: 2.4.8.0

No comments:

Post a Comment