How to check if a specific pixel of an image is transparent?

Building on Jeff’s answer, your first step would be to create a canvas representation of your PNG. The following creates an off-screen canvas that is the same width and height as your image and has the image drawn on it. var img = document.getElementById(‘my-image’); var canvas = document.createElement(‘canvas’); canvas.width = img.width; canvas.height = img.height; canvas.getContext(‘2d’).drawImage(img, … Read more

Converting RGB to grayscale/intensity

The specific numbers in the question are from CCIR 601 (see Wikipedia article). If you convert RGB -> grayscale with slightly different numbers / different methods, you won’t see much difference at all on a normal computer screen under normal lighting conditions — try it. Here are some more links on color in general: Wikipedia … Read more

How do I crop an image using C#?

Check out this link: http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing private static Image cropImage(Image img, Rectangle cropArea) { Bitmap bmpImage = new Bitmap(img); return bmpImage.Clone(cropArea, bmpImage.PixelFormat); }

Use pytesseract OCR to recognize text from an image

Here is my solution: import pytesseract from PIL import Image, ImageEnhance, ImageFilter im = Image.open(“temp.jpg”) # the second one im = im.filter(ImageFilter.MedianFilter()) enhancer = ImageEnhance.Contrast(im) im = enhancer.enhance(2) im = im.convert(‘1’) im.save(‘temp2.jpg’) text = pytesseract.image_to_string(Image.open(‘temp2.jpg’)) print(text)

Resize image in PHP

You need to use either PHP’s ImageMagick or GD functions to work with images. With GD, for example, it’s as simple as… function resize_image($file, $w, $h, $crop=FALSE) { list($width, $height) = getimagesize($file); $r = $width / $height; if ($crop) { if ($width > $height) { $width = ceil($width-($width*abs($r-$w/$h))); } else { $height = ceil($height-($height*abs($r-$w/$h))); } … Read more

OpenCV C++/Obj-C: Detecting a sheet of paper / Square Detection

This is a recurring subject in Stackoverflow and since I was unable to find a relevant implementation I decided to accept the challenge. I made some modifications to the squares demo present in OpenCV and the resulting C++ code below is able to detect a sheet of paper in the image: void find_squares(Mat& image, vector<vector<Point> … Read more

Cinemagraph Encoding in C++

There is no specification and there is no algorithm that will define what moves and what is still. Cinemagraphs are an art form. It’s the artist’s choice that makes the difference between a simple animated gif or video and an appealing cinemagraph. I think you did not fully understand what this is about so you … Read more