Make datasets/raise/merge_single_color_channel_images_according_to_bayer_filter.py
production ready
This commit is contained in:
parent
0b52e781e3
commit
77330e24d2
@ -7,27 +7,31 @@ def getImageByColor(color):
|
||||
|
||||
color = Color.BLUE
|
||||
image = getImageByColor(color)
|
||||
width, height= image.size
|
||||
width, height = image.size
|
||||
|
||||
multipleColorsImage = Image.new('RGB', [dimension * 2 for dimension in image.size])
|
||||
|
||||
def getNewIndex(index, offset):
|
||||
newIndex = (index - offset) * 2 + offset
|
||||
return newIndex
|
||||
|
||||
for color in tqdm(Color, 'Color'):
|
||||
colorImage = getImageByColor(color)
|
||||
for y in tqdm(range(height), 'Height'):
|
||||
for x in range(width):
|
||||
pixel = colorImage.getpixel((x, y))
|
||||
'''
|
||||
Assume Bayer Filter:
|
||||
RG
|
||||
GB
|
||||
'''
|
||||
newX, newY = {
|
||||
Color.RED: (x, y),
|
||||
Color.GREEN_RIGHT: (x - 1, y),
|
||||
Color.GREEN_BOTTOM: (x, y - 1),
|
||||
Color.BLUE: (x - 1, y - 1),
|
||||
offsetX, offsetY = {
|
||||
Color.RED: (0, 0),
|
||||
Color.GREEN_RIGHT: (1, 0),
|
||||
Color.GREEN_BOTTOM: (0, 1),
|
||||
Color.BLUE: (1, 1),
|
||||
}[color]
|
||||
newX *= 2
|
||||
newY *= 2
|
||||
newX, newY = [getNewIndex(index, offset) for index, offset in [(x, offsetX), (y, offsetY)]]
|
||||
|
||||
multipleColorsImage.putpixel((newX, newY), pixel)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user