Ask Your Question

imnoise() like function in SimpleCV

asked 2014-02-22 13:34:32 -0500

lastlegion gravatar image

Hi Is there a function that adds noise to an image? This is helpful when you are experimenting with denoising methods. There is a function imnoise() in matlab that does this. It lets you choose the type of noise you want to add(gaussian, salt and pepper etc) and the intensity. Please let me know if there is some function that does something of this kind in SimpleCV.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-02-22 18:22:35 -0500

xamox gravatar image

Here is a simple way to do it yourself (salt & pepper):

    from SimpleCV import Image
    import random

    def addNoise(img, percent=0.1):
        narr = img.getNumpy()
        amount = int((img.width * img.height) * percent)

        for i in range(amount):
            r = random.randrange(2)
            color = (0,0,0) if r == 1 else (255,255,255)
            narr[random.randrange(img.width)][random.randrange(img.height)] = color

        return Image(narr)
edit flag offensive delete link more


Thanks I was wondering if there was a method that could do all this automatically as I need to experiment with different types of noise(gaussian, poisson etc). Now I know I'll have to write them by hand. Thanks for your help :)

lastlegion gravatar imagelastlegion ( 2014-02-22 22:17:45 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-02-22 13:34:32 -0500

Seen: 170 times

Last updated: Feb 22 '14