This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean parseIpAddress(String ip) throws IllegalArgumentException { // IPv4, format x.x.x.x | |
StringTokenizer tok = new StringTokenizer(ip, "."); | |
if (tok.countTokens() != 4) { | |
throw new IllegalArgumentException("IP address must be in the format 'xxx.xxx.xxx.xxx'"); | |
} | |
int i = 0; | |
while (tok.hasMoreTokens()) { | |
String strVal = tok.nextToken(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add Salt and Pepper noise to OpenCV image, vectorized approach. | |
# https://stackoverflow.com/questions/22937589/how-to-add-noise-gaussian-salt-and-pepper-etc-to-image-in-python-with-opencv | |
# Forked and fixed from https://gist.github.com/lucaswiman/1e877a164a69f78694f845eab45c381a | |
# Fixed: replaced 'image' with 'output' | |
import numpy as np | |
import cv2 | |
def sp_noise(image, prob): |