inspirit / jsfeat

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

imgproc: Morphology erode and dilate #18

Open ghost opened 11 years ago

ghost commented 11 years ago

Hi,

I have added two morphology functions based on a partial Open CV port to Javascript located here: http://code.google.com/p/js-handtracking/

I have allowed in place modifications of data_t by allocating a temporary array buffer copied from the source using the ArrayBuffer.slice method.

You may want to change that to use a matrix_t/data_t 'slice' method that would hide the fact that ArrayBuffer.slice is not supported in IE.

Cheers

David

inspirit commented 11 years ago

hi can u rewrite it a bit and get use of jsfeat cache sys? so u wont need to allocate buffers

ghost commented 11 years ago

The problem is that I want to initialize the new buffer with the data contained in the src, taking advantage of the fast memory copy allowed by slice: I don't see how I could do that with the existing jsfeat buffer types.

inspirit commented 11 years ago

ahh i see now. yeah probably better to use matrix_t copy to data_t from cache. so it will work in IE also since kernel is known size i dont see the reason to use loop there. it can be optimized to inplace check for surrounding values

ghost commented 11 years ago

it can be optimized to inplace check for surrounding values

Could you elaborate on that ? I'd be happy to remove one full copy if I can ...

inspirit commented 11 years ago

well u still need to create a copy of src matrix if it === dst to make that u get the buffer from cache and use copy_to method. the second thing i was talking about is that u use loop for checking values around current position. as far as we know all offsets at start and kernel is fixed size we can remove the loop and put all the checks instead, that might be faster than using 3d loop there

ghost commented 11 years ago

Got it. I will post an updated patch.

serapath commented 7 years ago

@inspirit this discussion above looks good. why was this not merged yet?

krhoyt commented 6 years ago

Added the dilate function (applyKernel) manually since this still does not seem merged. Works great! Rounding it off with findContours and approxPolyDP functions would give a good chunk of what most CV projects would need without the overhead of the massive OpenCV JS port.

sona1111 commented 4 years ago

@krhoyt Do you have a repository with the merged changes available?