| 68 | return torch.Tensor(np_obj[:, :, :, np.newaxis].transpose((3, 2, 0, 1))) |
| 69 | |
| 70 | def tensor2tensorlab(image_tensor,to_norm=True,mc_only=False): |
| 71 | # image tensor to lab tensor |
| 72 | from skimage import color |
| 73 | |
| 74 | img = tensor2im(image_tensor) |
| 75 | img_lab = color.rgb2lab(img) |
| 76 | if(mc_only): |
| 77 | img_lab[:,:,0] = img_lab[:,:,0]-50 |
| 78 | if(to_norm and not mc_only): |
| 79 | img_lab[:,:,0] = img_lab[:,:,0]-50 |
| 80 | img_lab = img_lab/100. |
| 81 | |
| 82 | return np2tensor(img_lab) |
| 83 | |
| 84 | def tensorlab2tensor(lab_tensor,return_inbnd=False): |
| 85 | from skimage import color |