Closed marklundin closed 11 years ago
input should be single channel grayscale U8_t or S32_t or F32_t output will be 2 channels S32_t if input U8 or S32 and F32
first channel is dx second is dy
to render it correctly the best way will be:
sobel_derivatives(src, dst);
var w = src.cols, h = src.rows;
var dstep = w<<1, dptr=0, sptr=0;
for(y=0; y < h; y++, dptr += dstep, sptr += w) {
for(x=0; x < w; x++) {
var dx = dst.data[x*2+dptr];
var dy = dst.data[x*2+dptr+1];
var gx = Math.sqrt(dx*dx + dy*dy);
src.data[x+sptr] = gx&0xff;
}
}
Awesome. That's perfect, thanks.
I've been trying to draw the derivative back to the canvas and I can't quite figure out what sort of format it's in, or whether the derivative method takes into account the format of the destination array.
The size of the data returned from the sobel and scharr derivative functions seem to to be a square of the input. Or at least, it's difficult to determine what the output format is.
Any pointers that might help?