Avoiding Boundaries `if` Cases When Filtering Image Matrix
visiting black chess board squares

You might do a mod2 pre-calculation of mod(iRowIdx + iColIdx, 2) by creating a chess board boolean matrix before the loop, using matrix operations.

But much better would be to step iColIdx by 2. And have iRowIdx start at 1 or 2 as appropriate, and then step it by 2.

boundary checking

Your matrix now is C x R. Simply allocate a (C+2) x (R+2) matrix, so you have zeros running along all four sides. Then iterate over just the middle, rather than over the whole matrix as you are now. So iColIdx for example would start at 2 and stop one short of the end.

Doing this will delete a great many ifs, to give you Version2 of the code. You might even find that puts you in a position to produce Version3, which takes advantage of matrix operations instead of scalar operations, pushing much of the looping work down into matlab primitives, which would be faster.

style

It would have been helpful to see the method signature, but your English description that mOutputImage is the only return value worked well enough.

Typo: % Filteration

It would be natural to express the normalization e.g. like this:

    relWeight4 *= weightsNormalizationFactor;


Leave a blank after if, please.

The extra parentheses in mod and places like this:

        relPixel1 = mOutputImage((iRowIdx + 1), iColIdx);


are a little odd, you could safely elide them.