GithubHelp home page GithubHelp logo

Comments (3)

cospectrum avatar cospectrum commented on August 19, 2024

The first thing to check is whether opencv is using the GPU in this case or not.

from imageproc.

theotherphil avatar theotherphil commented on August 19, 2024

OpenCV may well be doing something smarter, but one difference here is that you're using a 7x7 filter for OpenCV and a 15x15 filter for imageproc. OpenCV takes a width parameter that it requires to be odd, whereas imageproc takes a radius parameter and uses a filter of size 2*radius + 1 to ensure it's always odd. This is possibly a confusing API!

from imageproc.

theotherphil avatar theotherphil commented on August 19, 2024

Having reminded myself of what the code does, the imageproc implementation is linear in kernel width so your accidental difference in parameters shouldn't account for much of the difference between the two libraries!

Quick empirical sanity check for this:

use std::time::SystemTime;
use image::{GrayImage, Luma};
use imageproc::filter::median_filter;

fn main() {
    let image = GrayImage::from_fn(9720, 11340, |_, _| Luma([7]));
    
    let t0 = SystemTime::now();
    let _f1 = median_filter(&image, 3, 3);
    let t1 = SystemTime::now();
    let _f2 = median_filter(&image, 7, 7);
    let t2 = SystemTime::now();
    
    println!("{:?}", t1.duration_since(t0));
    println!("{:?}", t2.duration_since(t1));
}

Ok(3.232656s)
Ok(6.872397s)

That's still slower than your OpenCV run time, but far faster than your imageproc run time. I suspect you might be running your code in debug mode and so comparing a debug build of imageproc against a release build of OpenCV.

From a quick glance at the source code for OpenCV's implementation, it looks to be doing something roughly similar to what we do in imageproc, but with SIMD acceleration. I wouldn't be too surprised by a 5-10x difference in run time, but 200x looks wrong.

@wangm23456 can you check if you're running imageproc in debug or release mode.

from imageproc.

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.