How to convert jpeg file to RAW10 data format?

8 visualizzazioni (ultimi 30 giorni)
Hello,
Is there a way to convert an image file (e.g. jpeg format) to RAW10 data format using MatLab?
Thank you.

Risposta accettata

Guillaume
Guillaume il 3 Apr 2018
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 Commenti
Guillaume
Guillaume il 4 Apr 2018
Modificato: Guillaume il 4 Apr 2018
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 il 4 Apr 2018
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.

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 3 Apr 2018
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 Commenti
Guillaume
Guillaume il 3 Apr 2018
a bitstream in a text file
The two things are contradictory. What do you mean exactly?
Mark Allen Lagaya
Mark Allen Lagaya il 4 Apr 2018
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.

Accedi per commentare.

Categorie

Scopri di più su Images in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by