def set_img(self, img): """ read an rgb image, set the gpu copy to be the lab image """ if img.shape[0] != self.dimy or img.shape[1] != self.dimx: raise ValueError(img.shape, self.dimy, self.dimx) if img.ndim == 1: nChannels = 1 isNaN = np.isnan(img) elif img.ndim == 3: nChannels = 3 img_isNaN_r = np.isnan(img[:, :, 0]) img_isNaN_g = np.isnan(img[:, :, 1]) img_isNaN_b = np.isnan(img[:, :, 2]) isNaN = np.logical_or(img_isNaN_r, np.logical_or(img_isNaN_g, img_isNaN_b)) else: raise NotImplementedError() self.img = CpuGpuArray(arr=img) self.img_isNaN = CpuGpuArray(arr=isNaN) print('self.img', self.img) print('self.img_isNaN', self.img_isNaN) if nChannels == 3: rgb_to_lab(img_gpu=self.img.gpu)
def set_img(self,img): """ read an rgb image, set the gpu copy to be the lab image """ if img.shape[0] != self.dimy or img.shape[1] != self.dimx: raise ValueError(img.shape,self.dimy,self.dimx) if img.ndim == 1: nChannels = 1 isNaN = np.isnan( img) elif img.ndim == 3: nChannels = 3 img_isNaN_r = np.isnan( img[:,:,0] ) img_isNaN_g = np.isnan( img[:,:,1] ) img_isNaN_b = np.isnan( img[:,:,2] ) isNaN = np.logical_or(img_isNaN_r, np.logical_or(img_isNaN_g,img_isNaN_b)) else: raise NotImplementedError(nChannels) self.img = CpuGpuArray(arr=img) self.img_isNaN = CpuGpuArray(arr=isNaN) print 'self.img',self.img print 'self.img_isNaN',self.img_isNaN if nChannels==3: rgb_to_lab(img_gpu=self.img.gpu)
def set_img(self, img): """ read an rgb image, set the gpu copy to be the lab image """ if img.shape[0] != self.dimy or img.shape[1] != self.dimx: raise ValueError(img.shape, self.dimy, self.dimx) if img.ndim == 2: nChannels = 1 elif img.ndim == 3: nChannels = 3 else: raise NotImplementedError(nChannels) self.img = CpuGpuArray(arr=img.astype(np.float)) if nChannels == 3: rgb_to_lab(img_gpu=self.img.gpu)
def set_img(self,img): """ read an rgb image, set the gpu copy to be the lab image """ if img.shape[0] != self.dimy or img.shape[1] != self.dimx: raise ValueError(img.shape,self.dimy,self.dimx) if img.ndim == 2: nChannels = 1 elif img.ndim == 3: nChannels = 3 else: raise NotImplementedError(nChannels) self.img = CpuGpuArray(arr=img.astype(np.float)) if nChannels==3: rgb_to_lab(img_gpu=self.img.gpu)