0% found this document useful (0 votes)
3 views4 pages

vertopal.com_day8_image_processing_lab

Uploaded by

dhanjaljobanjit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

vertopal.com_day8_image_processing_lab

Uploaded by

dhanjaljobanjit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

import numpy as np

import cv2
import matplotlib.pyplot as plt
from google.colab.patches import cv2_imshow

img = cv2.imread('F7.png',0)

cv2_imshow(img)

1. Implement Log transformation and power law gamma transformation


2. Compare the output of both transformation
3. Display histograms before and after transformation
# Log transform
image_float = np.float32(img) + 1
img_log = np.log(image_float)
log_transformed = cv2.normalize(img_log, None, 0, 255,
cv2.NORM_MINMAX)
cv2_imshow(log_transformed)
# Gamma transform
gamma = 1.5
img_gamma = np.power(img, gamma)
gamma_transformed = cv2.normalize(img_gamma, None, 0, 255,
cv2.NORM_MINMAX)
cv2_imshow(gamma_transformed)

res = np.hstack((img, log_transformed, gamma_transformed))


cv2_imshow(res)
# Histogram for original image
hist = cv2.calcHist([img], [0], None, [256], [0, 256])
plt.plot(hist)
plt.show()

# Histogram after log transform


hist = cv2.calcHist([log_transformed], [0], None, [256], [0, 256])
plt.plot(hist)
plt.show()

You might also like