In this section, let us see the different types of transformations that can be applied to images to generate synthetic data when there is a limited amount of data. In machine learning, shearing and flipping are often used as image augmentation techniques to increase the diversity of training data. It helps improve a model’s ability to recognize objects from different angles or orientations.
Shearing can be used in computer vision tasks to correct for perspective distortion in images. For example, it can be applied to rectify skewed text in scanned documents.
Image shearing is a transformation that distorts an image by moving its pixels in a specific direction. It involves shifting the pixels of an image along one of its axes while keeping the other axis unchanged. There are two primary types of shearing:
- Horizontal shearing: In this case, pixels are shifted horizontally, usually in a diagonal manner, causing an image to slant left or right
- Vertical shearing: Here, pixels are shifted vertically, causing an image to slant up or down
To perform image shearing, you typically specify the amount of shear (the extent of distortion) and the direction (horizontal or vertical). The amount of shear is usually defined as a shear angle or shear factor.
Image shearing is typically accomplished using a shear matrix. For example, in 2D computer graphics, a horizontal shear matrix might look like this:
| 1 shear_x |
| 0 1 |
Here, shear_x represents the amount of horizontal shearing applied.
By applying a random shearing transformation to an image, we can generate multiple versions of the image with slightly different pixel values. These variations can provide a useful way to identify visual patterns or features that are characteristic of an object.
Similarly, image flipping is another transformation that can be useful to identify flowers. By flipping an image horizontally or vertically, we can generate new versions of an image that may contain different visual patterns or features. For example, we could use an LF that checks whether an image is flipped along a certain axis, labeling images that are flipped as positively depicting flowers. This LF would be able to capture the fact that many flowers have bilateral symmetry, meaning that they look similar when mirrored along a particular axis.
Overall, by applying image transformations such as shearing or flipping, we can generate a larger number of labeled examples that capture different aspects of the image content. This can help to increase the accuracy of the classification model by providing more varied and robust training data.
We will further explore image transformation along with other data augmentation techniques and examples in the next chapter.
Summary
In this chapter, we embarked on an enlightening journey into the world of image labeling and classification. We began by mastering the art of creating labeling rules through manual inspection, tapping into the extensive capabilities of Python. This newfound skill empowers us to translate visual intuition into valuable data, a crucial asset in the realm of machine learning.
As we delved deeper, we explored the intricacies of size, aspect ratio, bounding boxes, and polygon and polyline annotations. We learned how to craft labeling rules based on these quantitative image characteristics, ushering in a systematic and dependable approach to data labeling.
Our exploration extended to the transformative realm of image manipulation. We harnessed the potential of image transformations such as shearing and flipping, enhancing our labeling process with dynamic versatility.
Furthermore, we applied our knowledge to real-world scenarios, classifying plant disease images using rule-based LFs. We honed our skills in predicting objects by leveraging aspect ratio and contour height, a valuable asset in scenarios such as identifying a person riding a bicycle. Additionally, we delved into the powerful domain of pre-trained models and transfer learning for image classification.
But our journey is far from over. In the upcoming chapter, we will dive even deeper into the realm of image data augmentation. We’ll explore advanced techniques and learn how to perform image classification using augmented data with support vector machines (SVMs) and convolutional neural networks (CNNs). Get ready for the next exciting chapter!