03806d0b67
This commit implements described in the #104573. The goal is to fix the confusion of the submodule hashes change, which are not ideal for any of the supported git-module configuration (they are either always visible causing confusion, or silently staged and committed, also causing confusion). This commit replaces submodules with a checkout of addons and addons_contrib, covered by the .gitignore, and locale and developer tools are moved to the main repository. This also changes the paths: - /release/scripts are moved to the /scripts - /source/tools are moved to the /tools - /release/datafiles/locale is moved to /locale This is done to avoid conflicts when using bisect, and also allow buildbot to automatically "recover" wgen building older or newer branches/patches. Running `make update` will initialize the local checkout to the changed repository configuration. Another aspect of the change is that the make update will support Github style of remote organization (origin remote pointing to thy fork, upstream remote pointing to the upstream blender/blender.git). Pull Request #104755
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
# This sample shows the 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: Inverse 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()
|