Kernel Convolution in Python 2.7
Unnecessary type conversions

There are a couple of unnecessary type conversions, for example:


index_y = int((len(kernel[0]) - 1) / 2.0) * -1



Casting to int truncates, but so does integer division.
So you can simplify the above with:

index_y = -(len(kernel_offset_y) - 1) // 2


In Python 2 integer division truncates by default,
so ... / 2 would work too.
But not in Python 3, where the behavior was changed.
Using // works in Python 2.7 and Python 3 consistently.

I also replaced the * -1 with a simpler - prefix.



On this line, x, index_x, y and index_y are all integers,
so no need to convert them to int:


temp_r, temp_g, temp_b = img.getpixel((int(x + index_x), int(y + index_y)))





This is also unnecessary:


outputIm.putdata([tuple(pixel) for pixel in d])



Since d is already a list of tuples, you could write simply:

outputIm.putdata(d)


Simplify

The default start value of range is 0, so instead of range(0, k) you could write range(k).

Instead of x = x / y you could write x /= y.

The parentheses are unnecessary in if (expr):.

Formatting

Instead of this:


kernel = [[1]*10]*10



PEP8 recommends this writing style:

kernel = [[1] * 10] * 10