Language:EN
Pages: 4
Words: 437
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
histogram equalization answer and explanation

histogram equalization answer and explanation

Histogram Equalization Assignment Answers

Question:

Programming OpenCV – (a) Use the VideoCapture() function in OpenCV to capture yourself and use the function cv2.imwrite(‘output.jpg’, frame) to save your photo to a JPG file, (b) Use the OpenCV to generate the histogram, and (c) Apply the principle of Histogram Equalization.

while(True):

# Capture frame-by-frame

cv2.imshow('frame',gray)

if cv2.waitKey(1) & 0xFF == ord('q'):

Histogram Equalization Answer and Explanation

Here's how you can modify your code to include these functionalities:

Part (a) Capture and Save Image

    # Capture frame-by-frame

    ret, frame = cap.read()

    if cv2.waitKey(1) & 0xFF == ord('s'):

        cv2.imwrite('output.jpg', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):

        break

- This code captures frames from your camera (`VideoCapture(0)` represents the default camera).

- It displays the live feed and waits for the user to press 's' to save the current frame as `output.jpg`.

# Load the saved image

img = cv2.imread('output.jpg', 0)  # Load as grayscale

plt.xlabel('Pixel Intensity')

plt.ylabel('Frequency')

- Matplotlib is used to plot and display the histogram.

Part (c) Apply Histogram Equalization

# Apply histogram equalization

equ = cv2.equalizeHist(img)

plt.title('Original Image')

plt.axis('off')

plt.tight_layout()

plt.show()

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : vedika rana

PageId: DOCB9B0A57