开发者

Using fwrite, want to skip writing three items in A between each write

So, I'm doing some image processing in MATLAB, and attempting to save a file out to a y4m format with colorspace 4:2:0.

Basically, w开发者_StackOverflow社区hat it comes down to is I want to use fwrite, but I want to be able to skip a certain number of items in the vector that's writing. Is there an easy way I can do this?


There are tools for doing this already.

If you insist on doing things yourself (I do, since I can't be bothered paying for the separate toolboxes), you can always make a new vector containing only the elements you need to write. Assuming that you have YUV 4:4:4 and you want to write it as YUV 4:2:0:

  • Split yuv444 into it's separate Y', Cb, Cr components
  • Write Y' as is, using fwrite
  • Downsample Cb and Cr by a factor of two to get Cb_down and Cr_down
  • Write Cb_down and Cr_down using fwrite to the same open file handle


Logical indexing from 'Steve on Image Processing' might be a good starter for your aim.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