5

I have some array, let's say a = np.asarray([[10, 50], [30, 60]])
And I know that colors of pixels are colors = np.asarray([['G', 'R'], ['B', 'G']])
I want to save the image in .raw (or .dng) format. How do I do this?

8
  • Could you be a bit clearer about what your numbers in your array are please? Is it supposed to be a 2x2 pixel? What is the 10 please? 10 what? A sample image where the height, width and number of colour channels are all different is much easier to understand than a 2x2 pixel 2-channel image! Commented Mar 26, 2020 at 13:48
  • Why do you want to save this as DNG? DNG is an extremely portable, expressive format for high-resolution and non-standard data that often requires sophisticated deBayering and calibration. Is that your data? Or do you mean you want raw pixels without headers or other extraneous info? What are hou you trying to achieve here please? Commented Mar 26, 2020 at 13:52
  • @mark-setchell I have raw files but they saved for unknown me reason in png files. Basically they are like white-black pictures, but actually they are raw files. And I need to do demosaicing for them, but I can't open them in for example rawpy library. First array in my answer a is 2x2 picture, and each number corresponds to how much color of corresponding colors of colors is presented in the corresponding pixel Commented Mar 26, 2020 at 14:58
  • I'm confused. The title of your question implies you want to write a raw file, but your comment implies you have raw files, which are somehow PNG files, that you cannot read. Your 2-channel 2x2 pixel isn't helping much either. Commented Mar 26, 2020 at 15:12
  • @mark-setchell I read PNG files, I get some let's say 512x512 one channel numpy array. Then, I want to write this array to .raw file. I assume that Bayer filter is [['G', 'R'], ['B', 'G']] Commented Mar 26, 2020 at 16:35

1 Answer 1

0

I think the rawpy library might be your friend here, I believe the raw_image type is just implemented through numpy arrays.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.