plantcv
plantcv copied to clipboard
Add image data structure classes
Describe your changes This PR contains prototype features for the purpose of discussion and development.
Adds Python classes for image data structures, subclassed from NumPy n-dimensional arrays. In the current PR, a generic class Image
is subclassed from the np.ndarray
class and has one additional attribute, filename
. All other classes are subclassed from Image
.
Image
BGR
: OpenCV-type color image - currently behaves exactly like Image
RGB
: scikit-image-type color image - currently behaves exactly like Image
GRAY
: grayscale image - currently behaves exactly like Image
HSI
: hyperspectral image - has additional attributes/methods
HSI
would replace Spectral_data
. It currently contains attributes in addition to Image
: wavelengths
- a list of wavelengths, default_wavelengths
- a list of default wavelengths for visualizing the data cube, and wavelength_units
. When an instance is built it automatically adds attributes for min and max wavelengths, can automatically pick default wavelengths if needed, and automatically creates a "thumbnail" for visualizing the data cube (what we have been calling "pseudo_rgb". The thumb
attribute is itself either a BGR
or GRAY
image.
As these classes are based on np.ndarray
, properties like height, width, etc. can be accessed using .shape
and other standard ndarray
class methods/attributes, or NumPy functions.
Some (but not all) to-do items:
- Other classes, e.g.
THERMAL
,MASK
? - Automatic conversion between classes? - For example, if a
BGR
/RGB
is subsetted to a single channel that new image should beGRAY
- Built-in converters in some cases? - For example, would it be convenient to have
BGR.torgb
andRGB.tobgr
methods?
Type of update Is this a: Work in progress
Associated issues Related: #775 #896
For the reviewer See this page for instructions on how to review the pull request.
- [ ] PR functionality reviewed in a Jupyter Notebook
- [ ] All tests pass
- [ ] Test coverage remains 100%
- [ ] Documentation tested
- [ ] New documentation pages added to
plantcv/mkdocs.yml
- [ ] Changes to function input/output signatures added to
updating.md
- [ ] Code reviewed
- [ ] PR approved
Codecov Report
Merging #909 (9a4aca0) into 4.x (696704c) will not change coverage. The diff coverage is
100.00%
.
@@ Coverage Diff @@
## 4.x #909 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 160 161 +1
Lines 6827 6880 +53
=========================================
+ Hits 6827 6880 +53
Flag | Coverage Δ | |
---|---|---|
unittests | 100.00% <100.00%> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
plantcv/plantcv/__init__.py | 100.00% <ø> (ø) |
|
plantcv/plantcv/classes.py | 100.00% <100.00%> (ø) |
|
plantcv/plantcv/images.py | 100.00% <100.00%> (ø) |
|
plantcv/__init__.py | 100.00% <0.00%> (ø) |
Moved to a separate repository: https://github.com/danforthcenter/eidc