Maybe this is caused because it's not opening the right directory. Let me share the entire code and let me know: 

import numpy as np
import imageio
import os
import codecs
import matplotlib.pyplot as plt
from scipy.interpolate import Rbf
from scipy.interpolate import interp1d
import scipy.ndimage as ndimage
from scipy.stats import norm

def get\_images(image\_folder):
 images = []
 for filename in os.listdir(image\_folder):
 with codecs.open(os.path.join(image\_folder, filename), 'r', encoding='utf-8', errors='ignore') as file:
 images.append(imageio.imread(file.name))
 return images

def get\_average\_rgb(image\_path):
 image = imageio.imread(image\_path)
 average\_rgb = np.mean(image, axis=(0, 1)) / 255
 return average\_rgb

def get\_rgb\_coordinates(image\_folder):
 rgb\_coordinates = []
 for image\_name in os.listdir(image\_folder):
 image\_path = os.path.join(image\_folder, image\_name)
 average\_rgb = get\_average\_rgb(image\_path)
 rgb\_coordinates.append(average\_rgb)
 return np.array(rgb\_coordinates)

def get\_curve\_input\_output(source\_channel, target\_channel):
 source\_histogram, \_ = np.histogram(source\_channel, bins=255, range=(0, 255), density=True)
 target\_histogram, \_ = np.histogram(target\_channel, bins=255, range=(0, 255), density=True)
 cumulative\_source\_histogram = np.cumsum(source\_histogram)
 cumulative\_target\_histogram = np.cumsum(target\_histogram)
 input\_values = cumulative\_source\_histogram \* 255
 output\_values = cumulative\_target\_histogram \* 255
 return input\_values, output\_values

def create\_curve(input\_values, output\_values):
 curve = interp1d(input\_values, output\_values, bounds\_error=False, fill\_value=(output\_values[0], output\_values[-1]))
 return curve

def apply\_r\_curve\_transformation(source\_grayscale, target\_grayscale):
 source\_images = get\_images(source\_grayscale)
 target\_images = get\_images(target\_grayscale)

 for source\_image, target\_image in zip(source\_images, target\_images):
 source\_r\_channel = source\_image[..., 0]
 target\_r\_channel = target\_image[..., 0]
 input\_values, output\_values = get\_curve\_input\_output(source\_r\_channel, target\_r\_channel)
 r\_curve = create\_curve(input\_values, output\_values)
 source\_image[..., 0] = r\_curve(source\_r\_channel)

def apply\_g\_curve\_transformation(source\_grayscale, target\_grayscale):
 source\_images = get\_images(source\_grayscale)
 target\_images = get\_images(target\_grayscale)

 for source\_image, target\_image in zip(source\_images, target\_images):
 source\_g\_channel = source\_image[..., 1]
 target\_g\_channel = target\_image[..., 1]
 input\_values, output\_values = get\_curve\_input\_output(source\_g\_channel, target\_g\_channel)
 g\_curve = create\_curve(input\_values, output\_values)
 source\_image[..., 1] = g\_curve(source\_g\_channel)

def apply\_b\_curve\_transformation(source\_grayscale, target\_grayscale):
 source\_images = get\_images(source\_grayscale)
 target\_images = get\_images(target\_grayscale)

 for source\_image, target\_image in zip(source\_images, target\_images):
 source\_b\_channel = source\_image[..., 2]
 target\_b\_channel = target\_image[..., 2]
 input\_values, output\_values = get\_curve\_input\_output(source\_b\_channel, target\_b\_channel)
 b\_curve = create\_curve(input\_values, output\_values)
 source\_image[..., 2] = b\_curve(source\_b\_channel)

