gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
write a python script that can transform equirectangular map to 6 faces of cubemap. user…
- User
write a python script that can transform equirectangular map to 6 faces of cubemap. user needs to type path for input (png) and output (png). Add that on export all 6 faces are joined horizontally without spaces. in that order: X+, X-, Y+, Y-, Z+, Z-
- Assistant
Sure! Here's a Python script that takes an equirectangular map and transforms it into a cube map with 6 separate faces. It then joins all the faces horizontally without spaces, in the order: X+, X-, Y+, Y-, Z+, Z-.
from PIL import Image def equirectangular_to_cubemap(input_path, output_path): # Open the input image input_image = Image.open(input_path) width, height = input_image.size # Calculate the size of each face face_size = int(width / 4) # Create a blank cube map image cube_map = Image.new('RGB', (face_size * 6, face_size)) # Crop and paste each face onto the cube map faces = [ (face_size * 2, face_size), # X+ (0, face_size), # X- (face_size, 0), # Y+ (face_size, face_size * 2), # Y- (face_size, face_size), # Z+ (face_size * 3, face_size) # Z- ] for i, face in enumerate(faces): x, y = face face_image = input_image.crop((x, y, x + face_size, y + face_size)) cube_map.paste(face_image, (i * face_size, 0)) # Save the output cube map cube_map.save(output_path) print(f"Cube map saved at: {output_path}") # Example usage input_path = input("Enter the path for the input image (PNG): ") output_path = input("Enter the path for the output cube map (PNG): ") equirectangular_to_cubemap(input_path, output_path)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.