質問

Please i need help regarding changes of color space

I have calculate Y, Cr , Cb values using conversion

            int Y = (int)(0.299*r+0.587*g+0.114*b);
            int Cb=(int)(128-0.169*r-0.331*g+0.500*b);
            int Cr =(int)(128+0.500*r-0.419*g-0.081*b);

Now i have to save new image with new color space e.g YCrCb not RGB what should i follow.

役に立ちましたか?

解決

You can display the image in YCbCr space using bufferedImage class in java. For this create an empty buffered image of size same as your RGB image and set all the pixel values using setRGB method as shown below.

BufferedImage ycb =  new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);

int val = (y<<16) | (cb<<8) | cr;
    ycb.setRGB(i,j,val);

ImageIO.write(ycb,"png", new File("E:\\Rose\\ycbcr\\ycbcr.png"));
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top