Matlab默认颜色空间&与YUV合作

时间:2016-03-18 20:20:29

标签: matlab rgb yuv

我有兴趣在Matlab中使用YUV色彩空间图像,但是(如果我错了,请纠正我)我相信Matlab使用的默认色彩空间是RGB吗?

因此,我可能误导自己认为我在亮度(Y)通道上操作,例如当我真正在红色(R)通道上工作时。我对么?是否可以更改正在使用的色彩空间?

我知道转换,但目前我很好奇是否有可能告诉Matlab使用YUV色彩空间,例如,只需改变一行中的亮度通道(而不是改变)红色强度,如果RGB)。

我遇到过:http://www.mathworks.com/help/imaq/returnedcolorspace.html(ReturnedColorSpace),但我不明白如何实现它。

编辑:

t = Tiff('e82.tiff','r');
[Y,Cb,Cr] = read(t);
close(t)

figure; imshow(Cr);

我也在Matlab中尝试过这段代码,但是我不确定我是否认为它正在将Cr通道读取为灰度,因为它假设涉及RGB色彩空间? (该图显示图像的灰度版本)

EDIT(28/3/16) - 我的YUV文件的imfinfo输出。

                 FileSize: 353500
                   Format: 'tif'
            FormatVersion: []
                    Width: 720
                   Height: 243
                 BitDepth: 24
                ColorType: 'YCbCr'
          FormatSignature: [73 73 42 0]
                ByteOrder: 'little-endian'
           NewSubFileType: 0
            BitsPerSample: [8 8 8]
              Compression: 'PackBits'
PhotometricInterpretation: 'YCbCr'
             StripOffsets: [1x49 double]
          SamplesPerPixel: 3
             RowsPerStrip: 5
          StripByteCounts: [1x49 double]
              XResolution: 72
              YResolution: 72
           ResolutionUnit: 'Inch'
                 Colormap: []
      PlanarConfiguration: 'Chunky'
                TileWidth: []
               TileLength: []
              TileOffsets: []
           TileByteCounts: []
              Orientation: 1
                FillOrder: 1
         GrayResponseUnit: 0.0100
           MaxSampleValue: [255 255 255]
           MinSampleValue: [0 0 0]
             Thresholding: 1
                   Offset: 353302
                 Software: 'Lavc56.60.100'
         YCbCrSubsampling: [2 1]
      ReferenceBlackWhite: [15 235 128 240 128 240]

然而,下面的代码片段写了" Y" " U" " V"图像就好像它们是RGB(每个输出是每个RGB颜色通道的灰度版本)

a = imread('3d008.tiff');
a1 = a(:,:,1); imwrite(a1,'xdel1.tiff');
a2 = a(:,:,2); imwrite(a2,'xdel2.tiff');
a3 = a(:,:,3); imwrite(a3,'xdel3.tiff');

转换此" YUV"图像到YUV(通过rgb2yuv代码)并重复上面4行代码输出我的视觉期望。 a1是亮度通道,其他是色度。

1 个答案:

答案 0 :(得分:-3)

通过这个页面阅读我会建议

http://www.mathworks.com/help/imaq/specifying-the-color-space.html

{{1}}