1 | initial version |
First, you don't need to convert your images from unsigned char to double. Any function that takes double as input will work just as good with unsigned char. And since the output is put inside image of unsigned char, your function should return unsigned char as well. Of course inside your function you can use doubles but its input and output should be unsigned char.
Second, you don't need to split image into channels. The only thing you need to remember is that when you are trying to access neighbor of pixel you should move by three bytes instead of one.
To conclude this: you don't need any temporary containers. Your input and output images are more than enough for functions like filter2D or other similar functions.
P.S. I am not 100% sure about Java since I am working with C++ but I think it should be pretty much the same.