RGB and (Conversion from RGB to YCbCr to RGB) images

Source: Internet
Author: User

RGB and (converted from RGB to YCbCr to RGB) are irreversible, which can be seen from the inverse operation of the matrix. Attached Matlab code:

Clc,clear1_source1_imread('1.jpg '); % read original RGB image figure (1); subplot (1, 2, 1); imshow (source): Title ('original '); % Show image [r c d] = size (source); % calculate image size % ------ calculate the red component and display the decomposition diagram ------ % R (:,:, 1) = source (:,:, 1); R (:,:, 2) = zeros (R, c); R (:,:, 3) = zeros (r, c); r = uint8 (r); whos; figure (2); subplot (1, 1); imshow (r) Title ('red component '); % ------- calculate the green component and display the decomposition graph ------- % G (:,:, 2) = source (:,:, 2); G (:,:, 1) = zeros (R, c); G (:,:, 3) = zeros (R, c); G = uint8 (g); figure (2); subplot (1, 3, 2); imshow (g) Title ('green component'); % -------- calculate the blue component and display the decomposition graph ------- % B (:,:, 3) = source (:, :, 3); B (:,:, 1) = zeros (R, c); B (:,:, 2) = zeros (R, C ); B = uint8 (B); figure (2); subplot (, 3) imshow (B) Title ('Blue component'); % ------------ synthesize ------------- % comp (:, :, 1) = R (:,:, 1); comp (:,:, 2) = g (:,:, 2); comp (:,:, 3) = B (:,:, 3); figure (5); subplot (1, 2); imshow (COMP): Title ('composition image '); y = 0.213 * r + 0.715 * g + 0.072 * B; Cb = 0.511 * B-0.117 * R-0.394 * g + 128; CR = 0.511 * R-0.464 * G-0.047 * B + 128; % red = Y + 1.402 * (Cr-128); % Green = Y-0.34414 * (CB-128)-0.71414*(Cr-128 ); % Blue = Y + 1.772 * (CB-128); Red = 1.164 * (Y-16) + 1.793 * (Cr-128); Green = 1.164*(Y-16)-0.534 * (Cr-128) -0.213 * (CB-128); Blue = 1.164 * (Y-16) + 2.115 * (CB-128); comp2 (:,:, 1) = red (:,:, 1); comp2 (:,:, 2) = green (:,:, 2); comp2 (:,:, 3) = blue (:,:, 3 ); comp5 (:,:, 1) = y (:,:, 1); comp5 (:,:, 2) = CB (:,:, 2); comp5 (:, :, 3) = CR (:,:, 3); figure (5); imshow (comp5); Title ('show 11ycbcr '); figure (1 ); subplot (, 2); imshow (comp2); Title ('rgb converted to ycrcb and then converted to RGB image'); RD = R (:,:, 1) -Red (:,:, 1); GD = g (:,:, 2)-green (:,:, 2); BD = B (:,:, 3) -Blue (:,:, 3); figure (4); subplot (, 1); imshow (RD); Title ('red component exception'); subplot, 2); imshow (GD); Title ('difference of green weight'); subplot (, 3); imshow (BD); Title ('difference of blue weight ');

RGB and (Conversion from RGB to YCbCr to RGB) images

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.