# Automatic Classification of Morphologically Similar Fish Species Using Their Head Contours
## 2 Materials and Methods
### Open Contour Extraction and Normalization  
As the fish were photographed following a certain protocol, they appear in the center of the image, in a horizontal position, with the dorsal fin at the top and the nose oriented to the left. To establish the fragment with relevant information, the expert introduced two marks in all images, one in the snout and the other in the starting point of the dorsal fin, indicating the limits of the contour fragment. These marks are in the background but close to the figure of the fish. Those images are our input data. At that point, the image processing is entirely conventional. Landmark detection can be done by colour. The landmark points are the references that make it possible to automatically crop the original images and thus isolate the profile of interest in a more straightforward and smaller image. In addition, the small size of the new images make the background color more uniform. Contour detection can also be established with a common algorithms presented in the _image processing toolbox_ of MATLAB.  
The first step is to convert the region of interest, the ROI, (a colour image) to a grey level in terms of luminance, and then binarize it. There are various methods that can be used to carry out a binarization, but they all depend on a threshold. In our particular case, we employed a global threshold computed using [PERSON]'s method, which chooses the threshold that minimizes the intraclass variance of black and white pixels [45]. There are more sophisticated methods that can be used to obtain the threshold, but this is the default option used by the function _imbinarize_ in the MATLAB image processing toolbox.  
In Figure 6, the sequential steps that are applied in order to obtain the contour segment of interest are shown, for a particular case; in Figure 6a the results of the binarization; in Figure 6b, the black holes in the white region are filled; in Figure 6c, the complement of the previous image; in Figure 6d,  
Figure 5: The images show the profiles of interest of the specimens in the database according to taxonomist criteria. (**a**) _Chelidonichthys cuculus_ (C.c#), (**b**) _Chelidonichthys lucerna_ (C.l#), (**c**) _Chelidonichthys obscurus_ (C.o#), (**d**) _Eutrigla gurnardus_ (E.g#), (**e**) _Lepidotrigla cavillone_ (L.c#), (**f**) _Lepidotrigla diuzeidei_ (L.d#), (**g**) _Peristedion calaphractum_ (P.c#), (**h**) _Trigla lyna_ (T.l#), and (**i**) _Triglporus lastoviza_ (T.l#).  
the black holes corresponding to the fish are filled; and in Figure 6e, the image is complemented once again to represent the fish in black and the background in white. In Figure 6f, the boundaries of the white region (in red) are found by exploring the image starting from the upper-left pixel and continuing in a downwards direction. In Figure 6g, the image borders are removed to find the contour of interest, which is the final result of the process. Finally, in the sub-image Figure 6h, the obtained result is shown overlapped against the original ROI.  
As will be seen, the method developed for this work is very robust to the high-frequency noise that can appear in the determination of contours. Notice that the binary image in Figure 6g can be used as a segmentation template to remove the background, as done in the compositions of Figures 4 and 5. After completing this step, the contour of the specimen \(i\), \(C^{i}\), is given by its two sequences of horizontal and vertical pixel positions in the cropped image. The origin was taken to be the first point of the open contour, which corresponds to the mark of the nose, and was assigned the (0,0) co-ordinate. The rest of the pixel positions are given relative to this first point and are grouped in the two series \(\left(h_{k},v_{k}\right)^{i}\). Each contour is represented by a different number of points \(N_{i}\). Figure 7 shows a cropped image where the contour of interest is delimited by the landmarks \(L_{1}\) and \(L_{2}\).