简体   繁体   中英

depth' is 6 (cv_64f) cvtcolor does not work

from skimage import data
from skimage import exposure
from skimage.exposure import adjust_log, equalize_adapthist

#foto di referenza
image_ref = cv2.imread("../Reference images/IMG_1807.jpg")
image_ref = cv2.resize(image_ref,(1080, 1080))
image_ref = cv2.cvtColor(image_ref, cv2.COLOR_BGR2RGB)

matched = equalize_adapthist(image_1)
matched = adjust_log(matched)

cv2.imwrite("prova_clahe_1.jpeg", cv2.cvtColor(matched_1, cv2.COLOR_BGR2RGB))

I tried to convert into float32, but it does not work

#This does not work

#cv2.imwrite("prova_clahe_5.jpeg", cv2.cvtColor(np.float32(matched_1), cv2.COLOR_BGR2RGB))

The matched_1 image variable is of float data type. You cannot convert it to RGB color arrangement unless you first convert the image to an integer data type.

OpenCV allows you to do this using cv2.normalize() function. Just mention the lowest and highest pixel intensities; also mention the data type:

dst = cv2.normalize(matched, dst=None, alpha=0, beta=255, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_8U)`

Now you can convert the variable dst to any color space and also save it using cv2.imwrite()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM