opencsp.app.target.target_color.lib.ImageColor
Tool for matching pixels between two images and viewing results.
- class opencsp.app.target.target_color.lib.ImageColor.ImageColor(image: ndarray)
Bases:
objectClass containing image processing and color matching methods on RGB images.
- crop_image(region: LoopXY) None
Masks image according to given region.
- Parameters:
region (LoopXY) – Active pixel region
- classmethod from_file(file: str) ImageColor
Creates instance by directly loading image file.
- Parameters:
file (str) – File name
- match_indices(rgb: ndarray, thresh: float) tuple[ndarray, ndarray]
Calls returns the indices of pixels matching given color in form (ys, xs).
- Parameters:
rgb (ndarray) – Length 3 vector to match in current image
thresh (float) – Threshold, in radians, to consider a match
- Returns:
ys/xs – Y and X pixel indices that match input RGB vector within given threshold
- Return type:
ndarray
- match_mask(rgb: ndarray, thresh: float) ndarray
Returns a mask of all pixels whos RGB vectors are within given threshold (in radians) to the given RGB value.
- Parameters:
rgb (ndarray) – Length 3 color vector to match in current image
thresh (float) – Threshold, in radians, to consider a match
- Returns:
Mask of matching pixels.
- Return type:
np.ndarray
- Raises:
ValueError – If input vector is not size 3
- plot_normalized(ax: Axes | None = None, **kwargs) Axes
Plots normalized RGB image
- Parameters:
ax (plt.Axes, optional) – Axes to plot on, by default None. If None, plt.gca() is used.
- Returns:
Matplotlib axes
- Return type:
plt.Axes
- plot_unprocessed(ax: Axes | None = None, **kwargs) Axes
Plots unprocessed RGB image
- Parameters:
ax (plt.Axes, optional) – Axes to plot on, by default None. If None, plt.gca() is used.
- Returns:
Matplotlib axes
- Return type:
plt.Axes
- smooth_image(ker: ndarray) ndarray
Smoothes image using OpenCV’s filter2D.
- Parameters:
image (ndarray) – NxMx3 image to smooth
ker (ndarray) – 2d smoothing kernel
- Returns:
NxMx3 smoothed image
- Return type:
ndarray