6d70e9b05f
- "Frame Step" -> "Number of frames to skip forward while baking each frame": expand description which was just copying the prop name. - "b-bone" -> "B-Bone": title case. - "Volumes Lighting" -> "Volume Lighting": typo. - "Volumes Shadows" -> "Volume Shadows": typo. - "Insert Blank Keyframe (All Layer)" -> "(All Layers)": typo. - "the an" -> "an", typo. - "Inverse" -> "Invert": use verb instead of noun for an action. - "Desination" -> "Destination": typo. - "Hides all other F-Curves other than the ones being framed": remove extra "other". - "Remove Bone from Bone collections" -> "Collection", singular because the operator is only applied to the active collection. Also title case on "Collection". - "Change Stroke material with selected material" -> "Assign the active material slot to the selected strokes": rephrase by reusing the message from the non-Grease Pencil materials. - "VisAction", "VisArea" -> "Visibility Action", "Visibility Area": expand abbreviation. This is not exposed in the UI right now but will show up in the API docs. - "Stop Mode Right / Global Down" -> "Stop Move" (typo). - "... for node input %s": remove extra space. - "Move along their normal" -> "Move shadows along their normal": rephrase unclear sentence. - "Stat Vis" -> "Mesh Analysis": stands for "Statistical visualization"? Unclear and not shown anywhere. Reuse the label specified in the UI code instead. - " Output data...": remove leading space. - "Attribute domain for the selection and group id inputs": title case on "Selection" and "Group ID" as that is how they appear in the UI. - "Ior" -> "IOR": uppercase acronym, for consistency. Pull Request: https://projects.blender.org/blender/blender/pulls/115964
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
# This sample shows an efficient way of doing image processing
|
|
# over Blender's images using Python.
|
|
|
|
import bpy
|
|
import numpy as np
|
|
|
|
|
|
input_image_name = "Image"
|
|
output_image_name = "NewImage"
|
|
|
|
# Retrieve input image.
|
|
input_image = bpy.data.images[input_image_name]
|
|
w, h = input_image.size
|
|
|
|
# Allocate a numpy array to manipulate pixel data.
|
|
pixel_data = np.zeros((w, h, 4), 'f')
|
|
|
|
# Fast copy of pixel data from bpy.data to numpy array.
|
|
input_image.pixels.foreach_get(pixel_data.ravel())
|
|
|
|
# Do whatever image processing you want using numpy here:
|
|
# Example 1: Invert red green and blue channels.
|
|
pixel_data[:, :, :3] = 1.0 - pixel_data[:, :, :3]
|
|
# Example 2: Change gamma on the red channel.
|
|
pixel_data[:, :, 0] = np.power(pixel_data[:, :, 0], 1.5)
|
|
|
|
# Create output image.
|
|
if output_image_name in bpy.data.images:
|
|
output_image = bpy.data.images[output_image_name]
|
|
else:
|
|
output_image = bpy.data.images.new(output_image_name, width=w, height=h)
|
|
|
|
# Copy of pixel data from numpy array back to the output image.
|
|
output_image.pixels.foreach_set(pixel_data.ravel())
|
|
output_image.update()
|