Visual Effects on Images

Setup & Test Examples

Let us import the relevant libraries and read a few images to play with.

[1]:
import numpy as np
import cv2
from cr import vision
%matplotlib inline

watch = cv2.imread('../../data/images/pocket_watch.jpg')
mountain = cv2.imread('../../data/images/mountain.png')
roses = cv2.imread('../../data/images/roses.jpg')
fighter_jet = cv2.imread('../../data/images/fighter_jet.jpg')
barbara = cv2.imread('../../data/images/barbara.png', 0)
puppy = cv2.imread('../../data/images/puppy.jpg')
[2]:
vision.imshow_multiple_in_row(watch, mountain, roses, fighter_jet, barbara, puppy)
../_images/image_processing_nb_effects_3_0.png

Mirroring Left to Right

[3]:
image_modified = vision.effects.mirror_lr(watch)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_5_0.png

Mirroring Up to Down

[4]:
image_modified = vision.effects.mirror_ud(watch)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_7_0.png

Mirroring Diagonally

[5]:
image_modified = vision.effects.mirror_x(watch)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_9_0.png

Selecting Red Channel

[6]:
image_modified = vision.effects.select_red(watch)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_11_0.png
[7]:
image_modified = vision.effects.select_red(watch, 50)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_12_0.png

Selecting Green Channel

[8]:
image_modified = vision.effects.select_green(watch)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_14_0.png
[9]:
image_modified = vision.effects.select_green(watch, 50)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_15_0.png

Selecting Blue Channel

[10]:
image_modified = vision.effects.select_blue(watch)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_17_0.png
[11]:
image_modified = vision.effects.select_blue(watch, 50)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_18_0.png

Monochrome Image

[12]:
image_modified = vision.effects.monochrome(watch)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_20_0.png

Embossing

[13]:
image_modified = vision.effects.emboss(fighter_jet)
vision.imshow_multiple_in_row(fighter_jet, image_modified)
../_images/image_processing_nb_effects_22_0.png
[14]:
image_modified = vision.effects.emboss(mountain, method='SW')
vision.imshow_multiple_in_row(mountain, image_modified)
../_images/image_processing_nb_effects_23_0.png
[15]:
image_modified = vision.effects.emboss(watch, method='NE')
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_24_0.png
[16]:
image_modified = vision.effects.emboss(mountain, method='NW')
vision.imshow_multiple_in_row(mountain, image_modified)
../_images/image_processing_nb_effects_25_0.png

Motion Blur

[17]:
image_modified = vision.effects.motion_blur(mountain, kernel_size=15)
vision.imshow_multiple_in_row(mountain, image_modified)
../_images/image_processing_nb_effects_27_0.png
[18]:
image_modified = vision.effects.motion_blur(watch, kernel_size=15, horz=False)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_28_0.png

Sharpening

[19]:
image_modified = vision.effects.sharpen(roses)
differerence = vision.abs_uint8(vision.signed_subtract(roses, image_modified))
vision.imshow_multiple_in_row(roses, image_modified, differerence)

../_images/image_processing_nb_effects_30_0.png

Vignette

[20]:
image_modified = vision.effects.vignette(watch, 150)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_32_0.png
[21]:
image_modified = vision.effects.vignette(barbara, 120)
vision.imshow_multiple_in_row(barbara, image_modified)
../_images/image_processing_nb_effects_33_0.png
[22]:
image_modified = vision.effects.vignette(puppy, 100)
vision.imshow_multiple_in_row(puppy, image_modified)
../_images/image_processing_nb_effects_34_0.png
[23]:
image_modified = vision.effects.enhance_contrast(watch)
vision.imshow_multiple_in_row(watch, image_modified)
../_images/image_processing_nb_effects_35_0.png

Cartoon

[24]:
image_modified = vision.effects.cartoonize(puppy)
vision.imshow_multiple_in_row(puppy, image_modified)
../_images/image_processing_nb_effects_37_0.png

Pixelization

[25]:
image_modified = vision.effects.pixelize(puppy, 16)
vision.imshow_multiple_in_row(puppy, image_modified)
../_images/image_processing_nb_effects_39_0.png

Sepia

[26]:
image_modified = vision.effects.sepia(puppy)
vision.imshow_multiple_in_row(puppy, image_modified)
../_images/image_processing_nb_effects_41_0.png

Contour

[27]:
image_modified = vision.effects.contour(puppy)
vision.imshow_multiple_in_row(puppy, image_modified)
../_images/image_processing_nb_effects_43_0.png

3d embossing

[28]:
image_modified = vision.effects.emboss3d(roses, depth=20)
vision.imshow_multiple_in_row(roses, image_modified)
../_images/image_processing_nb_effects_45_0.png