ImageProcessing

From SweepMe! Wiki
Jump to navigation Jump to search

The ImageProcessing module is a versatile tool within SweepMe! that enables users to load an image and apply a variety of transformation steps using OpenCV (cv2) functionalities. This module simplifies image manipulation by allowing users to create custom processing pipelines tailored to their needs. It is ideal for automating image processing tasks in research, testing, or other technical applications.

Key Features

  • Flip: Flip the image horizontally, vertically, or both.
  • Threshold: Apply a binary or adaptive threshold to emphasize or isolate image features.
  • Crop: Select and retain a specific region of the image while discarding the rest.
  • Gray Scale: Convert the image to gray scale for simpler processing or analysis.
  • Gamma Correction: Adjust the brightness and contrast of the image using gamma correction.
  • Invert: Invert the colors of the image, transforming it to a negative form.
  • Blur: Apply blurring filters such as Gaussian blur to reduce noise or detail.
  • Resize: Resize the image to desired dimensions for uniform scaling or downsampling.
  • Save: Save the processed image in a format of your choice: PNG, JPG, or TIFF.

Processing Pipeline

One of the most powerful features of the ImageProcessing module is the ability to create a customizable processing pipeline. Users can:

  • Add multiple transformation steps to the pipeline, with the flexibility to use each step more than once or not at all.
  • Adjust the parameters of each transformation to fine-tune the image processing workflow.
  • Rearrange the order of the steps to achieve different results based on the desired processing sequence.

Hotkeys

The ImageProcessing module supports several keyboard shortcuts to streamline the management of your processing pipeline:

  • PageUp/PageDown: Move the selected processing step up or down in the pipeline order.
  • Del: Delete the currently selected processing step from the pipeline.
  • Arrow Keys: Navigate between steps in the pipeline using the up, down, left, and right arrow keys.


Processing Steps

The ImageProcessing module provides various transformation steps that can be applied to an image. Each step has configurable parameters that allow users to customize the behavior of the transformation. Below is an explanation of each processing step.

Flip

The Flip step allows users to flip an image vertically, horizontally, or both.

Parameters:

  • Vertical: A boolean parameter (True/False) that, when set to True, flips the image vertically.
  • Horizontal: A boolean parameter (True/False) that, when set to True, flips the image horizontally.

This step is useful for mirroring images or correcting image orientation.

Threshold

The Threshold step applies a binary threshold to an image, setting pixel values above a certain threshold to 255 (white) and those below to 0 (black).

Parameters:

  • Threshold: The pixel intensity value above which pixels are set to 255.
  • Otsu's Method: A boolean parameter. If set to True, Otsu's method is used to automatically calculate the optimal threshold. In that case the given threshold value will be ignored.

This step is useful for isolating objects or regions of interest based on intensity.

Crop

The Crop step allows users to crop the image by specifying cutoffs for the left, right, top, and bottom edges.

Parameters:

  • Mode: Choose between "Pixel" and "Percentage" modes for defining the crop dimensions.
  • Left: The number of pixels or percentage to crop from the left side of the image.
  • Right: The number of pixels or percentage to crop from the right side of the image.
  • Top: The number of pixels or percentage to crop from the top of the image.
  • Bottom: The number of pixels or percentage to crop from the bottom of the image.

This step is useful for focusing on a particular region of the image.

Gray Scale

The Gray Scale step converts an image to grayscale by removing all color information and reducing the image to shades of gray.

This step is useful when analyzing patterns based on intensity rather than color.

Gamma

The Gamma step applies gamma correction to an image, adjusting its brightness.

Parameters:

  • Value: The gamma value for correction. A value of 1.0 makes no change, values less than 1.0 darken the image, and values greater than 1.0 brighten the image.

This step is useful for enhancing contrast in images with uneven brightness distributions.

Invert

The Invert step inverts the colors of the image, creating a negative of the original.

This step is useful for visualizing features that may be more distinguishable in a negative form.

Blur

The Blur step applies a blurring effect to the image, reducing noise or detail.

Parameters:

  • Mode: Choose between "Gaussian" or "Median" blur.
  • Value in px: The strength of the blur, measured in pixels.

This step is useful for smoothing images and reducing unwanted details or noise.

Resize

The Resize step resizes an image either by scaling it or setting a specific width or height. The image is uniformly scaled, meaning the aspect ratio is preserved.

Parameters:

  • Mode: Choose between "Factor," "Width in px," or "Height in px."
  • Value: The factor by which to scale the image or the target width/height in pixels.

This step is useful for standardizing image sizes or downscaling large images for further processing.

Save

The Save step saves the processed image to a specified file path in the desired format.

Parameters:

  • Path: The destination path where the image will be saved.
  • Format: Choose between ".jpg," ".png," or ".tiff" formats.

This step is useful for storing the final processed image for future use.

Save Options

Once the image processing is complete, users can save the image in the desired format, choosing between PNG, JPG, or TIFF file formats, depending on their use case or quality requirements.

Images are temporarily saved throughout the image processing workflow. The final images are permanently saved when the user saves the measurement data in SweepMe!.

There is also a parameter called Save all. When this option is checked, all converted images throughout the pipeline are saved, with an increasing counter appended to each file name (e.g., image_1, image_2, etc.). This ensures that every transformation step is preserved.

If Save all is not checked, only the last converted image in the pipeline is saved. This helps conserve memory by avoiding the storage of intermediate images, which can be beneficial when processing large image sets.

Application

The ImageProcessing module is perfect for engineers, scientists, and developers who need to automate image transformation tasks for analysis, testing, or documentation. Whether it’s simplifying an image for measurement, enhancing visibility, or preparing images for reports, this module offers a comprehensive solution.