Image
Processors for image transformations
CastImage
paz.processors.image.CastImage(dtype)
Cast image to given dtype.
Arguments
- dtype: Str or np.dtype
SubtractMeanImage
paz.processors.image.SubtractMeanImage(mean)
Subtract channel-wise mean to image.
Arguments
- mean: List of length 3, containing the channel-wise mean.
AddMeanImage
paz.processors.image.AddMeanImage(mean)
Adds channel-wise mean to image.
Arguments
- mean: List of length 3, containing the channel-wise mean.
NormalizeImage
paz.processors.image.NormalizeImage()
Normalize image by diving all values by 255.0.
DenormalizeImage
paz.processors.image.DenormalizeImage()
Denormalize image by multiplying all values by 255.0.
LoadImage
paz.processors.image.LoadImage(num_channels=3)
Loads image.
Arguments
- num_channels: Integer, valid integers are: 1, 3 and 4.
RandomSaturation
paz.processors.image.RandomSaturation(lower=0.3, upper=1.5)
Applies random saturation to an image in RGB space.
Arguments
- lower: Float, lower bound for saturation factor.
- upper: Float, upper bound for saturation factor.
RandomBrightness
paz.processors.image.RandomBrightness(delta=32)
Adjust random brightness to an image in RGB space.
Arguments
- max_delta: Float.
RandomContrast
paz.processors.image.RandomContrast(lower=0.5, upper=1.5)
Applies random contrast to an image in RGB
Arguments
- lower: Float, indicating the lower bound of the random number to be multiplied with the BGR/RGB image.
- upper: Float, indicating the upper bound of the random number
to be multiplied with the BGR/RGB image.
RandomHue
paz.processors.image.RandomHue(delta=18)
Applies random hue to an image in RGB space.
Arguments
- delta: Int, indicating the range (-delta, delta ) of possible hue values.
ResizeImages
paz.processors.image.ResizeImages(shape)
Resize list of images.
Arguments
- size: List of two ints.
ResizeImages
paz.processors.image.ResizeImages(shape)
Resize list of images.
Arguments
- size: List of two ints.
RandomImageBlur
paz.processors.image.RandomImageBlur(probability=0.5)
Randomizes image quality
Arguments
- probability: Float between [0, 1]. Assigns probability of how often a random image blur is applied.
RandomGaussianBlur
paz.processors.image.RandomGaussianBlur(kernel_size=(5, 5), probability=0.5)
Randomizes image quality
Arguments
- probability: Float between [0, 1]. Assigns probability of how often a random image blur is applied.
RandomFlipImageLeftRight
paz.processors.image.RandomFlipImageLeftRight()
Randomly flip the image left or right
ConvertColorSpace
paz.processors.image.ConvertColorSpace(flag)
Converts image to a different color space.
Arguments
- flag: Flag found in
processors
indicating transform e.g.pr.BGR2RGB
ShowImage
paz.processors.image.ShowImage(window_name='image', wait=True)
Shows image in a separate window.
Arguments
- window_name: String. Window name.
- wait: Boolean
ImageDataProcessor
paz.processors.image.ImageDataProcessor(generator)
Wrapper for Keras ImageDataGenerator
Arguments
- generator: An instantiated Keras ImageDataGenerator
AlphaBlending
paz.processors.image.AlphaBlending()
Blends image to background using the image's alpha channel.
RandomImageCrop
paz.processors.image.RandomImageCrop(crop_factor=0.3, probability=0.5)
Crops randomly a rectangle from an image.
Arguments
- crop_factor: Float between
[0, 1]
. - probability: Float between
[0, 1]
.
RandomShapeCrop
paz.processors.image.RandomShapeCrop(shape)
Randomly crops a part of an image of always the same given shape
.
Arguments
- shape: List of two ints [height, width]. Dimensions of image to be cropped.
MakeRandomPlainImage
paz.processors.image.MakeRandomPlainImage(shape)
Makes random plain image by randomly sampling an RGB color.
Arguments
- shape: List of two ints [height, width]. Dimensions of plain image to be generated.
ConcatenateAlphaMask
paz.processors.image.ConcatenateAlphaMask()
Concatenates alpha mask to original image.
BlendRandomCroppedBackground
paz.processors.image.BlendRandomCroppedBackground(background_paths)
Blends image with a randomly cropped background.
Arguments
- background_paths: List of strings. Each element of the list is a full-path to an image used for cropping a background.
AddOcclusion
paz.processors.image.AddOcclusion(max_radius_scale=0.5, probability=0.5)
Adds a random occlusion to image by generating random vertices and drawing a polygon.
Arguments
- max_radius_scale: Float between [0, 1]. Value multiplied with largest image dimension to obtain the maximum radius possible of a vertex in the occlusion polygon.
- probability: Float between [0, 1]. Assigns probability of how often an occlusion to an image is generated.
TranslateImage
paz.processors.geometric.TranslateImage(fill_color=None)
Applies a translation of image. The translation is a list of length two indicating the x, y values.
Arguments
- fill_color: List of three integers indicating the
color values e.g.
[0, 0, 0]
ImageToNormalizedDeviceCoordinates
paz.processors.image.ImageToNormalizedDeviceCoordinates()
Map image value from [0, 255] -> [-1, 1].
NormalizedDeviceCoordinatesToImage
paz.processors.image.NormalizedDeviceCoordinatesToImage()
Map normalized value from [-1, 1] -> [0, 255].
ReplaceLowerThanThreshold
paz.processors.image.ReplaceLowerThanThreshold(threshold=1e-08, replacement=0.0)
GetNonZeroValues
paz.processors.image.GetNonZeroValues()
GetNonZeroArguments
paz.processors.image.GetNonZeroArguments()
FlipLeftRightImage
paz.processors.image.FlipLeftRightImage()
Flips an image left and right.
Arguments
- image: Numpy array.
DivideStandardDeviationImage
paz.processors.image.DivideStandardDeviationImage(standard_deviation)
Divide channel-wise standard deviation to image.
Arguments
- standard_deviation: List of length 3, containing the channel-wise standard deviation.
Properties
- standard_deviation: List.
Methods
call()
ScaledResize
paz.processors.image.ScaledResize(image_size)
Resizes image by returning the scales to original image.
Arguments
- image_size: Int, desired size of the model input.
Properties
- image_size: Int.
Methods
call()
BufferImages
paz.processors.image.BufferImages(input_size, stride=25)
Buffers an image to store and process multiple images.
Arguments
- input_size: Tuple of integers. Input shape to the model in following format: (frames, height, width, channels) e.g. (38, 96, 96, 3).
- stride: Integer, specifies after how many images the buffer will return the all buffered images. In a scenario with an already full buffer and a stride of 10, after each 10th call the buffer will be returned. The stride must be smaller than the frames (the first argument of the input_size).
Methods
call()
PadImage
paz.processors.image.PadImage(size, mode='constant')
Pads the image to the final size size
.
Arguments
- size: Int, final size of maximum dimension of the image.
- mode: Str, specifying the type of padding.
EqualizeHistogram
paz.processors.image.EqualizeHistogram(probability=0.5)
The Efficientpose implementation uses Histogram equalization algorithm from python Pillow library. This version of Histogram equalization produces slightly different results from that used in the paper.
InvertColors
paz.processors.image.InvertColors(probability=0.5)
Performs color / gray value inversion on a given image.
Arguments
- probability: Float, probability of data transformation.
Posterize
paz.processors.image.Posterize(probability=0.5, num_bits=4)
Performs posterization on a given image. This is achieved by reducing the bit depth of the gray value.
Arguments
- probability: Float, probability of data transformation.
- num_bits: Int, final bit depth after posterization.
Solarize
paz.processors.image.Solarize(probability=0.5, threshold=225)
Performs solarization on a given image. This is achieved
by inverting those pixels whose gray values lie above
a certain threshold
.
Arguments
- probability: Float, probability of data transformation.
- threshold: Int, threshold value.
SharpenImage
paz.processors.image.SharpenImage(probability=0.5)
Performs image sharpening by applying a high pass filter.
Arguments
- probability: Float, probability of data transformation.
- kernel: Array, the high pass filter.
Cutout
paz.processors.image.Cutout(probability=0.5, size=16, fill=128)
Cuts out a square of size size
x size
at a random location
in the image and fills it with fill
value.
Arguments
- probability: Float, probability of data transformation.
- size: Int, size of cutout square.
- fill: Int, value to fill cutout with.
AddGaussianNoise
paz.processors.image.AddGaussianNoise(probability=0.5, mean=0, scale=0.2)
Adds Gaussian noise defined by mean
and scale
to the image.
Arguments
- probability: Float, probability of data transformation.
- mean: Int, mean of Gaussian noise.
- scale: Int, percent of variance relative to 255 (max gray value of 8 bit image).