Project 0028

by Sousa S

Description

The program I created for my final project was actually developed to solve a problem I had at work. It might not be the most exciting to others, but it saved several hours of work :) I needed to recreate thousands of files (.box files) using information that was present in another type of file (.star files). Box files encode the positions of rectangles of a certain dimension in an image. They are composed of 4 columns, that correspond to: the x- (column 1) and y- coordinates (column 2) of the top, left corner of a rectangle with sides of length w (column 3) and h (column 4). For the purpose of my work, the boxes are always squares (column 3 = column 4). An example is shown below. Star files contain much more information than box files, but include also x- and y- coordinates. This coordinates correspond to the centre of the rectangles found in the box files. Star files can be divided in two parts: a header, where the titles of each column are given, and a body, where each line corresponds to one instance in the image. An example is shown below, with one line highlighted. The program I wrote allows to create in one run box files from multiple star files present in a directory indicated by the user and with the box size chosen by the user (columns 3 and 4). The program recognises which columns in the star file correspond to the x- and y-coordinates by reading the information from the header. Then, for each line in the body of the star file, the x- and y-coordinates are corrected to point, not to the centre of the square, but to its top, left corner (columns 1 and 2); a new line is appended to a box file that has the same name as the star file (but different extension; .box).