Hello, I’ m trying to separate a UAV .tif (containing four channels: green, red, red-edge, NIR) to four different images, one for each channel. The code that I used for normal RGB (3 channel .tif) worked perfectly but I when I try to implement it to the 4-channel UAV .tif image with the related modifications in the code, I get this message…
File "code.py", line 4, in <module>
g,r,re,nir = cv2.split(img)
ValueError: not enough values to unpack (expected 4, got 0)
check img.shape
you probably loaded the image withoutIMREAD_UNCHANGED, which means OpenCV automatically converts it to (some type of) BGR, losing the extra channel
it may still reorder the channels. I don’t know exactly how it’ll behave. check the docs and/or run the function and check the results to be sure.
you’re using python. you can also use numpy means: (ch1, ch2, ch3, ch4) = np.transpose(img, axes=(2,0,1))