Skip to content

Mark rectangular areas in a batch of images and save the output as a CSV

License

Notifications You must be signed in to change notification settings

jakubvalenta/image-marker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Marker

A graphical program to mark rectangular areas in a batch of images and save their coordinates as a CSV. Optionally, add a text note to each of the images. Optimized for a fast workflow.

Image Marker screenshot

Output CSV format:

<image path> <left px> <top px> <width px> <height px>

Example:

./test_images/building.jpg 350 237 909 547
./test_images/canal.jpg 530 533 1075 252

This is all Image Marker does. You can do whatever you want with the output CSV. One obvious option is to crop the images according to the marks. You can use image-crop for that.

Installation

pip install --user --upgrade .

Usage

  1. Put all the images you want to mark in a single directory.

  2. Run Image Marker:

    image-marker ./my_directory --marks my_marks.csv --output my_output.csv --box-ratio 1.33 --box-padding 0.1

    The positional argument specifies the directory to load the images from.

    The option --marks specifies the CSV file path, where the coordinates of the marked rectangles will be saved.

    The option --output specifies the CSV file path, where the post-processed coordinates will be saved. More on that later.

  3. A window will appear with the first image in the directory. Use the mouse to draw a rectangular mark. The output CSV files are saved immediately.

    Image Marker screenshot - mark

    If you're not happy with the mark position or size, draw it again. The previously drawn rectangle will disappear.

  4. Use the right arrow key to advance to the next image.

    You can also go back using the left arrow key.

  5. Type any characters on your keyboard to add a text note to an image. It will appear in blue by the bottom edge of the window. You can delete what you've typed using the backspace key.

    Image Marker screenshot - note

  6. Quit the program by pressing the esc key.

Mark post-processing

By default the values stored in the --marks and --output CSV files are the same.

However, it is possible to make some automatic adjustments to your marks. In this case, the original marks will be stored in the --marks CSV file and the post-processed marks in the --output CSV file.

There is currently one post-processing option:

Box

If you want to create a set of marks that all have the same aspect ratio, you can use the option --box-ratio to automatically draw a box around each mark with a specified aspect ratio. The box will be drawn symmetrically around the marked area as a green rectangle. If the box doesn't fit in the image, it will be moved in the image.

Image Marker screenshot - box

You can also add padding to the box using the option --box-padding. It is defined as a fraction of the marked rectangle width. For instance --box-padding 0.15 will result in a 30 px padding for a 200 px wide mark.

Image Marker screenshot - box with padding

Controls

  • right or down or enter: show next image
  • left orup: show previous image
  • left mouse click and drag: draw a mark
  • left mouse click (no drag): delete current mark
  • esc: exit the program (all marks are automatically saved)
  • letter and number keys: add text note to current image
  • backspace: delete the last character of the text note

Help

image-marker --help

Contributing

Feel free to remix this piece of software. See NOTICE and LICENSE for license information.

About

Mark rectangular areas in a batch of images and save the output as a CSV

Topics

Resources

License

Stars

Watchers

Forks