Sharof rashidov nomidagi samarqand davlat universiteti intellektual tizimlar va kompyuter ilmlari fakulteti


Keling, shikastlangan tasvirni tiklaylik


Download 376.05 Kb.
bet4/4
Sana31.01.2023
Hajmi376.05 Kb.
#1144514
1   2   3   4
Bog'liq
Kurs ishi 2023

Keling, shikastlangan tasvirni tiklaylik


Ushbu mashqda biz inpaint_biharmonic()funksiyadan foydalanib, unda etishmayotgan qismlari bo‘lgan tasvirni tiklaymiz.Biz shikastlangan tasvir ustida ishlaymiz. Ba'zi piksellar shikastlangan tasvirni taqlid qilish uchun ataylab ikkilik niqob yordamida 1 ga almashtirildi. Piksellarni 1s bilan almashtirish ularni butunlay qora rangga aylantiradi.Niqob qora va oq tasvir bo'lib, yamoqlari bo'lib, ular buzilgan tasvir qismlarining joylashuviga ega. Ushbu sohalarda tiklash funktsiyasini qo'llashimiz mumkin.Esda tutingki, rasm chizish - bu tasvirlar va videolarning yo'qolgan yoki buzilgan qismlarini qayta tiklash jarayoni.
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

plt.rcParams['figure.figsize'] = (10, 8)


def show_image(image, title='Image', cmap_type='gray'):
plt.imshow(image, cmap=cmap_type)
plt.title(title)
plt.axis('off')
def plot_comparison(img_original, img_filtered, img_title_filtered):
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(10, 8), sharex=True, sharey=True)
ax1.imshow(img_original, cmap=plt.cm.gray)
ax1.set_title('Original')
ax1.axis('off')
ax2.imshow(img_filtered, cmap=plt.cm.gray)
ax2.set_title(img_title_filtered)
ax2.axis('off')
from skimage.restoration import inpaint
from skimage.transform import resize
from skimage import color

defect_image = plt.imread('./dataset/damaged_astronaut.png')


defect_image = resize(defect_image, (512, 512))
defect_image = color.rgba2rgb(defect_image)

mask = pd.read_csv('./dataset/astronaut_mask.csv').to_numpy()




# Apply the restoration function to the image using the mask
restored_image = inpaint.inpaint_biharmonic(defect_image, mask, multichannel=True)


# Show ther defective image
plot_comparison(defect_image, restored_image, 'Restored image')

Logotiplarni olib tashlash


Videoda ko'rganimizdek, tasvirni tiklashning yana bir qo'llanilishi sahnadan ob'ektlarni olib tashlashdir. Ushbu mashqda biz Datacamp logotipini rasmdan olib tashlaymiz.Siz ushbu maydonni bo'yash orqali logotipni o'chirish imkoniyatiga ega bo'lish uchun niqob yaratasiz va o'rnatasiz.Esda tutingki, siz ob'ektni tasvirdan olib tashlamoqchi bo'lsangiz, uni qo'lda belgilashingiz yoki uni topish uchun tasvirni tahlil qilish algoritmini ishga tushirishingiz mumkin.
image_with_logo = plt.imread('./dataset/4.2.06_w_logo_2_2.png')


# Initialize the mask
mask = np.zeros(image_with_logo.shape[:-1])


# Set the pixels where the logo is to 1
mask[210:272, 360:425] = 1


# Apply inpainting to remove the logo
image_logo_removed = inpaint.inpaint_biharmonic(image_with_logo,
mask,
multichannel=True)


# Show the original and logo removed images
plot_comparison(image_with_logo, image_logo_removed, 'Image with logo removed')


Xulosa:
Ushbu kurs ishimda raqamli tasvirni qayta ishlashning umumiy usullari, tamoyillari va usullari muhokama qildik.Wiener filtrlash algoritmini o'z ichiga olgan har biri uchun matematik model. Biz shuningdek, turli xil algoritmlarning tegishli diapazonlari va parametrlarini tahlil qildik.

Foydalanilgan adabiyotlar.
1: C. Gonzalez and E. Woods, “Image Restoration” IEEE Digital Image Processing, 2/E, pp. 220-276, 2002.
2: J. Flusser, T.Suk, and S.Saic, “Recognition of images degraded by linear motion blur,” Computing Suppl., vol. 11, pp. 37-51, 1996.
3: J. Flusser, T. Suk, and S. Saic, “Degraded image analysis: an invariant approach,” IEEE Transaction On Pattern Analysis and Machine Intelligence, vol. 20, No. 6, pp. 590-603, 1998
4: Y. Vitzhaky, I. Mor, A. Lantzman and N.S. Kopeika, “A direct method for restoration of motion blurred images,” J. Opt. Soc. Am. A, vol. 15, No. 6, pp.1512-1519, 1998.
5: K. Paik and K. Katsaggelos, “Image restoration using a modified Hopfield network,” IEEE Trans. Image Processing, vol.1, pp. 49-63, 1992.
Download 376.05 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling