How to convert jpeg file to RAW10 data format?

조회 수: 8 (최근 30일)
Mark Allen Lagaya
Mark Allen Lagaya 2018년 4월 3일
댓글: Walter Roberson 2018년 4월 4일
Hello,
Is there a way to convert an image file (e.g. jpeg format) to RAW10 data format using MatLab?
Thank you.

채택된 답변

Guillaume
Guillaume 2018년 4월 3일
While yes, as Walter says, you potentially could write a converter, it seems to be the opposite workflow to what people normally do. So, what would be the reason to want to do this?
There are a few technical considerations to bear in mind as well:
  • your image is probably 8-bit per pixel. The RAW10 is 10-bit per pixel. So you'll always have the two highest bits wasted. If the image was initially RAW10, you're never going to recreate the additional 2 bits of information that were lost.
  • RAW10, like all raw formats assumes the decoder knows what sensor the image corresponds to. Therefore, the RAW10 format does not include any information about the image such as width and height and bayer pattern. The image is just one long line of pixels. It's up to the decoder reshape that into a rectangle of the right size and to remove potential padding pixels (if the number of columns is not a multiple of 4).
  • If the image is colour, then the pixels in RAW10 needs to be encoded using a bayer pattern. There are several possible bayer patterns (GBRG, GRBG, BGGR, RGGB) so you'd have to chose the one that matches your sensor/decoding software. An additional problem is that while matlab has a function to decode bayer patterns it does not have one for encoding into them, so you'd have to write your own.
Once the image has been bayer encoded it's easy to convert it to RAW10. I can write the code for that if really needed (but not the bayer encoding).
  댓글 수: 5
Guillaume
Guillaume 2018년 4월 4일
편집: Guillaume 2018년 4월 4일
The person doing the work figures the bayer pattern might be CYYM
Actually, you can see later on that they figure out it's BGGR. That makes more sense, I've never heard of a sensor with CMY filters.
Each sensor will have its own pattern and again, it's not something encoded in the raw10 format. It's up to the reader to know what it is and decode the image accordingly.
Walter Roberson
Walter Roberson 2018년 4월 4일
Ah, I did not look on the right part of the page for the continuation indicators. There is too much information in the discussion for me to process well at the moment, as I am not familiar with a number of parts of what is being discussed -- but it is clear that at least for that device that reversing a RAW10 would not be easy.
I think we would need more information about the device being used on the test bench.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2018년 4월 3일
Yes, it should not be bad if you follow the file format description of https://developer.android.com/reference/android/graphics/ImageFormat.html#RAW10
There is no obvious file header for RAW10, just data. I am not sure how the size information is stored.
  댓글 수: 3
Guillaume
Guillaume 2018년 4월 3일
a bitstream in a text file
The two things are contradictory. What do you mean exactly?
Mark Allen Lagaya
Mark Allen Lagaya 2018년 4월 4일
Sorry for the confusing statement. What I have is a jpeg format and I'm looking for means to convert that to RAW10. The RAW10 format file will be used as an input to a testbench.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by