5  Linear Transformations

A linear transformation is a function that maps vectors from one vector space to another while preserving the basic operations within that vector space.

Linear transformation is applied in various aspects, such as geological modeling, mineral reserve calculations, excavation route optimization, and geotechnical structure analysis. By mastering this fundamental concept, mining engineering students are expected to develop the analytical skills needed to address challenges in the field and to carry out more efficient and safe mine planning.

5.1 2D Linear Transformation

2D transformations are operations that change the position, size, orientation, or shape of objects in a two-dimensional space. These transformations can be represented using matrices, allowing for efficient computation. A 2D linear transformation can be expressed in matrix form as:

\[ \mathbf{v}' = \mathbf{A} \cdot \mathbf{v} \]

Where:

  • \(\mathbf{v}\) is the original vector represented as a column vector:

\[ \mathbf{v} = \begin{pmatrix} x \\ y \end{pmatrix} \]

  • \(\mathbf{v}'\) is the transformed vector.
  • \(\mathbf{A}\) is a \(2 \times 2\) transformation matrix.

5.1.1 2D Rotation

Rotation is a linear transformation that rotates a vector around the origin \((0, 0)\) in a two-dimensional plane. In this context, we will rotate the vector \((2, 3)\) by 90 degrees.

The rotation matrix for a 90-degree rotation counterclockwise is:

\[ \begin{aligned} R_{90} &= \begin{pmatrix} \cos(90^\circ) & -\sin(90^\circ) \\ \sin(90^\circ) & \cos(90^\circ) \end{pmatrix} \\ &= \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} \end{aligned} \]

Applying this rotation matrix to the vector \((2, 3)\):

\[ \begin{aligned} R_{90} \begin{pmatrix} 2 \\ 3 \end{pmatrix} &= \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 2 \\ 3 \end{pmatrix} \\ &= \begin{pmatrix} -3 \\ 2 \end{pmatrix} \end{aligned} \]

After a 90-degree rotation, the vector \((2, 3)\) becomes \((-3, 2)\).

5.1.2 2D Reflection

Consider the original vector \((2, 3)\). We will calculate its reflections across the \(x\)-axis, \(y\)-axis, and the line \(y = x\).

  1. Reflection across the \(x\)-axis:

    \[ R_x(\mathbf{v}) = \begin{pmatrix} 2 \\ -3 \end{pmatrix} \]

  2. Reflection across the \(y\)-axis:

    \[ R_y(\mathbf{v}) = \begin{pmatrix} -2 \\ 3 \end{pmatrix} \]

  3. Reflection across the line \(y = x\):

    \[ R_{y=x}(\mathbf{v}) = \begin{pmatrix} 3 \\ 2 \end{pmatrix} \]

Thus, the reflection results for the vector \((2, 3)\) are:

  • Reflection across the \(x\)-axis: \((2, -3)\)
  • Reflection across the \(y\)-axis: \((-2, 3)\)
  • Reflection across the line \(y = x\): \((3, 2)\)

Let’s now visualize the reflections of the vector \((2, 3)\) across the \(x\)-axis and \(y\)-axis.

5.1.3 2D Scaling

Consider the original vector \((2, 3)\). We will scale this vector by different scalar factors, \(k = 2\) and \(k = 0.5\), to observe the effect of scaling.

  1. Scaling with Factor \(k = 2\):

    \[ SC_2(\mathbf{v}) = \begin{pmatrix} 2 \cdot 2 \\ 2 \cdot 3 \end{pmatrix} = \begin{pmatrix} 4 \\ 6 \end{pmatrix} \]

  2. Scaling with Factor \(k = 0.5\):

    \[ SC_{0.5}(\mathbf{v}) = \begin{pmatrix} 0.5 \cdot 2 \\ 0.5 \cdot 3 \end{pmatrix} = \begin{pmatrix} 1 \\ 1.5 \end{pmatrix} \]

Thus, the scaling results for the vector \((2, 3)\) are:

  • With factor \(k = 2: (4, 6)\)
  • With factor \(k = 0.5: (1, 1.5)\)

Let’s visualize the original vector \((2, 3)\) and its scaled results with factors \(k = 2\) and \(k = 0.5\).

5.1.4 2D Shearing

Consider the original vector \((2, 3)\), and we will perform horizontal shearing with a factor of \(k_x = 1.5\) and vertical shearing with a factor of \(k_y = 1.5\). The shearing results are calculated as follows:

  1. Horizontal Shearing with Factor \(k_x = 1.5\):

    \[ SH_h(2, 3) = \begin{pmatrix} 2 + 1.5 \cdot 3 \\ 3 \end{pmatrix} = \begin{pmatrix} 6.5 \\ 3 \end{pmatrix} \]

  2. Vertical Shearing with Factor \(k_y = 1.5\):

    \[ SH_v(2, 3) = \begin{pmatrix} 2 \\ 3 + 1.5 \cdot 2 \end{pmatrix} = \begin{pmatrix} 2 \\ 6 \end{pmatrix} \]

Thus, the shearing results for the vector \((2, 3)\) are:

  • Horizontal shearing with a factor of \(k_x = 1.5: (6.5, 3)\)
  • Vertical shearing with a factor of \(k_y = 1.5: (2, 6)\)

Now, let’s visualize the original vector \((2, 3)\) along with the shearing results with a factor of \(k_x = 1.5\) for horizontal and \(k_y = 1.5\) for vertical shearing.

5.1.5 2D Translation

Translation is a geometric transformation that shifts a vector by a specified distance along the x and y axes. It effectively changes the position of the vector without altering its shape or orientation. The transformation can be represented mathematically as follows:

If we have a vector \(\mathbf{v}\) represented by coordinates \((x, y)\), and we want to translate it by distances \(t_x\) in the x-direction and \(t_y\) in the y-direction, the translated vector \(\mathbf{v}'\) can be expressed as:

\[ T(\mathbf{v}) = \begin{pmatrix} x' \\ y' \end{pmatrix} = \begin{pmatrix} x + t_x \\ y + t_y \end{pmatrix} \]

Here: - \(x'\) and \(y'\) are the new coordinates of the vector after translation. - \(t_x\) is the translation distance along the x-axis. - \(t_y\) is the translation distance along the y-axis.

For example, if we have a vector \((2, 3)\) and we want to translate it by \(t_x = 5\) and \(t_y = -2\), the new vector will be calculated as follows:

\[ T(\mathbf{v}) = \begin{pmatrix} 2 + 5 \\ 3 - 2 \end{pmatrix} = \begin{pmatrix} 7 \\ 1 \end{pmatrix} \]

Thus, the vector \((2, 3)\) translated by \(t_x = 5\) and \(t_y = -2\) results in the new position \((7, 1)\).

5.2 3D Linear Transformation

Linear transformations in three dimensions can be represented using matrices and applied to vectors in 3D space. A linear transformation can include operations such as rotation, reflection, scaling, shearing, and translation.

A 3D linear transformation can be expressed in matrix form as:

\[ \mathbf{v}' = \mathbf{A} \cdot \mathbf{v} \]

Where:

  • \(\mathbf{v}\) is the original vector represented as a column vector:

\[ \mathbf{v} = \begin{pmatrix} x \\ y \\ z \end{pmatrix} \]

  • \(\mathbf{v}'\) is the transformed vector.
  • \(\mathbf{A}\) is a \(3 \times 3\) transformation matrix.

5.2.1 3D Rotation

Rotation in 3D space can be defined as the change in the position of a vector through a certain angle \((\theta)\) around one of the axes \((X, Y,\) or \(Z)\).

The 3D rotation can be performed using rotation matrices, which are defined for rotation around the \(X, Y,\) and \(Z\) axes as follows:

  1. Rotation around the X-axis: \[ R_x(\theta) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos(\theta) & -\sin(\theta) \\ 0 & \sin(\theta) & \cos(\theta) \end{bmatrix} \]

  2. Rotation around the Y-axis: \[ R_y(\theta) = \begin{bmatrix} \cos(\theta) & 0 & \sin(\theta) \\ 0 & 1 & 0 \\ -\sin(\theta) & 0 & \cos(\theta) \end{bmatrix} \]

  3. Rotation around the Z-axis: \[ R_z(\theta) = \begin{bmatrix} \cos(\theta) & -\sin(\theta) & 0 \\ \sin(\theta) & \cos(\theta) & 0 \\ 0 & 0 & 1 \end{bmatrix} \]

To rotate a vector \(\mathbf{v}\) around a specific axis, we multiply the vector by the corresponding rotation matrix. Suppose the vector \(\mathbf{v}\) is defined as:

\[ \mathbf{v} = \begin{bmatrix} x \\ y \\ z \end{bmatrix} \]

Then the resulting rotated vector \(\mathbf{v'}\) can be obtained using:

\[ \mathbf{v'} = R(\theta) \cdot \mathbf{v} \]

where \(R(\theta)\) is the rotation matrix corresponding to the chosen axis. Let’s consider the initial vector \((1, 2, 3)\) and perform a 3D rotation transformation. Observe the following visualization:

5.2.2 3D Reflection

Reflection in 3D space can be defined as the change in the position of a vector by flipping its components along a specific axis or plane. For example, if we reflect across the \(XY\) plane, the Z component of the vector will have its sign changed.

The reflection matrices for each coordinate plane in 3D are as follows:

  1. Reflection across the \(XY\) plane: \[ R_{XY} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & -1 \end{bmatrix} \]

  2. Reflection across the YZ plane: \[ R_{YZ} = \begin{bmatrix} -1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \]

  3. Reflection across the XZ plane: \[ R_{XZ} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \]

To reflect a vector \(\mathbf{v}\) across a specific plane, we multiply the vector by the corresponding reflection matrix. Suppose the vector \(\mathbf{v}\) is defined as:

\[ \mathbf{v} = \begin{bmatrix} x \\ y \\ z \end{bmatrix} \]

Then the resulting reflected vector \(\mathbf{v'}\) can be obtained using:

\[ \mathbf{v'} = R \cdot \mathbf{v} \]

where \(R\) is the reflection matrix corresponding to the selected plane. Let’s consider the initial vector \((1, 2, 3)\) and perform a 3D reflection transformation. Observe the following visualization:

5.2.3 3D Scaling

3D scaling enables us to increase or decrease the dimensions of an object according to our needs. This transformation can be applied uniformly, meaning the scaling factor remains consistent across all axes, or non-uniformly, where the scaling factors differ for each axis.

The scaling matrix in 3D space can be expressed in the following matrix form:

\[ S = \begin{bmatrix} s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & s_z \end{bmatrix} \]

Where: - \(s_x\), \(s_y\), and \(s_z\) are the scaling factors for the X, Y, and Z axes, respectively.

Suppose we have a vector \(\mathbf{v}\) represented as:

\[ \mathbf{v} = \begin{bmatrix} x \\ y \\ z \end{bmatrix} \]

After scaling, the new vector \(\mathbf{v'}\) can be obtained through:

\[ \mathbf{v'} = S \cdot \mathbf{v} = \begin{bmatrix} s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & s_z \end{bmatrix} \cdot \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} s_x \cdot x \\ s_y \cdot y \\ s_z \cdot z \end{bmatrix} \]

Uniform Scaling

Definition: Uniform scaling refers to a transformation that enlarges or shrinks an object in 3D space using the same scaling factor for all three axes (X, Y, and Z). This maintains the object’s proportions and shape, ensuring that the dimensions grow or shrink uniformly.

Mathematical Representation: The uniform scaling matrix can be represented as:

\[ S = \begin{bmatrix} s & 0 & 0 \\ 0 & s & 0 \\ 0 & 0 & s \end{bmatrix} \]

Where: -\(s\) is the uniform scaling factor.

Properties:

  • Proportionality: Since the same scaling factor is applied to all axes, the object retains its original shape and proportions. For example, a sphere remains a sphere, and a cube remains a cube.
  • Center of Scaling: The scaling occurs around a specified point, usually the origin (0, 0, 0), unless a different center is defined. Objects are enlarged or reduced in size relative to this center point.

Applications:

  • Modeling and Animation: Uniform scaling is commonly used in computer graphics to resize characters or objects without distorting their shapes. For example, enlarging a character model for a game scene while maintaining their proportions.
  • Architectural Visualization: In architectural design, uniform scaling can be applied to create models of buildings, allowing designers to maintain accurate proportions when resizing structures.
  • Simulation: In simulations, uniform scaling helps maintain realistic interactions between objects, such as when simulating physics.

Example: If an object (e.g., a cube) with dimensions \((1, 2, 3)\) is uniformly scaled by a factor of 2, the new dimensions will be \((2, 4, 6)\). The shape remains a cube, just larger.

Non-Uniform Scaling

Definition: Non-uniform scaling is a transformation that changes the dimensions of an object by applying different scaling factors to each of the three axes (X, Y, and Z). This can result in distortion, changing the object’s proportions and potentially altering its shape entirely.

Mathematical Representation: The non-uniform scaling matrix can be represented as:

\[ S = \begin{bmatrix} s_x & 0 & 0 \\ 0 & s_y & 0 \\ 0 & 0 & s_z \end{bmatrix} \]

Where:

  • \(s_x\) is the scaling factor for the X-axis.
  • \(s_y\) is the scaling factor for the Y-axis.
  • \(s_z\) is the scaling factor for the Z-axis.

Properties:

  • Distortion: Non-uniform scaling can stretch or compress an object differently along different axes, leading to a distortion of its original shape. For instance, a cube can become a rectangular prism or an elongated shape.
  • Independent Control: Each axis can be scaled independently, providing greater flexibility in design and manipulation. This is useful for creating complex shapes and adjusting models to fit specific requirements.

Applications:

  • Character Modeling: In character design, non-uniform scaling can create exaggerated features, such as a tall, thin character or a short, stocky character, by varying the scaling factors for each axis.
  • Animation: Non-uniform scaling is often used in animations to create effects such as stretching or squashing, which can add realism or stylization to animated characters and objects.
  • Industrial Design: In product design, non-uniform scaling can help designers adapt objects to fit functional requirements, such as making a part wider or thinner.

Example: Consider an object with dimensions \((1, 2, 3)\). If it undergoes non-uniform scaling with factors \(s_x = 2\), \(s_y = 1\), and \(s_z = 0.5\), the new dimensions will be \((2, 2, 1.5)\). The object’s shape will now be elongated along the X-axis, squashed along the Y-axis, and unchanged in the Z-axis.

5.2.4 3D Shearing

The shearing matrix in 3D space can be expressed in the following matrix form:

\[ H = \begin{bmatrix} 1 & sh_{xy} & sh_{xz} \\ sh_{yx} & 1 & sh_{yz} \\ sh_{zx} & sh_{zy} & 1 \end{bmatrix} \]

Where:

  • \(sh_{xy}\), \(sh_{xz}\), \(sh_{yx}\), \(sh_{yz}\), \(sh_{zx}\), and \(sh_{zy}\) are the shearing factors for each axis combination.

Let’s consider a vector \(\mathbf{v}\) expressed as:

\[ \mathbf{v} = \begin{bmatrix} x \\ y \\ z \end{bmatrix} \]

After shearing, the new vector \(\mathbf{v'}\) can be obtained through:

\[ \mathbf{v'} = H \cdot \mathbf{v} = \begin{bmatrix} 1 & sh_{xy} & sh_{xz} \\ sh_{yx} & 1 & sh_{yz} \\ sh_{zx} & sh_{zy} & 1 \end{bmatrix} \cdot \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} x + sh_{xy} \cdot y + sh_{xz} \cdot z \\ sh_{yx} \cdot x + y + sh_{yz} \cdot z \\ sh_{zx} \cdot x + sh_{zy} \cdot y + z \end{bmatrix} \]

Assuming we use the following shearing factors:

  • \(sh_{xy} = 0.5\)
  • \(sh_{xz} = 0.2\)
  • \(sh_{yx} = 0.1\)
  • \(sh_{yz} = 0.3\)
  • \(sh_{zx} = 0.4\)
  • \(sh_{zy} = 0.1\)

With the initial vector \(\mathbf{v} = \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix}\), we can calculate the new vector \(\mathbf{v'}\) as follows:

\[ \mathbf{v'} = H \cdot \mathbf{v} = \begin{bmatrix} 1 & 0.5 & 0.2 \\ 0.1 & 1 & 0.3 \\ 0.4 & 0.1 & 1 \end{bmatrix} \cdot \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix} \]

The result of the above calculation is:

\[ \mathbf{v'} = \begin{bmatrix} 2.6 \\ 3.0 \\ 3.6 \end{bmatrix} \]

Thus, the result of the shearing transformation on the vector \((1, 2, 3)\) is \((2.6, 3.0, 3.6)\).

Here is a visualization example of the original vector and the result of the shearing.

5.2.5 3D Translation

In the context of translation transformation, we can define the transformation as follows:

\[ \mathbf{v'} = T \cdot \mathbf{v} \]

where:

  • \(\mathbf{v}\) is the initial position vector,
  • \(\mathbf{v'}\) is the position vector after translation,
  • \(T\) is the translation matrix.

The translation matrix in 3D space can be expressed in the following augmented matrix form (adding a row for homogeneous coordinates):

\[ T = \begin{bmatrix} 1 & 0 & 0 & t_x \\ 0 & 1 & 0 & t_y \\ 0 & 0 & 1 & t_z \\ 0 & 0 & 0 & 1 \end{bmatrix} \]

Where:

  • \(t_x\), \(t_y\), and \(t_z\) are the translation distances along the X, Y, and Z axes, respectively.

Let’s consider a vector \(\mathbf{v}\) expressed as a homogeneous coordinate:

\[ \mathbf{v} = \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix} \]

After translation, the new vector \(\mathbf{v'}\) can be obtained through:

\[ \mathbf{v'} = T \cdot \mathbf{v} = \begin{bmatrix} 1 & 0 & 0 & t_x \\ 0 & 1 & 0 & t_y \\ 0 & 0 & 1 & t_z \\ 0 & 0 & 0 & 1 \end{bmatrix} \cdot \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix} = \begin{bmatrix} x + t_x \\ y + t_y \\ z + t_z \\ 1 \end{bmatrix} \]

Assuming we use the following translation distances:

  • \(t_x = 3\)
  • \(t_y = 2\)
  • \(t_z = 1\)

With the initial vector \(\mathbf{v} = \begin{bmatrix} 1 \\ 2 \\ 3 \\ 1 \end{bmatrix}\), we can calculate the new vector \(\mathbf{v'}\) as follows:

\[ \mathbf{v'} = T \cdot \mathbf{v} = \begin{bmatrix} 1 & 0 & 0 & 3 \\ 0 & 1 & 0 & 2 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 0 & 1 \end{bmatrix} \cdot \begin{bmatrix} 1 \\ 2 \\ 3 \\ 1 \end{bmatrix} \]

The result of the above calculation is:

\[ \mathbf{v'} = \begin{bmatrix} 4 \\ 4 \\ 4 \\ 1 \end{bmatrix} \]

Thus, the result of the translation transformation on the vector \((1, 2, 3)\) is \((4, 4, 4)\).

Here is a visualization example of the original vector and the result of the translation.

5.3 Case Study 1

Applying Scaling Transformation on an Image for Poster Design

5.3.1 Background

A graphic designer is creating a promotional poster for an event. They want to use the company logo, but the size and proportions don’t quite fit the poster layout. The designer uses scaling transformations to adjust the image size while preserving its original shape.

5.3.2 Objectives

  1. Create a version of the logo with uniform scaling to adjust the size while maintaining the original proportions.
  2. Create a version with non-uniform scaling to better fit specific dimensions on the poster.

5.3.3 Solution Steps

The designer used the following Python code to perform scaling transformations on the logo downloaded from a URL.

from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
import requests
from io import BytesIO

# Download and load the logo image
image_url = "https://github.com/dsciencelabs/images/blob/master/Logo_Dsciencelabs_v1.png?raw=true"
response = requests.get(image_url)
original_image = Image.open(BytesIO(response.content))

# Scaling transformation matrices
# Uniform scaling matrix (scaling factor = 1.5)
uniform_scale_factor = 1.5
uniform_scaling_matrix = np.array([
    [uniform_scale_factor, 0],
    [0, uniform_scale_factor]
])

# Non-uniform scaling matrix
non_uniform_scale_x = 1.2  # Scale width by 120%
non_uniform_scale_y = 0.8  # Scale height by 80%
non_uniform_scaling_matrix = np.array([
    [non_uniform_scale_x, 0],
    [0, non_uniform_scale_y]
])

# Function to apply scaling transformation
def apply_scaling(image, scaling_matrix):
    # Get the new dimensions
    width, height = image.size
    new_width = int(width * scaling_matrix[0, 0])
    new_height = int(height * scaling_matrix[1, 1])
    
    # Resize the image with the new dimensions
    return image.resize((new_width, new_height))

# Apply uniform and non-uniform scaling transformations
uniform_image = apply_scaling(original_image, uniform_scaling_matrix)
non_uniform_image = apply_scaling(original_image, non_uniform_scaling_matrix)

# Display the original and scaled images
fig, axes = plt.subplots(1, 3, figsize=(12, 4))
axes[0].imshow(original_image)
axes[0].set_title("Original Image")
axes[0].axis("off")

axes[1].imshow(uniform_image)
axes[1].set_title(f"Uniform Scaling ({uniform_scale_factor * 100:.0f}%)")
axes[1].axis("off")

axes[2].imshow(non_uniform_image)
axes[2].set_title(f"Non-uniform Scaling (Width {non_uniform_scale_x * 100:.0f}%, Height {non_uniform_scale_y * 100:.0f}%)")
axes[2].axis("off")

plt.tight_layout()
plt.show()

5.4 Case Study 2

Counting Lights in a City Night Image

In this case study, we explore how to estimate the number of lights in a nighttime photograph of an urban area using image processing techniques. This method can help city planners assess energy consumption and plan for energy-saving initiatives.

5.4.1 Problem Context

A city planner needs to evaluate energy usage in a specific urban area by counting the number of lights visible in a photograph taken at night. This estimation can help in planning energy-saving measures. We use an image analysis approach that involves several steps, such as contrast enhancement and object detection, to identify the lights.

5.4.2 Steps of the Analysis

  1. Image Processing: The original photograph is converted to grayscale to simplify light detection by reducing color complexity.
  2. Contrast Adjustment: A linear transformation is applied to enhance the contrast, making bright areas (lights) more distinguishable from dark areas.
  3. Thresholding: Using Otsu’s method, the image is binarized, converting bright spots to white and dark areas to black.
  4. Object Counting: Connected bright regions are identified and counted as individual lights.

5.4.3 Code Implementation

Below is the Python code used to perform these steps:

from PIL import Image
import requests
from io import BytesIO
import numpy as np
import matplotlib.pyplot as plt
from skimage import measure, color, filters

# Load the image
image_url = "https://github.com/dsciencelabs/images/blob/master/jogja.jpg?raw=true"
response = requests.get(image_url)
image = Image.open(BytesIO(response.content))

# Convert to grayscale
gray_image = image.convert("L")

# Convert image to numpy array
image_matrix = np.array(gray_image)

# Apply linear transformation to increase contrast
a, b = 2, -100  # Adjust as needed
transformed_image = np.clip(a * image_matrix + b, 0, 255).astype(np.uint8)

# Apply thresholding
threshold_value = filters.threshold_otsu(transformed_image)
binary_image = transformed_image > threshold_value

# Count bright objects using connected components
labels = measure.label(binary_image)
lamp_count = labels.max()

# Display results
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
axes[0].imshow(gray_image, cmap="gray")
axes[0].set_title("Original Grayscale Image")
axes[0].axis("off")

axes[1].imshow(transformed_image, cmap="gray")
axes[1].set_title("Transformed Image")
axes[1].axis("off")

axes[2].imshow(color.label2rgb(labels, bg_label=0))
axes[2].set_title(f"Detected Lights (Count: {lamp_count})")
axes[2].axis("off")

plt.tight_layout()
plt.show()

5.5 Case Study 3

Seasonal Production Demand Adjustment

5.5.1 Background

A manufacturing company operates three production facilities (A, B, and C) that produce the same product. Each facility has different initial production capacities, and seasonal demand variations require adjustments in their production levels. The company aims to optimize production by applying linear transformations (scaling, rotation, and translation) to meet the increased seasonal demand efficiently.

5.5.2 Given Data

The initial production capacities (in tons per day) and seasonal scaling factors for each facility are as follows:

Facility Initial Production (tons/day) Seasonal Scaling Factor
Facility A 100 1.2
Facility B 80 1.5
Facility C 60 1.3

Additionally, to shift production focus, Facility B will undergo a rotation transformation of 30 degrees around the z-axis. There is also a baseline increase in demand across all facilities represented by a translation vector that adds 10 tons/day to each facility’s production.

5.5.3 Problem Statement

  1. Calculate the new production capacities after applying the scaling transformation based on the given seasonal scaling factors.

  2. Determine the new production capacities after applying the rotation transformation around the z-axis for the adjusted production levels of Facility B.

  3. What will be the final production capacities for each facility after applying the translation vector that accounts for the increased demand?

  4. If the production capacity of Facility C is limited to a maximum of 80 tons/day, how would this limitation affect the overall production and demand fulfillment for the company?

  5. Discuss how applying these linear transformations can help the company respond to seasonal demand changes effectively.

5.5.4 Solution

  1. Scaling Transformation

We calculate the new production capacities by applying the scaling factors:

  • Facility A: ( 100 = 120 ) tons/day
  • Facility B: ( 80 = 120 ) tons/day
  • Facility C: ( 60 = 78 ) tons/day

The new production capacities after scaling are:

Facility New Production (tons/day)
Facility A 120
Facility B 120
Facility C 78
  1. Rotation Transformation

To apply the rotation transformation for Facility B, we need to perform the rotation around the z-axis by 30 degrees. In this case, since we are focusing on production capacity (not coordinates), we can assume that rotation will not affect the capacity directly, but it will affect the distribution of production. Thus, the production remains:

  • Facility B: 120 tons/day (no capacity change due to rotation)
  1. Final Production Capacities

After applying a translation vector that adds 10 tons/day to each facility, we calculate:

  • Facility A: ( 120 + 10 = 130 ) tons/day
  • Facility B: ( 120 + 10 = 130 ) tons/day
  • Facility C: ( 78 + 10 = 88 ) tons/day

The final production capacities are:

Facility Final Production (tons/day)
Facility A 130
Facility B 130
Facility C 88
  1. Capacity Limitation for Facility C

If Facility C’s production capacity is limited to 80 tons/day, we must adjust its final capacity:

  • Facility A: 130 tons/day
  • Facility B: 130 tons/day
  • Facility C: 80 tons/day (limited)

Thus, the new final capacities are:

Facility Adjusted Final Production (tons/day)
Facility A 130
Facility B 130
Facility C 80
  1. Discussion on Linear Transformations

Applying linear transformations such as scaling, rotation, and translation allows the company to effectively adjust their production capacities in response to seasonal demand changes. Scaling helps in increasing production levels, while rotation allows for adjusting the focus of production without changing the overall capacity. Translation reflects an increase in demand, ensuring that the facilities can adapt to meet market requirements efficiently. Such methods are crucial for optimizing resource utilization and enhancing operational efficiency in a dynamic production environment.

5.6 Linear Transformations in Python

Klik here