Hello, I am moving some Matlab code from working in Matlab to working in C through the Matlab Coder. I use the function imsubtract to see the difference between two photos. I was curious if anyone knows the best way to develop an alternative to imsubtract that is coder-supported? Also, I am working with Matlab 2014b Thanks
John Williams answered .
2025-11-20
Z = X-Y;
If you have a double image, then you may have to deal with out of bounds issues (since double images are supposed to be between 0 and 1):
Z = X-Y; Z(Z < 0) = 0;
Of course, all this also assumes valid input, and that X and Y are the same size (or scalar), which imsubtract would normally take care of. So if you're concerned about the input, you may need to write your own error checking.