Posts filed under ‘Image Processing’

ffmpeg examples

http://ffmpeg.org/

Below are a few samples that I use on a regular basis.

Sample 1. Convert an avi file to an flv file (flash). ‘-sameq’ means keep same quality as source. in this example, the video file is G.avi. ‘-i’ means the input file follows. The output file is always the last file on the line.

Sample 2. Cut some time out of a video cut time out of a video (what I use to make 1 second long videos, can omit the start time)

Sample 3. the following will extract the bitmaps from the avi file and name them as images/000001.bmp and so on. the ‘%6d’ is a special character set that says make a number with a pattern of six digits. in this example a subfolder called ‘images’ has the bitmap files.

Sample 4.make a movie from individual bitmap frames with high quality using the bit rate control the frames are in the subfolder ‘movie’. the ‘0%d’ is a special character set thats look for files names that start with a zero followed by a number. For example movie/0001.png movie/0002.png.The ‘-b:v 4000k’ means set the encoding bit rate to variable with a peak rate of 4 megabits/second. to make the file size smaller, drop down below 4mpbs, the lower the number the more lossy. to make the file size larger, and less lossy, increase the peak bit rate.

Sample 5. crop to 720×480 with upper left stating at position 67,67, force video codec to h264

February 18, 2013

Implementation of a Laplacian filter

A Laplacian filter is a first derivative of the spatial values, often used to detect edges and features.

In this implementation of a sharpening filter, an image is filtered with the resulting values placed into an output matrix.

This particular filter is not a pure Laplacian, but custom designed to enhance edges in a particular image.

filter

This code is design for speed and not for flexibility:

December 24, 2012

Extract pixel values from a bitmap in Qt

The first step in writing an image processing program is usually extracting the image data from a file container such as a bitmap or jpeg file. Using Qt, the QImage class makes this easy. The QImage can open/save directly to bmp, jpeg, and other common container formats. Once a file has been opened into an instance of a QImage, the RGB pixel values can be extracted into a luminance array for processing.

Here is a code example for extraction. In this case, an array of 32-bit value is used for storage even though only the lower byte has a value.
The RGB values are mapped to the luminance vector of the YUV color space.

December 24, 2012


Archives