(in_c, tar_type, img_list)
| 595 | |
| 596 | |
| 597 | def 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 | ''' |
nothing calls this directly
no test coverage detected