A Wolfram Notebook on Image Effects
There are various ways in the Wolfram Language to transform an image and create an effect. Popular image effects range from making an image look old—for example, a sepia color effect—all the way to transferring the style of an image to another. Here we use a few examples to show how image effects can be created.
Let’s start from an RGB image. :
Clickinthecode,thenholdandpresstorunit
In[1]:=
image=ImageResize[RemoveAlphaChannel@Import["https://cdn.pixabay.com/photo/2017/06/01/16/35/kingfisher-2363879_1280.jpg"],480]
Out[1]=
Color Transformations
Color Transformations
Create a higher-contrast image:
In[2]:=
ImageAdjust[image,0.5]
Out[2]=
It is also common to use a small number of colors to represent an image. This transformation, known as color quantization, can be performed by the function ColorQuantize:
In[3]:=
ColorQuantize[image,16]
Out[3]=
Color quantization can be performed with or without dithering. Compare the result without dithering:
In[4]:=
ColorQuantize[image,16,DitheringFalse]
Out[4]=
Edges of the quantized image can also be highlighted by subtracting them from the quantized image:
In[5]:=
q=ColorQuantize[image,16,DitheringFalse];
In[6]:=
q-EdgeDetect[q]/3
Out[6]=
Color Reduction
Color Reduction
Create a grayscale version of the image:
In[7]:=
ColorConvert[image,"Grayscale"]
Out[7]=
Increase the contrast of the grayscale image:
The function ImageEffect has a variety of other color transformations, such as creating a sepia effect:
Framing
Framing
Another type of image effect is to add a frame around an image. One can add a simple frame by adding a constant color frame, e.g. with the ImagePad function in the Wolfram Language:
ImageEffect has a few framing effects, including vignette, faded, torn paper and other frames:
Stylization
Stylization
Images can be stylized using image processing techniques to simulate charcoal drawing, oil painting, embossing and more. ImageEffect has a few stylization effects:
Deep neural networks also offer models to restyle an image based on the style of another image. ImageRestyle uses a neural network approach to perform such a style transfer:
The amount of style transfer can also be controlled using a style transfer image together with a restyle weighting factor:
In this notebook, we illustrated a number of effects that can be applied to images using the ImageEffect function together with a few of the many image processing functions available in the Wolfram Language. However, this is only a taste of what’s possible. Using the power and flexibility of Mathematica and the Wolfram Language, it is possible to create and apply virtually any effect suited to your artistic application, limited only by your imagination and creativity.