TENet icon indicating copy to clipboard operation
TENet copied to clipboard

is the raw data 14 bit ?

Open kia350 opened this issue 3 years ago • 1 comments

in the load_dataset.py : def getitem(self, index): # read images, crop size

    # Note: RGGB is not RAW, it is a Full color sampled image.
    # (compose: Red, Green_red, Green_blue and blue channel);
    if self.phase == 'train':
        # for training dataset, the mat version if 4 (reads with scipy)
        matfile = loadmat(self.data_lists[index])
        rggb = np.asarray(matfile['ps4k']).astype(np.float32) / (2 ** self.bit - 1)
    else:
        # for testing dataset, the mat version if 7.3 (reads with h5py)
        with h5py.File(self.data_lists[index], 'r') as matfile:
            rggb = np.asarray(matfile['raw']).astype(np.float32) / (2 ** self.bit - 1)
            rggb = np.transpose(rggb, (2, 1, 0))
            matainfo = matfile['metadata']
            matainfo = {'colormatrix': np.transpose(matainfo['colormatrix']),
                        'red_gain': matainfo['red_gain'],
                        'blue_gain': matainfo['blue_gain']
                        }
            ccm, red_g, blue_g = process.metadata2tensor(matainfo)
            metadata = {'ccm': ccm, 'red_gain': red_g, 'blue_gain': blue_g}

    rggb = crop_img_np(rggb, self.patch_size, center_crop=self.phase != 'train')  # in PIL
    linrgb = np.stack((rggb[:, :, 0], np.mean(rggb[:, :, 1:3], axis=-1), rggb[:, :, 3]), axis=2)

    if self.phase == 'train':
        linrgb = aug_img_np(linrgb, random.randint(0, 7))
    linrgb = TF.to_tensor(linrgb)
    linrgb = torch.clamp(linrgb, 0., 1.)

请问raw data是14bit吗?当self.bit=14时,为什么读取的原始数据rggb会超过1呢?而self.bit=16时,数据最大是1,您是把数据映射到16bit了吗?

kia350 avatar Aug 08 '22 14:08 kia350

另外 .mat 里的data范围是[black level , white level]?还是[0,14(or 16)bit]?

kia350 avatar Aug 09 '22 09:08 kia350

Same question here. Any updates?

feiran-l avatar Oct 25 '22 04:10 feiran-l

in the load_dataset.py : def getitem(self, index): # read images, crop size

    # Note: RGGB is not RAW, it is a Full color sampled image.
    # (compose: Red, Green_red, Green_blue and blue channel);
    if self.phase == 'train':
        # for training dataset, the mat version if 4 (reads with scipy)
        matfile = loadmat(self.data_lists[index])
        rggb = np.asarray(matfile['ps4k']).astype(np.float32) / (2 ** self.bit - 1)
    else:
        # for testing dataset, the mat version if 7.3 (reads with h5py)
        with h5py.File(self.data_lists[index], 'r') as matfile:
            rggb = np.asarray(matfile['raw']).astype(np.float32) / (2 ** self.bit - 1)
            rggb = np.transpose(rggb, (2, 1, 0))
            matainfo = matfile['metadata']
            matainfo = {'colormatrix': np.transpose(matainfo['colormatrix']),
                        'red_gain': matainfo['red_gain'],
                        'blue_gain': matainfo['blue_gain']
                        }
            ccm, red_g, blue_g = process.metadata2tensor(matainfo)
            metadata = {'ccm': ccm, 'red_gain': red_g, 'blue_gain': blue_g}

    rggb = crop_img_np(rggb, self.patch_size, center_crop=self.phase != 'train')  # in PIL
    linrgb = np.stack((rggb[:, :, 0], np.mean(rggb[:, :, 1:3], axis=-1), rggb[:, :, 3]), axis=2)

    if self.phase == 'train':
        linrgb = aug_img_np(linrgb, random.randint(0, 7))
    linrgb = TF.to_tensor(linrgb)
    linrgb = torch.clamp(linrgb, 0., 1.)

请问raw data是14bit吗?当self.bit=14时,为什么读取的原始数据rggb会超过1呢?而self.bit=16时,数据最大是1,您是把数据映射到16bit了吗?

数据集链接是否已经无法打开了?请问您有备份数据集吗?方便提供一下吗?

Ruimin-S avatar Feb 01 '23 15:02 Ruimin-S

in the updated version, we provided the raw files. the raw is in 14 bit

https://drive.google.com/drive/folders/1Nw5biJT7Ny8r8uUj9Ye42Vx8VMUmv6VW?usp=share_link

guochengqian avatar Mar 23 '23 12:03 guochengqian