this repository contains some of my linear algebra projects that i gather them here.
seyedCV is a class that edits images using linear algebra methods.
here is it's functionality:
Explanation: The resize operation rescales the image by applying a scaling transformation. It achieves this by creating a grid of coordinates in the output image and applying the inverse transformation to these coordinates. The coordinates are divided by the scaling factors, resulting in a rescaled image. The rounding of coordinates ensures that the nearest pixel in the input image is obtained.
$ \begin{bmatrix} sx & 0 \ 0 & sy \ \end{bmatrix} $
Explanation: The rotate operation rotates the image by applying a rotation transformation. It begins by converting the rotation angle to radians. A grid of coordinates is then created in the output image. The coordinates are centered by subtracting the width and height of the image by 2. The inverse rotation transformation is applied to these coordinates using trigonometric functions. The shifted and rounded coordinates are then used to index the input image, resulting in a rotated image.
\begin{bmatrix}
cos(
Explanation: The sobel_filter operation applies a convolution operation to the image using a specific filter. Convolution involves element-wise multiplication of the filter and the image, followed by summing the results. This operation is a linear transformation in linear algebra. The sobel_filter operation utilizes a 3x3 filter matrix to detect edges in the image.
$ \begin{bmatrix} -1 & -2 & -1 \ 0 & 0 & 0 \ 1 & 2 & 0 \ \end{bmatrix} $
Explanation: The prewitt_filter operation also applies a convolution operation to the image using a specific filter. Similar to the sobel_filter operation, it involves element-wise multiplication of the filter and the image, followed by summing the results. This operation is a linear transformation in linear algebra. The prewitt_filter operation utilizes a 3x3 filter matrix to detect edges in the image.
\begin{bmatrix} -1 & 0 & 1 \ -1 & 0 & 1 \ -1 & 0 & 1 \ \end{bmatrix}
Explanation: The sharpen_filter operation applies a convolution operation to the image using a specific filter. It involves element-wise multiplication of the filter and the image, followed by summing the results. This operation is a linear transformation in linear algebra. The sharpen_filter operation utilizes a 3x3 filter matrix to enhance the sharpness of the image.
\begin{bmatrix} 0 & -1 & 0 \ -1 & -5 & -1 \ 0 & -5 & 0 \ \end{bmatrix}
Explanation: The blur_filter operation applies a convolution operation to the image using an averaging filter. Similar to the previous operations, it involves element-wise multiplication of the filter and the image, followed by summing the results. This operation is a linear transformation in linear algebra. The blur_filter operation utilizes a 5x5 averaging filter matrix to blur the image.
\begin{bmatrix} \frac{1}{25} & \frac{1}{25} & \frac{1}{25} & \frac{1}{25} & \frac{1}{25} \ \frac{1}{25} & \frac{1}{25} & \frac{1}{25} & \frac{1}{25} & \frac{1}{25} \ \frac{1}{25} & \frac{1}{25} & \frac{1}{25} & \frac{1}{25} & \frac{1}{25} \ \frac{1}{25} & \frac{1}{25} & \frac{1}{25} & \frac{1}{25} & \frac{1}{25} \ \frac{1}{25} & \frac{1}{25} & \frac{1}{25} & \frac{1}{25} & \frac{1}{25} \ \end{bmatrix}
Explanation: The invert_color operation applies a linear transformation to each pixel of the image. It subtracts the pixel value from 255 to invert the color. This operation is a linear transformation in linear algebra.
metrix: Please note that these are not matrices in the linear algebra sense, but rather operations applied to each pixel in the image.
R' = 255 - R
G' = 255 - G
B' = 255 - B
Explanation: The luminosity operation applies a linear transformation to each pixel of the image. It calculates the luminosity value of each pixel using a weighted sum of the RGB values. This operation is a linear transformation in linear algebra.
\begin{bmatrix} 0.2989 & 0.5870 & 0.1140 \ \end{bmatrix}
Explanation: The color_balance operation applies a linear transformation to each pixel of the image. It multiplies the RGB values of each pixel by the specified color balance factors and clips the result to the valid range. This operation is a linear transformation in linear algebra.
\begin{bmatrix} red scale & green scale & blue scale \ \end{bmatrix}
Explanation: This is achieved by dividing the pixel values of the image by 4 and then multiplying them by 4, effectively reducing the color depth to a quarter of its original value. This method is a simple form of quantization, which can significantly reduce the file size of an image at the cost of some loss in image quality.
This Python class, Eigen, calculates the eigenvalues and eigenvectors of a given square matrix. It supports matrices of size 2x2 and 3x3. The class also includes methods for plotting the eigenvalues and eigenvectors and for diagonalizing the matrix.
example: $ \begin{bmatrix} 6 & 5 \ 32 & 4 \end{bmatrix} $
This Python script provides a simple tool for visualizing the projection of one vector onto another using matplotlib. It includes two main functions: project for calculating the projection of a vector b onto another vector a, and plot for visualizing the vectors and their projection.
example: projecting b=[4,1]
on a=[5,0]