Point Operations

Definition

Def Point Operation Point operation or histogram operation is an operation such that the output of such transformation only depends on the the corresponding input pixel (intensity, color) value. In other words, it’s context free, can be performed on the image histogram. A point operation can be defined as a mapping: where stands for pixel gray scale/intensity values. e.g. Globally adjust brightness and contrast: .

Definition

Def Image Histogram The histogram of a digital image with gray values is the discrete function where is the number of pixels with gray value and is the total number of pixels in the image. If we consider the gray values in the image as realizations of a random variable with some probability density, histogram provides an approximation to this probability density.

Remark

Usually, we require maps the full gray-level range ( levels) to its full range while keeping the gray-level order, should be non-decreasing monotonic. We also need the area under between and is equal to the area under between and .

Definition

Def Power-Law Transformation Power law transformation is a family of point operations such thate.g. If , the image will be brightened, if , the image will be darkened.

Histogram Equalization

Comment

For a better visual discrimination of an image, we would like to reassign gray-levels so that gray-level resource will be optimally assigned. That is

  • The transformed histogram is as flat as possible.
  • The order of gray-levels is maintained.
  • The histogram bars are not fragmented.

Algorithm

Algorithm Histogram Equalization

  1. For images with discrete gray values, compute:where is total number of gray levels, is the number of pixels with intensity , is total number of pixels in the image.
  2. Based on CDF, compute the transformation:
  3. Now define and we assign . he|450

Attention

Histogram equalization may not always produce desirable results, particularly if the given histogram is very narrow. It can produce false edges and regions. It can also increase image “graininess” and “patchiness.”

Neighborhood Operations

Definition

Def Neighborhood Operation Operation depends on Pixel’s value and its spatial neighbors (coordinates-dependent) is called neighborhood operation. It’s context dependent. e.g. Image denoising.

Geometric Operations

Def Geometric Operation Geometric operation is an operation that applied on pixel’s coordinates, independent of pixels gray scale/intensity value. e.g. Translation of an image.

Def Image Warping Image warping is the operation that change the spatial domain of an image. e.g. |400

Algorithm

Algorithm Forward Warping Iterate over source, copy pixel intensity value or color at source image to target image . It has the following facts:

  • Some source pixels map to the same target pixel.
  • Some target pixels may have no corresponding source.
  • Holes in reconstruction.

Algorithm

Algorithm Inverse Warping Iterate over target image, finding pixels from source. It has the following facts:

  • Non-integer evaluation source image, resample.
  • May over sample source.
  • But no holes.
  • In general simpler, better than forward mapping.
def bilinear_interpolate(image, x, y):
   # Get the integer and fractional parts of the coordinates
   x_int, y_int = int(x), int(y)
   x_frac, y_frac = x - x_int, y - y_int
   # Get the four nearest pixels
   top_left = image[y_int, x_int]
   top_right = image[y_int, x_int+1] if x_int+1 < image.shape[1] else top_left
   bottom_left = image[y_int+1, x_int] if y_int+1 < image.shape[0] else top_left
   bottom_right = image[y_int+1, x_int+1] if x_int+1 < image.shape[1] and y_int+1 < image.shape[0] else top_left
   # Interpolate between the four pixels
   top = top_left + x_frac * (top_right - top_left)
   bottom = bottom_left + x_frac * (bottom_right - bottom_left)
   pixel_value = top + y_frac * (bottom - top)
   return pixel_value
 
def inverse_warp(image, inv_transform_matrix, output_size):
   warped_image = np.zeros(output_size, dtype=np.uint8)
   # Iterate over each pixel in the output image
   for y in range(output_size[0]):
       for x in range(output_size[1]):
           # Apply the inverse transformation matrix to get the original image coordinates
           original_coord = np.dot(inv_transform_matrix, np.array([y, x, 1]))
           original_coord = original_coord / original_coord[2]
           # Perform bilinear interpolation if the coordinate falls within the input image bounds
           if 0 <= original_coord[0] < image.shape[0] and 0 <= original_coord[1] < image.shape[1]:
               warped_image[y, x] = bilinear_interpolate(image, original_coord[1], original_coord[0])   
   return warped_image
 
# Load an image
input_image = cv2.imread('image')
# Define an inverse transformation matrix
inv_transform_matrix = np.linalg.inv(np.array([[0, 1, 0],[-1, 0, 0],[0, 0, 1]]))
inv_transform_matrix[0, 2] = input_image.shape[0]
# Define the output image size
output_size = (input_image.shape[1], input_image.shape[0], 3)
# Get the transformed image
transformed_image = inverse_warp(input_image, inv_transform_matrix, output_size)
plt.imshow(transformed_image)
plt.show()

Def Scaling Scaling a coordinate means multiplying each of its components by a scalar. Uniform scaling means this scalar is the same for all components:

Def Rotation Rotating a coordinate by is defined as

Def Affine Transformation Affine transformation is defined as follows:

Def Shear Shear is a special case of affine transformation:

Def Projection Projection is defined as follows: proj|430

Def Control Points Unique points in the reference and target images. The coordinates of corresponding control points in images are used to determine a transformation function.