Code Monkey home page Code Monkey logo

Comments (11)

letmaik avatar letmaik commented on September 3, 2024 5

If you want to save it back as a raw file, then no. If you just want to change the raw pixels for the postprocessing, then yes, just change pixels in the arrays, e.g. raw.raw_image_visible[:] = new_data

from rawpy.

letmaik avatar letmaik commented on September 3, 2024 1

@Ir1d If you downsample then you destroy the Bayer matrix, which means you can't postprocess anymore. Please ask such questions on stackoverflow.

from rawpy.

Melody-doudou avatar Melody-doudou commented on September 3, 2024

Thanks Maik! I am not saving the raw file; the only process that I need is the postprocessing. I am trying to modify the raw.raw_image_visible to see what corresponding postprocessing results it would lead to.

I have a couple of more questions here. Does the postprocessing process only depend on the raw_image_visible matrix, or is it that it depends on other options in the raw file as well? I tried to fill a new_data (which is 100x100) into raw.raw_image_visible (which is 200x200). It led to a ValueError though: could not broadcast input array from shape (100,100) into shape (200,200). I modified the new_data as the upper left block contains the actual matrix values, while other parts are all set to zeros; then fed it into raw.raw_image_visible and it worked.

However, the results aren't what I was originally expecting for. My goal is trying to figure out what operations I could do on the raw data so that it leads to a simulated corresponding low-resolution counterpart of the original image. What I did earlier - by selecting a subset of the raw data doesn't lead to an image that is slightly blurry, but some points that have a color difference (I also tried bicubic interpolation of the raw data, seems it doesn't work either). Do you have any clue about it, if the above-mentioned makes sense to you. Thank you so much. :)

from rawpy.

letmaik avatar letmaik commented on September 3, 2024

I you just want to reduce the output resolution, maybe the half_size=True option is a solution. But this is probably not what you have in mind when talking about "simulating".

Before I continue, do you understand the concept of Bayer matrices?

from rawpy.

Melody-doudou avatar Melody-doudou commented on September 3, 2024

Thanks for your reply. Yeah that is not what I had in mind by setting "half_size=True".

I am actually trying to investigate the SR(super-resolution) problem by using raw data. As the raw data technically contains more information (hasn't been through all the processings) and offers higher controllability, my thought is that maybe it is more suitable for the SR problem of being able to restore more details. The traditional SR problem achieves the low-resolution images using bicubic interpolation.

img_2 = imresize(imresize(img, 1/2, 'bicubic'), [size(img, 1), size(img, 2)], 'bicubic');

For raw data though, I don't really have a clue of how to achieve similar "simulated" low-resolution images.

My basic understanding of Bayer matrices is that in raw data, each pixel value retains the intensity pixel value of only one color channel of the three RGB channels. The whole raw data is organized in Bayer pattern (RGBG) as blocks. I am all new into this so the understanding can be not very accurate.

from rawpy.

Melody-doudou avatar Melody-doudou commented on September 3, 2024

I actually want to enable the "half_size=True" option, but in the opposite direction. I am not sure this option is achieved from a down-sampling the RGB image of original image size, or from the raw data.

Given both raw data and RGB data of the original image size, instead of achieving a half-sized RGB image, I am wondering what the corresponding raw data would be like that could generate the half-sized RGB image.

from rawpy.

letmaik avatar letmaik commented on September 3, 2024

Given that rawpy is just a simple wrapper around libraw, I have the feeling that your question should better be asked in a general raw photography discussion forum than here. You will get more helpful answers.

from rawpy.

Melody-doudou avatar Melody-doudou commented on September 3, 2024

Okay, I see. Thanks a lot for your help! :)

from rawpy.

Melody-doudou avatar Melody-doudou commented on September 3, 2024

Could you still tell me your answer to this question, does the postprocessing process only depend on the raw_image_visible matrix, or is it that it depends on other options in the raw file as well?

from rawpy.

letmaik avatar letmaik commented on September 3, 2024

Postprocessing mostly depends on the image matrix, the chosen postprocessing parameters, and, if the parameters don't override it, then things like camera whitebalance can be used directly from the file metadata.

from rawpy.

Ir1d avatar Ir1d commented on September 3, 2024

@Melody-doudou Hi, have you solved this? Can you share your solution on how to perform postprocessing on downsampled images?
Since the numpy array is downsampled, it cant overwrite the original array

from rawpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.