• 811-20 Talaba: Abdisalomov Avazbek O‘qituvchi: Xayrullayev Alisher Toshkent – 2024
  • Talaba: Abdisalomov Avazbek




    Download 3,12 Mb.
    Sana14.05.2024
    Hajmi3,12 Mb.
    #230898
    Bog'liq
    kaggle 7-labaratory


    O‘ZBEKISTON RESPUBLIKASI
    RAQAMLI TEXNOLOGIYALAR VAZIRLIGI


    MUHAMMAD AL‑XORAZMIY NOMIDAGI
    TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

    VIDEOMA’LUMOTLARGA RAQAMLI ISHLOV BERISH”


    fanidan

    7 - labaratoriya ishi




    HISOBOTI
    Guruh: 811-20


    Talaba: Abdisalomov Avazbek


    O‘qituvchi: Xayrullayev Alisher


    Toshkent – 2024
    7-labaratoriya ishi
    Rasmlarni zichlashtirish natijalarini baholash
    Dastur kodi:
    from skimage.metrics import structural_similarity as ssim
    import cv2
    import numpy as np
    import math
    from matplotlib import pyplot as plt

    def mse(imageA, imageB):


    err = np.sum((imageA.astype("float") - imageB.astype("float")) ** 2)
    err /= float(imageA.shape[0] * imageA.shape[1])
    return err

    def compare(img1, img2):


    img1 = cv2.cvtColor(img1, cv2.COLOR_RGB2GRAY)
    img2 = cv2.cvtColor(img2, cv2.COLOR_RGB2GRAY)
    MSE_val = mse(img1, img2)
    SSIM_val = ssim(img1, img2)
    RMSI_val =math.sqrt(MSE_val)
    if RMSI_val!=0:
    PSNR_val=20*math.log10(255/RMSI_val)
    RMSI_val=255/pow(10.0,(PSNR_val/20.0))
    else:
    PSNR_val=100
    return MSE_val,SSIM_val,RMSI_val,PSNR_val

    org_img = cv2.imread("/kaggle/input/my-imagee/my-image.jpg")


    org_img=cv2.cvtColor(org_img, cv2.COLOR_BGR2RGB)
    fig, ax = plt.subplots(nrows=10,ncols=2,figsize=(10, 40))
    h,w,c=org_img.shape
    #inter_type=cv2.INTER_NEAREST
    #inter_type=cv2.INTER_LINEAR
    #inter_type=cv2.INTER_CUBIC
    #inter_type=cv2.INTER_AREA
    inter_type=cv2.INTER_LANCZOS4

    for i,j in zip(range(1,20,2),range(10)):


    ax[j][0].imshow(org_img)
    resized_img=cv2.resize(org_img,(int(w/i),int(h/i)),interpolation=inter_type)
    res_h,res_w,_=resized_img.shape
    ax[j][0].title.set_text("({}:{})/{}=({}:{})".format(h,w,i,res_h,res_w))
    resized_img=cv2.resize(resized_img,(w,h),interpolation=inter_type)
    MSE,SSIM,RMSI,PSNR=compare(org_img,resized_img,)

    ax[j][1].imshow(resized_img)


    ax[j][1].title.set_text("MSE:{:.2f} SSIM:{:.2f}RMSE:{:.2f} PSNR:{:.2f}".format(MSE,SSIM,RMSI,PSNR))

    plt.show()





    Kaggle ilovasida bajarilgan ish havolasi: https://www.kaggle.com/code/avazbekabdisalomov/7-labaratory


    Xulosa
    Ushbu laboratoriya ishida, rasmlarni zichlashtirish va natijalarini baholash uchun kaggleda dastur yaratdik. Dastur rasmlarni zichlashtirish va ularga mos holda SSIM, MSE, RMSE va PSNR kabi xususiyatlarni hisoblash uchun skimage, cv2, numpy va math kabi kutyaptirlar ishlatilgan. Natijalar, matplotlib kutubxonasidan foydalanib tasvirlar bilan ko'rsatildi.
    Asosiy dastur funksiyalari quyidagicha:

    1. mse(imageA, imageB): Ikkala rasmlar o'rtasidagi o'rtacha kvadrat xatolikni hisoblaydi.

    2. compare(img1, img2): Ikki rasmlarni solishtirib, ularning MSE, SSIM, RMSE va PSNR kabi farqliliklarini hisoblaydi.

    3. Asl rasmlar ochiladi va RGB formatiga o'tkaziladi.

    4. Belgilangan qayta o'lchash nisbatlari va interpolatsiya usulini tanlanadi.

    5. O'lchangan rasm olish uchun yangi rasmlar olish, keyin asal rasmlar bilan solishtiriladi.

    6. Har bir qayta o'lchash holati uchun asl va qayta o'lchangan rasmlar bilan bog'liq metrikalar va tasvirlar yaratiladi.

    Bu kodlar, rasmlarni o'zgartirish va ularga mos holda qanday o'zgarishlar kelishini baho qilish uchun foydalanilishi mumkin.
    Kaggle ilovasida bajarilgan ish havolasi: https://www.kaggle.com/code/avazbekabdisalomov/7-labaratory
    Download 3,12 Mb.




    Download 3,12 Mb.