plantcv
plantcv copied to clipboard
The bug from import hyperspectral image file using function readimage()
Describe the bug
When using function readimage()
function to read the raw and hdr images captured from the unispectral camera. Some bugs happen because of the size of the parameter default_bands
in your source code hyperspectral/read_data.py
, function _maek_pseudo_rgb
, the default_bands
is ['713'] got from the raw file. However, this function needs three data from the default_bands list, which is incompatible. Btw, if is reasonable to choose the default_band in axis 2 of the array_data
def _make_pseudo_rgb(spectral_array):
"""Create the best pseudo-rgb image possible from a hyperspectral datacube
Inputs:
spectral_array = Hyperspectral data instance
Returns:
pseudo_rgb = Pseudo-rgb image
:param spectral_array: __main__.Spectral_data
:return pseudo_rgb: numpy.ndarray
"""
# Make shorter variable names for data from the spectral class instance object
array_data = spectral_array.array_data
default_bands = spectral_array.default_bands #['713']
wl_keys = spectral_array.wavelength_dict.keys()
if default_bands is not None:
pseudo_rgb = cv2.merge((array_data[:, :, int(default_bands[0])],
array_data[:, :, int(default_bands[1])],
array_data[:, :, int(default_bands[2])]))
To Reproduce Steps to reproduce the behavior (including sample data and code really help):
- Starting with image '...' images1.zip
- Run function(s) 'readimage' with the
envi
mode - See error
Expected behavior please fix it ,thanks Or need a PR?
Local environment (please complete the following information):
- OS: ubuntu 18.04
- Environment virtualenv,
- PlantCV Version latest
Additional context Add any other context about the problem here.
Hi @ZainZh,
The function uses the bands specified in the header file and three bands are necessary to create a pseudo-rgb image.
We could potentially modify the code to return a grayscale image when only one band is provided. In the meantime, you could try commenting out the default bands
line in your header file.