def generate\_3d\_lut(source\_folder, target\_folder, lut\_size, epsilon=1e-5, sigma=1, smoothing\_on=False):
 source\_coordinates = get\_rgb\_coordinates(source\_folder)
 target\_coordinates = get\_rgb\_coordinates(target\_folder)

 # Perform 1st order transformation
 target\_coordinates[:, 0] = apply\_r\_curve\_transformation(source\_coordinates[:, 0], target\_coordinates[:, 0])
 target\_coordinates[:, 1] = apply\_g\_curve\_transformation(source\_coordinates[:, 1], target\_coordinates[:, 1])
 target\_coordinates[:, 2] = apply\_b\_curve\_transformation(source\_coordinates[:, 2], target\_coordinates[:, 2])

 # Create a 100x100x100 3D grid
 x = np.linspace(0, 1, lut\_size)
 y = np.linspace(0, 1, lut\_size)
 z = np.linspace(0, 1, lut\_size)
 grid\_x, grid\_y, grid\_z = np.meshgrid(x, y, z)

 # Flatten the grid for interpolation
 grid\_x = grid\_x.flatten()
 grid\_y = grid\_y.flatten()
 grid\_z = grid\_z.flatten()

 # Use the Rbf method for interpolation for red, green, and blue axis
 rbf\_r = Rbf(source\_coordinates[:, 0], source\_coordinates[:, 1], source\_coordinates[:, 2], target\_coordinates[:, 0], epsilon=epsilon)
 rbf\_g = Rbf(source\_coordinates[:, 0], source\_coordinates[:, 1], source\_coordinates[:, 2], target\_coordinates[:, 1], epsilon=epsilon)
 rbf\_b = Rbf(source\_coordinates[:, 0], source\_coordinates[:, 1], source\_coordinates[:, 2], target\_coordinates[:, 2], epsilon=epsilon)
 target\_rgb\_values = np.array([rbf\_r(grid\_z, grid\_x, grid\_y), rbf\_g(grid\_z, grid\_x, grid\_y), rbf\_b(grid\_z, grid\_x, grid\_y)]).T

 #Guassian Smoothing
 if smoothing\_on:
 target\_rgb\_values = ndimage.gaussian\_filter(target\_rgb\_values, sigma)

 # Write LUT to file
 with open(file\_path, "w") as f:
 f.write(f"# LUT size\nLUT\_3D\_SIZE {lut\_size}\n\n")
 for i, target\_rgb in enumerate(target\_rgb\_values):
 f.write(f"{target\_rgb[0]:.6f} {target\_rgb[1]:.6f} {target\_rgb[2]:.6f}\n")

 #Plot the 3D LUT transformation
 fig = plt.figure()
 ax = fig.add\_subplot(111, projection='3d')
 ax.scatter(target\_rgb\_values[:, 0], target\_rgb\_values[:, 1], target\_rgb\_values[:, 2], c='r', marker='o')
 plt.show()

source\_folder = r"D:\Users\Forrest\Documents\Python\3D LUT\ALEXA\_INPUT\COLOR"
target\_folder = r"D:\Users\Forrest\Documents\Python\3D LUT\FPE\_TARGET\COLOR"

source\_grayscale = r"D:\Users\Forrest\Documents\Python\3D LUT\ALEXA\_INPUT\GRAYSCALE"
target\_grayscale = r"D:\Users\Forrest\Documents\Python\3D LUT\FPE\_TARGET\GRAYSCALE"
file\_path = r"D:\Users\Forrest\Documents\Python\3D LUT\RBF\_LUT\RBF\_with\_Nick.cube"
lut\_size = 16
smooth\_set =False

