image-rs / imageproc

Image processing operations
MIT License
755 stars 148 forks source link

Arithmetic Operations on Images #455

Closed ava57r closed 3 years ago

ava57r commented 3 years ago

Hello. I need image substraction. How can I get img1 - img2?

For example in OpenCV https://docs.opencv.org/3.4/dd/d4d/tutorial_js_image_arithmetics.html

I am trying to use gradY = https://docs.rs/imageproc/0.22.0/imageproc/gradients/fn.vertical_scharr.html and gradX = https://docs.rs/imageproc/0.22.0/imageproc/gradients/fn.horizontal_scharr.html

in result

gradX - gradY

Is it possible?

Thanks.

theotherphil commented 3 years ago

Arithmetic operations are not implemented directly on images, but you can achieve the same effect using map_colors2. The example in the docs adds the pixel values from two images: https://docs.rs/imageproc/0.22.0/imageproc/map/fn.map_colors2.html

ava57r commented 3 years ago

Thanks. I will try.

ava57r commented 3 years ago

It works.