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.
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.
pip install --user --upgrade .
-
Put all the images you want to mark in a single directory.
-
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. -
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.
If you're not happy with the mark position or size, draw it again. The previously drawn rectangle will disappear.
-
Use the right arrow key to advance to the next image.
You can also go back using the left arrow key.
-
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.
-
Quit the program by pressing the esc key.
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:
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.
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.
- 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
image-marker --help
Feel free to remix this piece of software. See NOTICE and LICENSE for license information.