Closed Priyankaagrawal closed 1 year ago
Can you send me the code and the output image to reproduce?
` from PIL import Image from pathlib import Path import numpy as np from chromakey import chroma_key
image_path = Path(file).parent / "uneven_green_green_lighting.png" image = Image.open(str(image_path))
background_image_path = Path(file).parent / "MAWP-C-1302_1.jpg" background_image = Image.open(str(background_image_path))
image = np.asarray(image) background_image = np.asarray(background_image) maskedimage, = chroma_key( image, keycolor="#6dff8b", background_image=background_image, tola=25, tolb=50 ) Image.fromarray(masked_image).show()`
Ah yes. If you look into the code, the background image is resized to the same size as the original image. Background image is then summed with the mask.
If you don't want it to be zoomed in. You have to somehow project your image onto the mask.
Can you suggest, where I need to do this changes? I think this changes will go in core.py? I just want to apply image in green screen fully
I imagine it would be a separate new function. It is quite specific to your use case. You have to change the way you sum your background image and the mask array. Check: https://github.com/eugeneteoh/chromakey/blob/main/chromakey/core.py#L40
I have one more more query. Is it possible to start masking where the green-screen start instead of taking full width. It prevents my background image from cropping
As mentioned above:
If you don't want it to be zoomed in. You have to somehow project your image onto the mask.
I don't think this is easy as what you want is not a linear projection. The mask is almost never a perfect square/rectangle. You have to somehow distort your background image onto project to the mask. Best to ask someone else, as I'm not super familiar with this topic.
Hi I just wanted to replace the green screen with image attached, but the output is quite blur and image is cropping and zoomed. Please help me to resolve on same