Samarand davlat universiteti raqamli texnologiyalar fakulteti


Haar almashitirishini tasvirga qo’llash dasturi



Download 1,78 Mb.
bet6/7
Sana29.05.2022
Hajmi1,78 Mb.
#616114
1   2   3   4   5   6   7
Bog'liq
Veyvelet kurs ishi

Haar almashitirishini tasvirga qo’llash dasturi.
import numpy as np
import pywt
import cv2
def w2d(img, mode='haar', level=1):
imArray = cv2.imread(img)
# Ma'lumotlar turini o'zgartirish
# kulrang rangga aylantirish
imArray = cv2.cvtColor( imArray,cv2.COLOR_RGB2GRAY )
# floatga aylantiring
imArray = np.float32(imArray)
imArray /= 255;
# koeffitsientlarni hisoblash
coeffs=pywt.wavedec2(imArray, mode, level=level)
# Jarayon koeffitsientlari
coeffs_H=list(coeffs)
coeffs_H[0] *= 0;
# qayta qurish
imArray_H=pywt.waverec2(coeffs_H, mode);
imArray_H *= 255;
imArray_H = np.uint8(imArray_H)
# Natijani ko'rsatish
cv2.imshow('image',imArray_H)
cv2.waitKey(0)
cv2.destroyAllWindows()
w2d("test1.png",'db1',10)
Diskret veyvelet-almashtirish
Misol: Tasvirga veyvelet-almashtirishni qo’llash.
import numpy as np
import matplotlib.pyplot as plt
import cv2
import pywt
import pywt.data
# Load image
image = cv2.imread('test2.png')
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Convert to float for more resolution for use with pywt
image = np.float32(image)
image /= 255
# Wavelet transform of image, and plot approximation and details
titles = ['Approximation', ' Horizontal detail',
'Vertical detail', 'Diagonal detail']
coeffs2 = pywt.dwt2(image, 'bior1.3')
LL, (LH, HL, HH) = coeffs2
fig = plt.figure(figsize=(12, 3))
for i, a in enumerate([LL, LH, HL, HH]):
ax = fig.add_subplot(1, 4, i + 1)
ax.imshow(a, interpolation="nearest", cmap=plt.cm.gray)
ax.set_title(titles[i], fontsize=10)
ax.set_xticks([])
ax.set_yticks([])

fig.tight_layout()
plt.show()

Tezkor Haar almashtirishi
import numpy as np
from matplotlib import pyplot as plt
import pywt
import cv2
# Load image
img = cv2.imread('test1.png')
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Convert to float for more resolution for use with pywt
img = np.float32(img)
img /= 255
# Fully separable transform
fswavedecn_result = pywt.fswavedecn(img, 'db2', 'periodization', levels=4)
# Standard DWT
coefs = pywt.wavedec2(img, 'db2', 'periodization', level=4)
# convert DWT coefficients to a 2D array
mallat_array, mallat_slices = pywt.coeffs_to_array(coefs)
fig, (ax1, ax2) = plt.subplots(1, 2)
ax1.imshow(np.abs(mallat_array)**0.25,
cmap=plt.cm.gray,
interpolation='nearest')
ax1.set_axis_off()
ax1.set_title('Mallat decomposition\n(wavedec2)')
ax2.imshow(np.abs(fswavedecn_result.coeffs)**0.25,
cmap=plt.cm.gray,
interpolation='nearest')
ax2.set_axis_off()
ax2.set_title('Fully separable decomposition\n(fswt)')
plt.show()

Download 1,78 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish