BasicSR icon indicating copy to clipboard operation
BasicSR copied to clipboard

how to read gray image for 1 channel

Open DejaVuyan opened this issue 2 years ago • 3 comments

我的数据集由灰度图像组成,但是我没有找到怎样让图片按照灰度图像读取(读取的图片通道为1),调整config文件中的num_in_ch也只能调整构造的网络输入通道,读取图片的通道仍然为3。

My dataset consists of grayscale images, but I have not found how to make the images read as grayscale images (the image read channel is 1), adjusting num_in_CH in the config file can only adjust the constructed network input channel, the image read channel is still 3.

DejaVuyan avatar May 05 '22 12:05 DejaVuyan

Solved

ElliotQi avatar Oct 25 '22 10:10 ElliotQi

Solved

您好,请问如何解决的。

我是直接读取RGB(复制2个通道)然后获取单个通道,即img[:,:,0] 但是在做扩增时会有问题,不清楚为什么源码里面augment采用了cv2.flip(img, 1, img)多了一个参数导致的,我修改了可以。

    def _augment(img):
        if hflip:  # horizontal
            cv2.flip(img, 1, img)
        if vflip:  # vertical
            cv2.flip(img, 0, img)
        if rot90:
            img = img.transpose(1, 0, 2)
        return img
  • 想探讨在您的解决方案,谢谢

zhgqcn avatar Dec 18 '23 11:12 zhgqcn