1. Obtain histogram equalization for both original and negative of an image in Python. give direct one sniipit code
Question
1. Obtain histogram equalization for both original and negative of an image in Python.
give direct one sniipit code
Solution
Sure, here is a Python code snippet that performs histogram equalization on both the original and negative of an image using OpenCV and NumPy libraries.
import cv2
import numpy as np
# Load the image
original_img = cv2.imread('image.jpg', 0)
# Perform histogram equalization on the original image
equalized_img = cv2.equalizeHist(original_img)
# Create a negative image by subtracting the original image from 255
negative_img = 255 - original_img
# Perform histogram equalization on the negative image
equalized_negative_img = cv2.equalizeHist(negative_img)
# Display the images
cv2.imshow('Original Image', original_img)
cv2.imshow('Equalized Image', equalized_img)
cv2.imshow('Negative Image', negative_img)
cv2.imshow('Equalized Negative Image', equalized_negative_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Please replace 'image.jpg'
with the path to your image. This code will display the original image, the equalized image, the negative image, and the equalized negative image.
Similar Questions
Gaussian smoothing Laplacian sharpening Histogram equalization Total variation denoising
Which of the following tools is used to adjust the brightness, contrast and tonal range of an image histogram
Write a Python function that takes a listand makes all negative values topositive ones if there is any.Sample output:
Which of the following will give the same result as cv2.flip(img, 1)? ("img" represents BGR image)
Histogram is useful to determine graphically the value of(a) Arithmetic Mean(b) Median(c) Mode(d) HM
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.