src.operations.point package¶
Submodules¶
src.operations.point.img_calculator module¶
- class src.operations.point.img_calculator.ImageCalculator(images)¶
Bases:
PyQt5.QtWidgets.QDialog,src.operations.point.img_calculator_ui.ImageCalculatorUIThe ImageCalculator class represents a calculator between two images.
- OPERATIONS = {'AND': <built-in function bitwise_and>, 'Add': <built-in function add>, 'OR': <built-in function bitwise_or>, 'Subtract': <built-in function subtract>, 'XOR': <built-in function bitwise_xor>}¶
- accept_changes()¶
Accept changed image data to the original one.
- calculate(img1_data, img2_data, operation_name)¶
Perform specified operation between two images.
Available operations are in
OPERATIONS.- Parameters
img1_data (class:numpy.ndarray) – The first image data to perform calculation
img2_data (class:numpy.ndarray) – The second image data to perform calculation
operation_name (str) – The operation name to perform between images
- Returns
The new calculated image data
- Return type
class:numpy.ndarray
- update_calculation()¶
Update calculation whenever changed form.
Get the image data based on chosen images.
Resize the image if the radio button is checked.
Validate images.
Perform calculations based on chosen operations and images.
- update_form()¶
Update the image weights and gamma form access, which is available only for Blend operation.
- update_gamma_range()¶
Validate the gamma spin box to be in the color depth range of the first image.
- update_img_preview(img_data)¶
Update image preview window.
Reload image preview using the base
operation.Operationmethod.
- update_rbtns()¶
Validate only one radio button to be checked.
- static validate_images(img1_data, img2_data)¶
Validate images whether they match to perform the calculation.
The images must have the same:
Dimensions.
Number of channels.
Color depth.
True if the images match to calculation, False otherwise.
- Parameters
img1_data (class:numpy.ndarray) – The first image data to validate
img2_data (class:numpy.ndarray) – The second image data to validate
- Returns
The status of validation. (match, fail message) - (bool, str)
- Return type
tuple
- src.operations.point.img_calculator.add(src1, src2[, dst[, mask[, dtype]]]) → dst¶
. @brief Calculates the per-element sum of two arrays or an array and a scalar. . . The function add calculates: . - Sum of two arrays when both input arrays have the same size and the same number of channels: . f[texttt{dst}(I) = texttt{saturate} ( texttt{src1}(I) + texttt{src2}(I)) quad texttt{if mask}(I) ne0f] . - Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of . elements as src1.channels(): . f[texttt{dst}(I) = texttt{saturate} ( texttt{src1}(I) + texttt{src2} ) quad texttt{if mask}(I) ne0f] . - Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of . elements as src2.channels(): . f[texttt{dst}(I) = texttt{saturate} ( texttt{src1} + texttt{src2}(I) ) quad texttt{if mask}(I) ne0f] . where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each . channel is processed independently. . . The first function in the list above can be replaced with matrix expressions: . @code{.cpp} . dst = src1 + src2; . dst += src1; // equivalent to add(dst, src1, dst); . @endcode . The input arrays and the output array can all have the same or different depths. For example, you . can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit . floating-point array. Depth of the output array is determined by the dtype parameter. In the second . and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can . be set to the default -1. In this case, the output array will have the same depth as the input . array, be it src1, src2 or both. . @note Saturation is not applied when the output array has the depth CV_32S. You may even get . result of an incorrect sign in the case of overflow. . @param src1 first input array or a scalar. . @param src2 second input array or a scalar. . @param dst output array that has the same size and number of channels as the input array(s); the . depth is defined by dtype or src1/src2. . @param mask optional operation mask - 8-bit single channel array, that specifies elements of the . output array to be changed. . @param dtype optional depth of the output array (see the discussion below). . @sa subtract, addWeighted, scaleAdd, Mat::convertTo
- src.operations.point.img_calculator.addWeighted(src1, alpha, src2, beta, gamma[, dst[, dtype]]) → dst¶
. @brief Calculates the weighted sum of two arrays. . . The function addWeighted calculates the weighted sum of two arrays as follows: . f[texttt{dst} (I)= texttt{saturate} ( texttt{src1} (I)* texttt{alpha} + texttt{src2} (I)* texttt{beta} + texttt{gamma} )f] . where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each . channel is processed independently. . The function can be replaced with a matrix expression: . @code{.cpp} . dst = src1*alpha + src2*beta + gamma; . @endcode . @note Saturation is not applied when the output array has the depth CV_32S. You may even get . result of an incorrect sign in the case of overflow. . @param src1 first input array. . @param alpha weight of the first array elements. . @param src2 second input array of the same size and channel number as src1. . @param beta weight of the second array elements. . @param gamma scalar added to each sum. . @param dst output array that has the same size and number of channels as the input arrays. . @param dtype optional depth of the output array; when both input arrays have the same depth, dtype . can be set to -1, which will be equivalent to src1.depth(). . @sa add, subtract, scaleAdd, Mat::convertTo
- src.operations.point.img_calculator.bitwise_and(src1, src2[, dst[, mask]]) → dst¶
. @brief computes bitwise conjunction of the two arrays (dst = src1 & src2) . Calculates the per-element bit-wise conjunction of two arrays or an . array and a scalar. . . The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for: . * Two arrays when src1 and src2 have the same size: . f[texttt{dst} (I) = texttt{src1} (I) wedge texttt{src2} (I) quad texttt{if mask} (I) ne0f] . * An array and a scalar when src2 is constructed from Scalar or has . the same number of elements as src1.channels(): . f[texttt{dst} (I) = texttt{src1} (I) wedge texttt{src2} quad texttt{if mask} (I) ne0f] . * A scalar and an array when src1 is constructed from Scalar or has . the same number of elements as src2.channels(): . f[texttt{dst} (I) = texttt{src1} wedge texttt{src2} (I) quad texttt{if mask} (I) ne0f] . In case of floating-point arrays, their machine-specific bit . representations (usually IEEE754-compliant) are used for the operation. . In case of multi-channel arrays, each channel is processed . independently. In the second and third cases above, the scalar is first . converted to the array type. . @param src1 first input array or a scalar. . @param src2 second input array or a scalar. . @param dst output array that has the same size and type as the input . arrays. . @param mask optional operation mask, 8-bit single channel array, that . specifies elements of the output array to be changed.
- src.operations.point.img_calculator.bitwise_or(src1, src2[, dst[, mask]]) → dst¶
. @brief Calculates the per-element bit-wise disjunction of two arrays or an . array and a scalar. . . The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for: . * Two arrays when src1 and src2 have the same size: . f[texttt{dst} (I) = texttt{src1} (I) vee texttt{src2} (I) quad texttt{if mask} (I) ne0f] . * An array and a scalar when src2 is constructed from Scalar or has . the same number of elements as src1.channels(): . f[texttt{dst} (I) = texttt{src1} (I) vee texttt{src2} quad texttt{if mask} (I) ne0f] . * A scalar and an array when src1 is constructed from Scalar or has . the same number of elements as src2.channels(): . f[texttt{dst} (I) = texttt{src1} vee texttt{src2} (I) quad texttt{if mask} (I) ne0f] . In case of floating-point arrays, their machine-specific bit . representations (usually IEEE754-compliant) are used for the operation. . In case of multi-channel arrays, each channel is processed . independently. In the second and third cases above, the scalar is first . converted to the array type. . @param src1 first input array or a scalar. . @param src2 second input array or a scalar. . @param dst output array that has the same size and type as the input . arrays. . @param mask optional operation mask, 8-bit single channel array, that . specifies elements of the output array to be changed.
- src.operations.point.img_calculator.bitwise_xor(src1, src2[, dst[, mask]]) → dst¶
. @brief Calculates the per-element bit-wise “exclusive or” operation on two . arrays or an array and a scalar. . . The function cv::bitwise_xor calculates the per-element bit-wise logical “exclusive-or” . operation for: . * Two arrays when src1 and src2 have the same size: . f[texttt{dst} (I) = texttt{src1} (I) oplus texttt{src2} (I) quad texttt{if mask} (I) ne0f] . * An array and a scalar when src2 is constructed from Scalar or has . the same number of elements as src1.channels(): . f[texttt{dst} (I) = texttt{src1} (I) oplus texttt{src2} quad texttt{if mask} (I) ne0f] . * A scalar and an array when src1 is constructed from Scalar or has . the same number of elements as src2.channels(): . f[texttt{dst} (I) = texttt{src1} oplus texttt{src2} (I) quad texttt{if mask} (I) ne0f] . In case of floating-point arrays, their machine-specific bit . representations (usually IEEE754-compliant) are used for the operation. . In case of multi-channel arrays, each channel is processed . independently. In the 2nd and 3rd cases above, the scalar is first . converted to the array type. . @param src1 first input array or a scalar. . @param src2 second input array or a scalar. . @param dst output array that has the same size and type as the input . arrays. . @param mask optional operation mask, 8-bit single channel array, that . specifies elements of the output array to be changed.
- src.operations.point.img_calculator.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]]) → dst¶
. @brief Resizes an image. . . The function resize resizes the image src down to or up to the specified size. Note that the . initial dst type or size are not taken into account. Instead, the size and type are derived from . the src,`dsize`,`fx`, and fy. If you want to resize src so that it fits the pre-created dst, . you may call the function as follows: . @code . // explicitly specify dsize=dst.size(); fx and fy will be computed from that. . resize(src, dst, dst.size(), 0, 0, interpolation); . @endcode . If you want to decimate the image by factor of 2 in each direction, you can call the function this . way: . @code . // specify fx and fy and let the function compute the destination image size. . resize(src, dst, Size(), 0.5, 0.5, interpolation); . @endcode . To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to . enlarge an image, it will generally look best with c#INTER_CUBIC (slow) or #INTER_LINEAR . (faster but still looks OK). . . @param src input image. . @param dst output image; it has the size dsize (when it is non-zero) or the size computed from . src.size(), fx, and fy; the type of dst is the same as of src. . @param dsize output image size; if it equals zero, it is computed as: . f[texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}f] . Either dsize or both fx and fy must be non-zero. . @param fx scale factor along the horizontal axis; when it equals 0, it is computed as . f[texttt{(double)dsize.width/src.cols}f] . @param fy scale factor along the vertical axis; when it equals 0, it is computed as . f[texttt{(double)dsize.height/src.rows}f] . @param interpolation interpolation method, see #InterpolationFlags . . @sa warpAffine, warpPerspective, remap
- src.operations.point.img_calculator.subtract(src1, src2[, dst[, mask[, dtype]]]) → dst¶
. @brief Calculates the per-element difference between two arrays or array and a scalar. . . The function subtract calculates: . - Difference between two arrays, when both input arrays have the same size and the same number of . channels: . f[texttt{dst}(I) = texttt{saturate} ( texttt{src1}(I) - texttt{src2}(I)) quad texttt{if mask}(I) ne0f] . - Difference between an array and a scalar, when src2 is constructed from Scalar or has the same . number of elements as src1.channels(): . f[texttt{dst}(I) = texttt{saturate} ( texttt{src1}(I) - texttt{src2} ) quad texttt{if mask}(I) ne0f] . - Difference between a scalar and an array, when src1 is constructed from Scalar or has the same . number of elements as src2.channels(): . f[texttt{dst}(I) = texttt{saturate} ( texttt{src1} - texttt{src2}(I) ) quad texttt{if mask}(I) ne0f] . - The reverse difference between a scalar and an array in the case of SubRS: . f[texttt{dst}(I) = texttt{saturate} ( texttt{src2} - texttt{src1}(I) ) quad texttt{if mask}(I) ne0f] . where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each . channel is processed independently. . . The first function in the list above can be replaced with matrix expressions: . @code{.cpp} . dst = src1 - src2; . dst -= src1; // equivalent to subtract(dst, src1, dst); . @endcode . The input arrays and the output array can all have the same or different depths. For example, you . can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of . the output array is determined by dtype parameter. In the second and third cases above, as well as . in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this . case the output array will have the same depth as the input array, be it src1, src2 or both. . @note Saturation is not applied when the output array has the depth CV_32S. You may even get . result of an incorrect sign in the case of overflow. . @param src1 first input array or a scalar. . @param src2 second input array or a scalar. . @param dst output array of the same size and the same number of channels as the input array. . @param mask optional operation mask; this is an 8-bit single channel array that specifies elements . of the output array to be changed. . @param dtype optional depth of the output array . @sa add, addWeighted, scaleAdd, Mat::convertTo
src.operations.point.img_calculator_ui module¶
- class src.operations.point.img_calculator_ui.ImageCalculatorUI¶
Bases:
src.operations.operation_ui.OperationUIBuild UI for
img_calculator.ImageCalculator.- init_ui(img_calculator)¶
Create user interface for
img_calculator.ImageCalculator.The method creates the widget objects in the proper containers and assigns the object names to them.
- Parameters
img_calculator (
img_calculator.ImageCalculator) – The image calculator dialog
src.operations.point.normalize module¶
- class src.operations.point.normalize.Normalize(parent)¶
Bases:
PyQt5.QtWidgets.QDialog,src.operations.operation.Operation,src.operations.point.normalize_ui.NormalizeUIThe Normalize class impelements a histogram normalization.
- calc_histogram(img_data)¶
Calculate image histogram data.
- Parameters
img_data (
numpy.ndarray) – The image data to calculate histogram- Returns
The histogram data
- Return type
list
- normalize_histogram(min_val, max_val)¶
Calculate histogram normalization:
Define min/max pixel values in the image.
Calculate contrast stretching for range: [
min_val;max_val]
- Parameters
min_val (int) – The lower stretching bound
max_val (int) – The upper stretching bound
- Returns
The new updated image data
- Return type
class:numpy.ndarray
- update_left_value()¶
Update
label_left_valuewhenever is changed.
- update_plot_preview()¶
Update histogram preview window.
Calculate image normalization based on slider range. Draw original and normalized histogram.
- update_right_value()¶
Update
label_right_valuewhenever is changed.
src.operations.point.normalize_ui module¶
- class src.operations.point.normalize_ui.NormalizeUI¶
Bases:
src.operations.operation_ui.OperationUIBuild UI for
normalize.Normalize.- init_ui(normalize, limits)¶
Create user interface for
normalize.Normalize.The method creates the widget objects in the proper containers and assigns the object names to them.
- Parameters
normalize (
normalize.Normalize) – The dialog normalize windowlimits (list[int, int]) – The limits for range slider
src.operations.point.posterize module¶
- class src.operations.point.posterize.Posterize(parent)¶
Bases:
PyQt5.QtWidgets.QDialog,src.operations.operation.Operation,src.operations.point.posterize_ui.PosterizeUIThe Posterize class implements a posterizing point operation.
- calc_posterize_lut(bins_num)¶
Calculate LUT for posterizing point operation.
Based on given
bins_num:Calculate length for a single bin.
Calculate ranges for bins.
Create LUT for ranges.
- Parameters
bins_num (int) – The number of bins to posterize
- Returns
The Lookup Table
- Return type
list[int]
- update_bins_value()¶
Update
label_bins_numwhenever is changed.
- update_img_preview()¶
Update image preview window.
Calculate image posterization based on slider value.
Reload image preview using the base
operation.Operationmethod.
src.operations.point.posterize_ui module¶
- class src.operations.point.posterize_ui.PosterizeUI¶
Bases:
src.operations.operation_ui.OperationUIBuild UI for
posterize.Posterize.- init_ui(posterize)¶
Create user interface for
posterize.Posterize.The method creates the widget objects in the proper containers and assigns the object names to them.
- Parameters
posterize (
posterize.Posterize) – The dialog posterize window