inspirit / jsfeat

JavaScript Computer Vision library.
MIT License
2.74k stars 372 forks source link

Gaussian pyramid down supported by jsfeat? #23

Open 452 opened 10 years ago

452 commented 10 years ago

Hello, how I can configure jsfeat to get "Gaussian pyramid down"? Gaussian pyramid down supported by jsfeat?

jsfeat.imgproc.gaussian_blur(source:matrix_t, dest:matrix_t, kernel_size, sigma = 0);
jsfeat.imgproc.pyrdown(source:matrix_t, dest:matrix_t);

=-=-=-=-=-=-=-= void org.opencv.imgproc.Imgproc.pyrDown(Mat src, Mat dst) Blurs an image and downsamples it. The function performs the downsampling step of the Gaussian pyramid construction. First, it convolves the source image with the kernel: 1/256 1 4 6 4 1 4 16 24 16 4 6 24 36 24 6 4 16 24 16 4 1 4 6 4 1 Then, it downsamples the image by rejecting even rows and columns. =-=-=-=-=-=-=-=

int BLUR_LEVEL = 4;
for (int i = 0; i < BLUR_LEVEL; i++) {
    Imgproc.pyrDown(blurred, blurred);
}

=-=-=-=-=-=-=-= but better will be for jsfeat:

    jsfeat.imgproc.pyrdown(source:matrix_t, dest:matrix_t, level);
inspirit commented 10 years ago

for performance reasons jsfeat uses simple average of 4 pixels during pyr_down. if u are interested in very precise resizing during down sampling u can use jsfeat resize function.

452 commented 10 years ago

Resize down This step applies a spatial filter by calculating a level of the Gaussian pyramid. This is achieved by looping to the desired level where the input to the next loop is the result from the previous loop, starting with the original frame. A Gaussian pyramid level is calculated by, first, convolving the input frame with the kernel: K = 1/256 1 4 6 4 1 4 16 24 16 4 6 24 36 24 6 4 16 24 16 4 1 4 6 4 1 and then, downsampling the frame by rejecting even rows and columns. I can do this with jsfeat? yes or no. Be very awesome if you can create a small example.

inspirit commented 10 years ago

there is no such method available at the moment. but u can always write/add/port it in ;)