Add and use getColorChannel

This commit is contained in:
2024-04-27 21:49:32 +02:00
parent 561ec9d1e0
commit 5ea0a862c0
3 changed files with 15 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
from enum import Enum, auto
import skimage.restoration
import numpy as np
import rawpy
class Color(Enum):
RED = auto()
@@ -71,5 +72,14 @@ def getRawColorChannel(raw, color):
def isARawImage(imageFilePath):
return any([imageFileName.lower().endswith(f'.{rawImageFileExtension}') for rawImageFileExtension in RAW_IMAGE_FILE_EXTENSIONS])
def getColorChannel(imageFilePath, color):
if isARawImage(imageFilePath):
with rawpy.imread(imageFilePath) as raw:
imageNpArray = getRawColorChannel(raw, color)
else:
imagePil = Image.open(imageFilePath)
imageNpArray = img_as_float(np.array(imagePil))
return imageNpArray
def escapeFilePath(filePath):
return filePath.replace('/', '_')