@bwalkin I have a core image kernel that does just that, if you'd like it I could send you the source.