Question: I have a JS Object of the form stored in a variable `keyData`: 

```
{type: "", label: "fname", title: "first name", …}
    defaultvalue: ""
    disabled: false
    label: "fname"
    readonly: false
    required: "on"
    title: "first name"
    type: ""
    __proto__: Object

```

I want to filter through these key-value pair and return a new object which contains the key-value pair with data available in them. For example, in this data, it should return **title, required, and label** only. 

With that new filtered data, I want to map a react form with filtered keys as input types and filtered values as their value.

I am confused on how to solve this. I tried using **Object.entries(keyData)**
like this:

```
   Object.entries(keyData).filter(x => console.log(x))
   console.log(keyData)

```

on the `console.log(keyData)`, it prints:

```
(2) ["type", ""]
(2) ["label", "fname"]
(2) ["title", "first name"]
(2) ["placeholder", ""]
(2) ["required", "on"]
(2) ["readonly", false]
(2) ["disabled", false]

```

I am unable to filter through this empty data further.

Answer: 
So in general you can use OpenCVs ColorMap to change colors in your image:

```
import cv2
img = cv2.imread(r"<IMAGE PATH>")
img = cv2.applyColorMap(img, cv2.COLORMAP_JET) # Change colors of image with predefined colormap

# Display the new image
cv2.imshow("img", img)
cv2.waitKey()

```

Now if you want to create your own colormap instead of using a predefined one in OpenCV you can do it with `cv2.LUT()` ([OpenCV Documentation](https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#lut))

Example Input:  

[![enter image description here](https://i.stack.imgur.com/obusB.png)](https://i.stack.imgur.com/obusB.png)

Example Output:  

[![enter image description here](https://i.stack.imgur.com/9aFSL.png)](https://i.stack.imgur.com/9aFSL.png)

And here would be a quick example of how to change Gamma with this approach:

```
def adjust_gamma(img, gamma=1.0):
    assert (img.shape[0] == 1)
    invGamma = 1.0 / gamma
    table = np.array([((i / 255.0) ** invGamma) *
                      255 for i in np.arange(0, 256)]).astype("uint8")
    new_img = cv2.LUT(np.array(img, dtype=np.uint8), table)
    return new_img 

```
It looks like you have a typo in your loop:

```
for i in range(0, 10):
    # if-elses
    ...

    images.append(enhancer.enhance(10/10))

```

You're `enhancing` the image with a factor of `1.0` at each iteration, which according to the [docs](https://pillow.readthedocs.io/en/3.1.x/reference/ImageEnhance.html#PIL.ImageEnhance.Brightness):

> 
> Adjust image brightness.
> 
> 
> This class can be used to control the brightness of an image. An enhancement factor of 0.0 gives a black image. **A factor of 1.0 gives the original image.**
> 
> 
> 

Using `z`, which I suspect was your intention, will give you the tiers of brightness your comments describe:

```
for i in range(0, 10):
    # if-elses
    ...

    images.append(enhancer.enhance(z/10))

```

**Edit**: changed assumed value from `i` to `z`, based on the text you're writing.

I should also point out that you probably want to create a temp "watermark" image during the for-loop to apply the text/rectangle to. Since the ImageDraw objects modify the image in-place, you're applying the text on top of each other at each iteration, causing some weird text on the later images.