Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more examples #31

Open
ovisan opened this issue May 24, 2020 · 9 comments
Open

more examples #31

ovisan opened this issue May 24, 2020 · 9 comments

Comments

@ovisan
Copy link

ovisan commented May 24, 2020

Hi,

So glad you made this library, thank you!
Can you please add more examples, besides ppm? Maybe also a link to a good learning resource.

@pedrocr
Copy link
Owner

pedrocr commented May 24, 2020

See imagepipe and chimper for practical uses of the library:

https://github.com/pedrocr/imagepipe/
https://github.com/pedrocr/chimper

@aaronleopold
Copy link

Does this library have any support for conversion operations? Such as CR2 -> JPG?

@pedrocr
Copy link
Owner

pedrocr commented Feb 23, 2021

@aaronleopold rawloader only deals with interpreting and decoding the raw data itself, it doesn't process it in any way. imagepipe is what you want if you want to create an RGB image as that requires a raw processing pipeline to convert the raw data into RGB output with proper demosaic, white balance, levels, etc. You can then write that image out to a jpeg. The converter binary in imagepipe includes a full JPG output from any raw file that you can use as a guide:

https://github.com/pedrocr/imagepipe/blob/d95a17f7a55c7d6fb73d8006791a9436e80de10c/src/bin/converter.rs

This just uses the default values for the operations. imagepipe operations have options that can be set to use different whitebalance, color conversion, crop, rotate, etc.

Documenting imagepipe a bit more would be a good first issue. I'll put that in that project.

@aaronleopold
Copy link

@pedrocr Thank you so much for the detailed reply!! I'll look at the linked file for reference!

@pedrocr
Copy link
Owner

pedrocr commented Feb 23, 2021

More than welcome. If you want to discuss anything live I have IRC always running on #chimper irc.freenode.net. I may not always be available but I'll eventually reply, and check it often.

@qarmin
Copy link

qarmin commented Dec 31, 2021

It is possible to use this library to extend extension number supported byimage-rs?
I can't find anywhere example how to decode image in this library and results pass to image-rs.

@pedrocr
Copy link
Owner

pedrocr commented Dec 31, 2021

@qarmin see my comment above with the link to imagepipe. That converter example uses the image crate and so does chimper.

@qarmin
Copy link

qarmin commented Dec 31, 2021

Well, if I read this correctly, then decoded image from rawloader is not used in any other place, so still I don't know how to use this
https://github.com/pedrocr/imagepipe/blob/d95a17f7a55c7d6fb73d8006791a9436e80de10c/src/bin/converter.rs#L36-L39

                if file_entry.path.to_string_lossy().ends_with(".cr2"){
                    let raw_image = match rawloader::decode_file(&file_entry.path){
                        Ok(t) => t,
                        Err(e) => {
                            println!("Failed to process image {:?}, reason {}", file_entry.path,e);
                            return Some(Some((file_entry,Vec::new())));
                        }
                    };


                    raw_image.
                    match raw_image.data{
                        RawImageData::Integer(vec_16) => {
                            vec_16.u
                        }
                        RawImageData::Float(vec_32) => {

                        }
                    }
                    // image = image::load_from_memory(raw_image.data);
}

For now I wrote this code, but I don't know how to convert vec_16 or vec_32 to &[u8] needed by load_from_memory and I'm not sure if it will work.

@pedrocr
Copy link
Owner

pedrocr commented Dec 31, 2021

That part is only used to print out some metadata. The actual decode and conversion is just this call:

https://github.com/pedrocr/imagepipe/blob/d95a17f7a55c7d6fb73d8006791a9436e80de10c/src/bin/converter.rs#L53-L56

It gives you an 8bit output directly no matter what the internal pipeline needed to do to achieve that.

That can then be used with the image crate:

https://github.com/pedrocr/imagepipe/blob/d95a17f7a55c7d6fb73d8006791a9436e80de10c/src/bin/converter.rs#L67-L71

That's the simplest API. If you want to change settings then you need to actually setup a pipeline:

https://github.com/pedrocr/imagepipe/blob/12269f04ac2fa0d165fc860d853ca828a8b8de3e/src/lib.rs#L22-L25

and then you can alter the conversion settings of the pipeline, by writing to pipeline.ops.*. The pipeline also has a 16bit output option which is useful if you want to use an 16bit format with the image crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants