0% found this document useful (0 votes)
26 views

Import Import As From Import As: 'Ronaldo - JPG'

The document contains Python code that loads an image, applies different blurring filters to it using OpenCV, and displays the original and filtered images for comparison. It reads in an image, converts the color space, applies filters like Gaussian blur, median blur and bilateral blur. It then plots the original and filtered images side by side to show the effects of the different blurring techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Import Import As From Import As: 'Ronaldo - JPG'

The document contains Python code that loads an image, applies different blurring filters to it using OpenCV, and displays the original and filtered images for comparison. It reads in an image, converts the color space, applies filters like Gaussian blur, median blur and bilateral blur. It then plots the original and filtered images side by side to show the effects of the different blurring techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

import cv2

import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('Ronaldo.jpg')
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

kernel = np.ones((5, 5), np.float32)/25


dst = cv2.filter2D(img, -1, kernel)
blur = cv2.blur(img, (5, 5))
gblur = cv2.GaussianBlur(img, (5, 5), 0)
median = cv2.medianBlur(img, 5)
bilateralFilter = cv2.bilateralFilter(img, 9, 75, 75)

titles = ['image', '2D Convolution', 'blur', 'GaussianBlur', 'median',


'bilateralFilter']
images = [img, dst, blur, gblur, median, bilateralFilter]

for i in range(6):
plt.subplot(2, 3, i+1), plt.imshow(images[i], 'gray')
plt.title(titles[i])
plt.xticks([]),plt.yticks([])
plt.show()
import cv2
import matplotlib.pyplot as plt
import numpy as np
a = cv2.imread("Ronaldo.jpg")
b = cv2.cvtColor(a, cv2.COLOR_BGR2RGB )
plt.imshow(a)
plt.show()

import cv2
import matplotlib.pyplot as plt
import numpy as np
a = cv2.imread("Ronaldo.jpg")
b = cv2.cvtColor(a, cv2.COLOR_BGR2RGB )
plt.imshow(b)
plt.show()
import cv2
import matplotlib.pyplot as plt
import numpy as np
a = cv2.imread("Ronaldo.jpg")
b = cv2.cvtColor(a, cv2.COLOR_BGR2RGB )
c = b.shape

tinggi = b.shape[0]
lebar = b.shape[1]
channels = b.shape[2]

print('Dimensi =',c)
print('Tinggi =',tinggi)
print('Lebar =',lebar)
print('Channels =',channels)

Hasil Run

You might also like