OpenCV Python Histogram Equalization and CLAHE

Поделиться
HTML-код
  • Опубликовано: 4 ноя 2024

Комментарии • 6

  • @kevinwoodrobotics
    @kevinwoodrobotics  Год назад

    Code and Doc: kevinwoodrobotics.com/product/opencv-python-histogram-equalization-and-clahe/
    OpenCV Python Playlist Code and Doc: kevinwoodrobotics.com/product/opencv-python-tutorials-full-playlist/

  • @colourftw
    @colourftw Год назад

    I like the intro!

  • @d_antisocial00
    @d_antisocial00 9 месяцев назад

    💕💕👩🏻‍💻

  • @muhammadamarussalam6500
    @muhammadamarussalam6500 Год назад

    can i get the code?

    • @kevinwoodrobotics
      @kevinwoodrobotics  Год назад +1

      import cv2 as cv
      import numpy as np
      import matplotlib.pyplot as plt
      import os
      def histogramEqual():
      root = os.getcwd()
      imgPath = os.path.join(root,'demoImages\\badQuality.jpg')
      img = cv.imread(imgPath,cv.IMREAD_GRAYSCALE)
      hist = cv.calcHist([img],[0],None,[256],[0,256])
      cdf = hist.cumsum()
      cdfNorm = cdf * float(hist.max()) / cdf.max()
      plt.figure()
      plt.subplot(231)
      plt.imshow(img,cmap='gray')
      plt.subplot(234)
      plt.plot(hist)
      plt.plot(cdfNorm,color='b')
      plt.xlabel('pixel intesity')
      plt.ylabel('# of pixels')
      equImg = cv.equalizeHist(img)
      equhist = cv.calcHist([equImg],[0],None,[256],[0,256])
      equcdf = equhist.cumsum()
      equcdfNorm = equcdf * float(equhist.max()) / equcdf.max()
      plt.subplot(232)
      plt.imshow(equImg,cmap='gray')
      plt.subplot(235)
      plt.plot(equhist)
      plt.plot(equcdfNorm,color='b')
      plt.xlabel('pixel intesity')
      plt.ylabel('# of pixels')
      claheObj = cv.createCLAHE(clipLimit=5,tileGridSize=(8,8))
      claheImg = claheObj.apply(img)
      clahehist = cv.calcHist([claheImg],[0],None,[256],[0,256])
      clahecdf = clahehist.cumsum()
      clahecdfNorm = clahecdf * float(clahehist.max()) / clahecdf.max()
      plt.subplot(233)
      plt.imshow(claheImg,cmap='gray')
      plt.subplot(236)
      plt.plot(clahehist)
      plt.plot(clahecdfNorm,color='b')
      plt.xlabel('pixel intesity')
      plt.ylabel('# of pixels')
      plt.show()
      if __name__ == '__main__':
      histogramEqual()