How to add watermarks to images via command line – Hopefully using Irfanview

I recommend using ImageMagick, which is open source and quite standard for manipulating images on the command line. Watermarking with an image is as simple as composite -dissolve 30% -gravity south watermark.jpg input-file.jpg output-file.jpg With text, it’s a little more complicated but possible. Using the above command as an example, a Bash command for doing … Read more

Image Processing – Implementing Sobel Filter

It’s pretty easy, you just need to convolve your image with a Sobel filter. A Sobel filter has two kernels, x-direction kernel and y-direction kernel. The x-direction kernel detects horizontal edges, and y-direction kernels detects vertical edges. x-direction kernel (the size is 3×3) float kernelx[3][3] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}}; … Read more

FFMPEG: chroma key / greenscreen filter for images / video [closed]

The answer (now) is yes, there is a filter for generating chroma-keys and overlaying them. The filter name is “color key”. There are examples on the site, here’s the command: ffmpeg -i <base-video> -i <overlay-video> -filter_complex ‘[1:v]colorkey=0x<color>:<similarity>:<blend>[ckout];[0:v][ckout]overlay[out]’ -map ‘[out]’ <output-file> where <color> is the rgb color to match in hex (ex: 0x000000 for black), <similarity> … Read more

Detect which image is sharper

As e.g. shown in this Matlab Central page, the sharpness can be estimated by the average gradient magnitude. I used this in Python as from PIL import Image import numpy as np im = Image.open(filename).convert(‘L’) # to grayscale array = np.asarray(im, dtype=np.int32) gy, gx = np.gradient(array) gnorm = np.sqrt(gx**2 + gy**2) sharpness = np.average(gnorm) A … Read more

Filling holes inside a binary object

There are two methods to do this: 1) Contour Filling: First, invert the image, find contours in the image, fill it with black and invert back. des = cv2.bitwise_not(gray) contour,hier = cv2.findContours(des,cv2.RETR_CCOMP,cv2.CHAIN_APPROX_SIMPLE) for cnt in contour: cv2.drawContours(des,[cnt],0,255,-1) gray = cv2.bitwise_not(des) Resulting image: 2) Image Opening: kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(3,3)) res = cv2.morphologyEx(gray,cv2.MORPH_OPEN,kernel) The resulting image is … Read more

Impulse, gaussian and salt and pepper noise with OpenCV

As far as I know there are no convenient built in functions like in Matlab. But with only a few lines of code you can create those images yourself. For example additive gaussian noise: Mat gaussian_noise = img.clone(); randn(gaussian_noise,128,30); Salt and pepper noise: Mat saltpepper_noise = Mat::zeros(img.rows, img.cols,CV_8U); randu(saltpepper_noise,0,255); Mat black = saltpepper_noise < 30; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)