grayscale matrix issue resolved

Resending pull request (#451).
Tests are working.

Signed-off-by: jayrambhia <jayrambhia777@gmail.com>