generate\_3d\_lut(source\_folder, target\_folder, lut\_size)
올바른 디렉토리를 열지 않아서 발생한 것일 수 있습니다. 전체 코드를 공유하고 알려주세요: [...] numpy를 np로 가져옵니다.이미지오 가져오기import os코덱 가져오기matplotlib.pyplot을 plt로 가져옵니다.scipy.interpolate에서 Rbf를 가져옵니다.scipy.interpolate에서 interp1d를 가져옵니다.scipy.ndimage를 ndimage로 가져옵니다.from scipy.stats import normdef get\_images(image\_folder): images = [] for filename in os.listdir(image\_folder): with codecs.open(os.path.join(image\_folder, filename), 'r', encoding='utf-8', errors='ignore') as file: images.append(imageio.imread(file.name)) 이미지 반환def get\_평균\_rgb(image\_path): image = imageio.imread(image\_path) average\_rgb = np.mean(image, axis=(0, 1)) / 255 반환 평균\_rgbdef get\_rgb\_coordinates(image\_folder): RGB\_좌표 = [] for image\_name in os.listdir(image\_folder): image\_path = os.path.join(image\_folder, image\_name) 평균\_rgb = get\_평균\_rgb(이미지\_경로) RGB\_coordinates.append(평균\_RGB) 반환 np.array(rgb\_coordinates)def get\_curve\_input\_output(source\_channel, target\_channel): source\_histogram, \_ = np.histogram(source\_channel, bins=255, range=(0, 255), density=True) target\_histogram, \_ = np.histogram(target\_channel, bins=255, range=(0, 255), density=True) 누적\_소스\_히스토그램 = np.cumsum(소스\_히스토그램) 누적\_대상\_히스토그램 = np.cumsum(대상\_히스토그램) 입력\_값 = 누적\_source\_히스토그램 \* 255 output\_values = 누적\_target\_histogram \* 255 반환 입력\_값, 출력\_값def create\_curve(input\_values, output\_values): curve = interp1d(input\_값, output\_값, bounds\_error=False, fill\_값=(output\_값[0], output\_값[-1])) 반환 커브def apply\_r\_curve\_transformation(source\_grayscale, target\_grayscale): source\_images = get\_images(source\_grayscale) 대상\_이미지 = get\_이미지(대상\_그레이스케일) 소스의 경우 소스\_이미지, 대상\_이미지 = zip(소스\_이미지, 대상\_이미지): source\_r\_channel = source\_image[..., 0] target\_r\_channel = target\_image[..., 0] 입력\_값, 출력\_값 = GET\_CURVE\_입력\_출력(소스\_R\_채널, 대상\_R\_채널) r\_curve = create\_curve(입력\_값, 출력\_값) source\_image[..., 0] = r\_curve(source\_r\_channel)def apply\_g\_curve\_transformation(source\_grayscale, target\_grayscale): source\_images = get\_images(source\_grayscale) 대상\_이미지 = get\_이미지(대상\_그레이스케일) 소스의 경우 소스\_이미지, 대상\_이미지 = zip(소스\_이미지, 대상\_이미지): source\_g\_channel = source\_image[..., 1] target\_g\_channel = target\_image[..., 1] 입력\_값, 출력\_값 = GET\_CURVE\_입력\_출력(소스\_G\_채널, 대상\_G\_채널) g\_curve = create\_curve(input\_values, output\_values) source\_image[..., 1] = g\_curve(source\_g\_channel)def apply\_b\_curve\_transformation(source\_grayscale, target\_grayscale): source\_images = get\_images(source\_grayscale) 대상\_이미지 = get\_이미지(대상\_그레이스케일) 소스의 경우 소스\_이미지, 대상\_이미지 = zip(소스\_이미지, 대상\_이미지): source\_b\_channel = source\_image[..., 2] target\_b\_channel = target\_image[..., 2] 입력\_값, 출력\_값 = GET\_CURVE\_입력\_출력(소스\_B\_채널, 대상\_B\_채널) b\_curve = create\_curve(입력\_값, 출력\_값) source\_image[..., 2] = b\_curve(source\_b\_channel)def generate\_3d\_lut(source\_folder, target\_folder, lut\_size, epsilon=1e-5, sigma=1, smoothing\_on=False): source\_coordinates = get\_rgb\_coordinates(source\_folder) 대상\_좌표 = get\_rgb\_좌표(대상\_폴더) # 1차 변환 수행 target\_coordinates[:, 0] = apply\_r\_curve\_transformation(source\_coordinates[:, 0], target\_coordinates[:, 0]) target\_좌표[:, 1] = apply\_g\_curve\_transformation(source\_좌표[:, 1], target\_좌표[:, 1]) target\_coordinates[:, 2] = apply\_b\_curve\_transformation(source\_coordinates[:, 2], target\_coordinates[:, 2]) # 100x100x100 3D 그리드 만들기 x = np.linspace(0, 1, lut\_size) y = np.linspace(0, 1, lut\_size) z = np.linspace(0, 1, lut\_size) 그리드\_x, 그리드\_y, 그리드\_z = np.meshgrid(x, y, z) # 보간을 위해 그리드를 평평하게 만듭니다. grid\_x = grid\_x.flatten() grid\_y = grid\_y.flatten() grid\_z = grid\_z.flatten() # 빨간색, 녹색 및 파란색 축에 대한 보간에 Rbf 메서드 사용 rbf\_r = Rbf(source\_coordinates[:, 0], source\_coordinates[:, 1], source\_coordinates[:, 2], target\_coordinates[:, 0], epsilon=epsilon) rbf\_g = Rbf(source\_좌표[:, 0], source\_좌표[:, 1], source\_좌표[:, 2], target\_좌표[:, 1], epsilon=epsilon) rbf\_b = Rbf(source\_좌표[:, 0], source\_좌표[:, 1], source\_좌표[:, 2], target\_좌표[:, 2], epsilon=epsilon) target\_rgb\_values = np.array([rbf\_r(grid\_z, grid\_x, grid\_y), rbf\_g(grid\_z, grid\_x, grid\_y), rbf\_b(grid\_z, grid\_x, grid\_y)]).T #구아시안 스무딩 IF 스무딩\_ON: 대상\_RGB\_값 