I was still intrigued by the problem of using views. I didn't manage managed to do it, but and in this incomplete implementation
the brightest() function accepts images as GenericImage traits – both views and GrayImages should implement that
views are passed into brightest() from the main program
constant value pixels are returned since I couldn't figure out how to turn get_pixel() return values into Lumas
I can't wrap my head around solved this by using GenericImageView instead of GenericImage:
error[E0277]: the trait bound `&image::ImageBuffer<image::Luma<u8>, std::vec::Vec<u8>>: std::ops::DerefMut` is not satisfied
--> src/main.rs:39:26
|
14 | fn brightest<T: GenericImage>(img1: T, img2: T) -> GrayImage {
| ------------ required by this bound in `brightest`
...
39 | let top_pixels = brightest(orig, left);
| ^^^^^^^^^ the trait `std::ops::DerefMut` is not implemented for `&image::ImageBuffer<image::Luma<u8>, std::vec::Vec<u8>>`
|
= help: the following implementations were found:
<image::ImageBuffer<P, Container> as std::ops::DerefMut>
= note: `std::ops::DerefMut` is implemented for `&mut image::ImageBuffer<image::Luma<u8>, std::vec::Vec<u8>>`, but not for `&image::ImageBuffer<image::Luma<u8>, std::vec::Vec<u8>>`
= note: required because of the requirements on the impl of `image::GenericImage` for `image::SubImage<&image::ImageBuffer<image::Luma<u8>, std::vec::Vec<u8>>>`
I was still intrigued by the problem of using views. I
didn't managemanaged to do it,butand in thisincompleteimplementationbrightest()
function accepts images asGenericImage
traits – both views andGrayImage
s should implement thatbrightest()
from the main programconstant value pixels are returned since I couldn't figure out how to turnget_pixel()
return values intoLuma
sI
can't wrap my head aroundsolved this by usingGenericImageView
instead ofGenericImage
: