Callback function to receive and save Rgbd Scans. 

        @param rgb: ROS color Image to translate

        @param d: ROS depth image to translate

        @type rgb: ImageROS

        @type d: ImageROS
519356
def __callback (self, rgb, d):
        '''
        

        '''
        data = Images2Rgbd(rgb, d)

        self.lock.acquire()
        self.data = data
        self.lock.release()
619126
def from_color_and_depth(color_im, depth_im):
        
        # check shape
        if color_im.height != depth_im.height or color_im.width != depth_im.width:
            raise ValueError('Color and depth images must have the same shape')

        # check frame
        if color_im.frame != depth_im.frame:
            raise ValueError('Color and depth images must have the same frame')

        # form composite data
        rgbd_data = np.zeros([color_im.height, color_im.width, 4])
        rgbd_data[:, :, :3] = color_im.data.astype(np.float64)
        rgbd_data[:, :, 3] = depth_im.data
        return RgbdImage(rgbd_data, frame=color_im.frame)
599435
private void initializeDrawableForDisplay(Drawable d) {
        if (mBlockInvalidateCallback == null) {
            mBlockInvalidateCallback = new BlockInvalidateCallback();
        }
        // Temporary fix for suspending callbacks during initialization. We
        // don't want any of these setters causing an invalidate() since that
        // may call back into DrawableContainer.
        d.setCallback(mBlockInvalidateCallback.wrap(d.getCallback()));
        try {
            if (mDrawableContainerState.mEnterFadeDuration <= 0 && mHasAlpha) {
                d.setAlpha(mAlpha);
            }
            if (mDrawableContainerState.mHasColorFilter) {
                // Color filter always overrides tint.
                d.setColorFilter(mDrawableContainerState.mColorFilter);
            } else {
                if (mDrawableContainerState.mHasTintList) {
                    DrawableCompat.setTintList(d, mDrawableContainerState.mTintList);
                }
                if (mDrawableContainerState.mHasTintMode) {
                    DrawableCompat.setTintMode(d, mDrawableContainerState.mTintMode);
                }
            }
            d.setVisible(isVisible(), true);
            d.setDither(mDrawableContainerState.mDither);
            d.setState(getState());
            d.setLevel(getLevel());
            d.setBounds(getBounds());
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                d.setLayoutDirection(getLayoutDirection());
            }
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                d.setAutoMirrored(mDrawableContainerState.mAutoMirrored);
            }
            final Rect hotspotBounds = mHotspotBounds;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && hotspotBounds != null) {
                d.setHotspotBounds(hotspotBounds.left, hotspotBounds.top,
                        hotspotBounds.right, hotspotBounds.bottom);
            }
        } finally {
            d.setCallback(mBlockInvalidateCallback.unwrap());
        }
    }
667336
def _rgbtomask(self, obj):
        """"""
        dat = obj.get_image().get_data()  # RGB arrays
        return dat.sum(axis=2).astype(np.bool)
1114654
def render_image(self, rgbobj, dst_x, dst_y):
        
        if self.surface is None:
            return
        self.logger.debug("redraw surface")

        # get window contents as a buffer and paste it into the PIL surface
        # TODO: allow greater bit depths when support is better in PIL
        rgb_arr = self.viewer.getwin_array(order=self.rgb_order, dtype=np.uint8)
        p_image = Image.fromarray(rgb_arr)

        if self.surface is None or p_image.size != self.surface.size:
            # window size must have changed out from underneath us!
            width, height = self.viewer.get_window_size()
            self.resize((width, height))
            if p_image.size != self.surface.size:
                raise render.RenderError("Rendered image does not match window size")

        self.surface.paste(p_image)
849193
public static void srgbToLab( double r , double g , double b , double lab[] ) {
		ColorXyz.srgbToXyz(r,g,b,lab);

		double X = lab[0];
		double Y = lab[1];
		double Z = lab[2];


		double xr = X/Xr;
		double yr = Y/Yr;
		double zr = Z/Zr;

		double fx, fy, fz;
		if(xr > epsilon)	fx = Math.pow(xr, 1.0 / 3.0);
		else				fx = (kappa*xr + 16.0)/116.0;
		if(yr > epsilon)	fy = Math.pow(yr, 1.0 / 3.0);
		else				fy = (kappa*yr + 16.0)/116.0;
		if(zr > epsilon)	fz = Math.pow(zr, 1.0 / 3.0);
		else				fz = (kappa*zr + 16.0)/116.0;

		lab[0] = 116.0*fy-16.0;
		lab[1] = 500.0*(fx-fy);
		lab[2] = 200.0*(fy-fz);
	}
703429
def render_image(self, rgbobj, dst_x, dst_y):
        
        self.logger.debug("redraw pixmap=%s" % (self.pixmap))
        if self.pixmap is None:
            return
        self.logger.debug("drawing to pixmap")

        # Prepare array for rendering
        arr = rgbobj.get_array(self.rgb_order, dtype=np.uint8)
        (height, width) = arr.shape[:2]

        return self._render_offscreen(self.pixmap, arr, dst_x, dst_y,
                                      width, height)
566880
def render_image(self, rgbobj, dst_x, dst_y):
        
        pos = (0, 0)
        arr = self.viewer.getwin_array(order=self.rgb_order, alpha=1.0,
                                       dtype=np.uint8)
        #pos = (dst_x, dst_y)
        #print('dst', pos)
        #pos = self.tform['window_to_native'].to_(pos)
        #print('dst(c)', pos)
        self.gl_set_image(arr, pos)
381442
public static void float2rgbe(byte[] rgbe, float red, float green, float blue) {
        float v;
        int e;

        v = red;
        if (green > v) {
            v = green;
        }
        if (blue > v) {
            v = blue;
        }
        if (v < 1e-32f) {
            rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0;
        }
        else {
            FracExp fe = frexp(v);
            v = (float) (fe.getFraction() * 256.0 / v);
            rgbe[0] = (byte) (red * v);
            rgbe[1] = (byte) (green * v);
            rgbe[2] = (byte) (blue * v);
            rgbe[3] = (byte) (fe.getExponent() + 128);
        }
    }
1290427
def _read_color_and_depth_image(self):
        
        frames = self._pipe.wait_for_frames()
        if self._depth_align:
            frames = self._align.process(frames)

        depth_frame = frames.get_depth_frame()
        color_frame = frames.get_color_frame()

        if not depth_frame or not color_frame:
            logging.warning('Could not retrieve frames.')
            return None, None

        if self._filter_depth:
            depth_frame = self._filter_depth_frame(depth_frame)

        # convert to numpy arrays
        depth_image = self._to_numpy(depth_frame, np.float32)
        color_image = self._to_numpy(color_frame, np.uint8)

        # convert depth to meters
        depth_image *= self._depth_scale

        # bgr to rgb
        color_image = color_image[..., ::-1]

        depth = DepthImage(depth_image, frame=self._frame)
        color = ColorImage(color_image, frame=self._frame)
        return color, depth
63292
def unpack_rgb_image(plane):
    """"""
    assert plane.bits_per_pixel == 24, "{} != 24".format(plane.bits_per_pixel)
    size = point.Point.build(plane.size)
    data = np.frombuffer(plane.data, dtype=np.uint8)
    return data.reshape(size.y, size.x, 3)
869549
def _get_color(self, r, g, b):
        
        clr = (r, g, b)
        return clr
554458
public static void srgbToXyz( double r , double g , double b , double xyz[] ) {
		xyz[0] = 0.412453*r + 0.35758*g + 0.180423*b;
		xyz[1] = 0.212671*r + 0.71516*g + 0.072169*b;
		xyz[2] = 0.019334*r + 0.119193*g + 0.950227*b;
	}
1296526
private void renderDot( int cx , int cy , float Z , int rgb ) {
		for (int i = -dotRadius; i <= dotRadius; i++) {
			int y = cy+i;
			if( y < 0 || y >= imageRgb.height )
				continue;
			for (int j = -dotRadius; j <= dotRadius; j++) {
				int x = cx+j;
				if( x < 0 || x >= imageRgb.width )
					continue;

				int pixelIndex = imageDepth.getIndex(x,y);
				float depth = imageDepth.data[pixelIndex];
				if( depth > Z ) {
					imageDepth.data[pixelIndex] = Z;
					imageRgb.data[pixelIndex] = rgb;
				}
			}
		}
	}
1033731
def set_rgb(self, red, green, blue):
        
        x, y = rgb_to_xy(red, green, blue)
        self.xy = [x, y]
667610
def rgb2short(r, g, b):
    
    # Using list of snap points, convert RGB value to cube indexes
    r, g, b = [len(tuple(s for s in snaps if s < x)) for x in (r, g, b)]

    # Simple colorcube transform
    return (r * 36) + (g * 6) + b + 16
994112
def colorRGB(r, g, b):
        
        return (float(r / 255), float(g / 255), float(b / 255))