Color filters allow you to alter an image by … well … filtering out colors from an image. While Processing has some filters built-in, it’s often handy to be able to create your own custom filters. For example, the site Anaglyph Methods Comparison details a number of different filters that are handy in creating 3D images.
As you’ll see from the site, filters are basically mathematical transformations that are applied to the red, green, and blue components of the pixels in an image. To create a filter like the ones on the stereo anaglyph site, we need to pull each pixel in the original image, apply a matrix operation to its color components, and then use this new value in the corresponding pixel in the new image. This Codebox shows you how to create your own filters like these.
First, though, a bit of review for the (potentially) hairy looking math. A matrix is a 2 dimensional array of numbers called elements. Matrices are used in many different applications, representing sets of equations, transformations to 3D objects, and color filters (as in this example).
A matrix is usually characterized by its dimensions: the number of elements in its rows (the numbers going across ) and columns (the numbers going up and down). By convention, the number of rows always comes first. The following figure shows 2 matrices. On the left is a 2 row by 3 matrix, which is generally just called a 2×3 matrix. On the right is a 3 row by 2 column matrix, also called a 3×2 matrix:
Color filters allow you to alter an image by … well … filtering out colors from an image. While Processing has some filters built-in, it’s often handy to be able to create your own custom filters. For example, the site Anaglyph Methods Comparison details a number of different filters that are handy in creating 3D images.
As you’ll see from the site, filters are basically mathematical transformations that are applied to the red, green, and blue components of the pixels in an image. To create a filter like the ones on the stereo anaglyph site, we need to pull each pixel in the original image, apply a matrix operation to its color components, and then use this new value in the corresponding pixel in the new image. This Codebox shows you how to create your own filters like these.
First, though, a bit of review for the (potentially) hairy looking math. A matrix is a 2 dimensional array of numbers called elements. Matrices are used in many different applications, representing sets of equations, transformations to 3D objects, and color filters (as in this example).
A matrix is usually characterized by its dimensions: the number of elements in its rows (the numbers going across ) and columns (the numbers going up and down). By convention, the number of rows always comes first. The following figure shows 2 matrices. On the left is a 2 row by 3 matrix, which is generally just called a 2×3 matrix. On the right is a 3 row by 2 column matrix, also called a 3×2 matrix:
การแปล กรุณารอสักครู่..
