MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / channel_convert

Function channel_convert

ldm/modules/image_degradation/utils_image.py:597–608  ·  view source on GitHub ↗
(in_c, tar_type, img_list)

Source from the content-addressed store, hash-verified

595
596
597def channel_convert(in_c, tar_type, img_list):
598 # conversion among BGR, gray and y
599 if in_c == 3 and tar_type == 'gray': # BGR to gray
600 gray_list = [cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) for img in img_list]
601 return [np.expand_dims(img, axis=2) for img in gray_list]
602 elif in_c == 3 and tar_type == 'y': # BGR to y
603 y_list = [bgr2ycbcr(img, only_y=True) for img in img_list]
604 return [np.expand_dims(img, axis=2) for img in y_list]
605 elif in_c == 1 and tar_type == 'RGB': # gray/y to BGR
606 return [cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) for img in img_list]
607 else:
608 return img_list
609
610
611'''

Callers

nothing calls this directly

Calls 1

bgr2ycbcrFunction · 0.85

Tested by

no test coverage detected