a. Write a function that allows you to highlight a specific range of grays in an image. The function must receive as input parameters: a grayscale image (uint8), parameter A and B that defines the range of values that the function will highlight. A and B must be positive and less than 255. Output image will be a black and white image; the white pixels will correspond to the pixels with values between A and B in the input image, and black pixels to all other pixels.
b. Select a color image, transform the image to grayscale and apply the range enhancement grays for the following values of A and B: [A, B] = {[20 240], [40 200], [80 180], [100 150], [120 135]}.
Hello again, this time is an artificial point of vision where you have to make a gray highlight. The question is that I understand very little. More or less I understand that you take an image and what is in black turns it white and white turns it black. I have searched on Google but it is not very understandable if someone knew how to explain to me I would appreciate it.
- The code we are implementing is this:
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
import sys
sys.path.append('/media/basilio/ADATA UFD/VAI92/Code/')
import my_linealT as trans
Im_g = Image.open('img2.jpg').convert('L')
Im_ga = np.array(Im_g)
a = np.array([1, 1, 1])
p1 = np.array([50, 125])
p2 = np.array([200, 225])
Im2 = trans.my_linealTrozos(Im_ga,a,p1,p2)
plt.gray()
plt.imshow(np.uint8(Im_ga))
plt.axis("off")
plt.figure()
plt.gray()
plt.imshow(Im2)
plt.axis("off")