Author: Nako

Strange Warning with custom render Engine in Blender

Error

WARN (bpy.rna): c:\b\win64_cmake_vs2017\win64_cmake_vs2017\blender.git\source\blender\python\intern\bpy_rna.c:1476 pyrna_enum_to_py: current value ‘3’ matches no enum in ‘SpaceNodeEditor’, ‘(null)’, ‘tree_type’

Similar reports

Custom RenderEngine: Shader Editor issues

There’s also a corner case when having the Shader editor visible (for example when Cycles is active) and then switching to a render engine that has bl_use_shading_nodes_custom=True: the icon for the editor will become blank, but the Shader editor remains visible. In the console I warnings in this case:
WARN (bpy.rna): ../source/blender/python/intern/bpy_rna.c:1451 pyrna_enum_to_py: current value ‘3’ matches no enum in ‘SpaceNodeEditor’, ‘(null)’, ‘tree_type’

https://developer.blender.org/T68473

SpaceNodeEditor error for CustomRenderEngine example

When I activate my custom render engine and switch to the Shading workspace, the node menus disappear and I get the error:
WARN (bpy.rna): c:\b\win64_cmake_vs2017\win64_cmake_vs2017\blender.git\source\blender\python\intern\bpy_rna.c:1449 pyrna_enum_to_py: current value ‘0’ matches no enum in ‘SpaceNodeEditor’, ‘(null)’, ‘tree_type’

https://blenderartists.org/t/spacenodeeditor-error-for-customrenderengine-example/1162743

Cause

The cause is unclear. However, in my case, this error occurs when I access SpaceNodeEditor.tree_type in register() function with the flag “bl_use_shading_nodes_custom” set to True. My solution was one of the following:

  • To set SpaceNodeEditor.tree_type not to be accessed in register() function.
  • Set the flag “bl_use_shading_nodes_custom to False and use my node in ShaderEditor for existing Eevee, Cycles.

Thanks for more information and help…

Chi-Square Test in Python

GOAL

To write program of chi-square test using python. 

What is chi-square test?

Chi-square test which means “Pearson’s chi-square test” here, is a method of statistical hypothesis testing for goodness-of-fit and independence.

Goodness-of-fit test is the testing to determine whether the observed frequency distribution is the same as the theoretical distribution.
Independence test is the testing to determine whether 2 observations that is represented by 2*2 table, on 2 variables are independent of each other.

Details will be longer. Please see the following sites and document.

Implementation

The following is implementation for chi-square test.

Import libraries

import numpy as np
import pandas as pd
import scipy as sp
from scipy import stats

Data preparing

gourp Agroup Bgroup C
success2365158
failure10044119
success rate0.1870.5960.570

chi_square_data.csv

A,B,C
23,65,158
100,44,119

Read and Set Data

csv_line = []
with open('chi_square_data.csv', ) as f:
    for i in f:
        items = i.split(',')
        for j in range(len(items)):
            if '\n' in items[j]:
                items[j] =float(items[j][:-1])
            else:
                items[j] =float(items[j])
        csv_line.append(items)
group = csv_line[0]
success = [int(n) for n in csv_line[1]]
failure = [int(n) for n in csv_line[2]]

groups = [] 
result =[]
count = []
for i in range(len(group)):
    groups += [group[i], group[i]] #['A','A', 'B', 'B', 'C', 'C']
    result += ['success', 'failure'] #['success', 'failure', 'success', 'failure', 'success', 'failure']
    count += [success[i], failure[i]] #[23, 100, 65, 44, 158, 119]
    
data =  pd.DataFrame({
    'groups' : groups,
    'result' : result,
    'count' : count
})
cross_data = pd.pivot_table(
    data = data,
    values ='count',
    aggfunc = 'sum',
    index = 'groups',
    columns = 'result'
)
print(cross_data)
>>result  failure  success
groups                  
A           100       23
B            44       65
C           119      158

Chi-square test

print(stats.chi2_contingency(cross_data, correction=False))
>> (57.23616422920877, 3.726703617716424e-13, 2, array([[ 63.554,  59.446],
       [ 56.32 ,  52.68 ],
       [143.126, 133.874]]))
  • chi2 : 57.23616422920877
    • The test statistic
  • p : 3.726703617716424e-13
    • The p-value of the test
  • dof : 2
    • Degrees of freedom
  • expected : array
    • The expected frequencies, based on the marginal sums of the table.

The smaller the p-value, the stronger the evidence that you should reject the null hypothesis.
When statistically significant, that is, p-value is less than 0.05 (typically ≤ 0.05), the difference between groups is significant.

How Can I change the language in Windows10?

GOAL

Change language in Windows10

Environment

Windows10

Method

Open setting window.

Click “Time & Language”.

Click and open “language” panel. Then select windows display language.

If the system doesn’t have language set you want, add a preferred language.

Paired One-way ANOVA And Multiple Comparisons In Python

GOAL

To write program of paired one-way ANOVA(analysis of variance) and multiple comparisons using python. Please refer another article “Unpaired One-way ANOVA And Multiple Comparisons In Python” for unpaired one-way ANOVA.

What is ANOVA

ANOVA(analysis of variance) is a method of statistical hypothesis testing that determines the effects of factors and interactions, which analyzes the differences between group means within a sample.
Details will be longer. Please see the following site.

One-way ANOVA is ANOVA test that compares the means of three or more samples. Null hypothesis is that samples in groups were taken from populations with the same mean.

Implementation

The following is implementation example of paired one-way ANOVA.

Import Libraries

Import libraries below for ANOVA test.

import statsmodels.api as sm
from statsmodels.formula.api import ols
import pandas as pd
import numpy as np
import statsmodels.stats.anova as anova

Data Preparing

id_1id_2id_3id_4id_5id_6id_7
condition A85908869789887
condition B55826764785449
condition C46955980527370

test_data.csv

85, 90, 88, 69, 78, 98, 87
55, 82, 67, 64, 78, 54, 49
46, 95, 59, 80, 52, 73, 70

Read and Set Data

csv_line = []
with open('test_data.csv', ) as f:
    for i in f:
        items = i.split(',')
        for j in range(len(items)):
            if '\n' in items[j]:
                items[j] =float(items[j][:-1])
            else:
                items[j] =float(items[j])
        print(items)
        csv_line.append(items)
groupA = csv_line [0]
groupB = csv_line [1]
groupC = csv_line [2]
tdata = pd.DataFrame({'A':groupA, 'B':groupB, 'C':groupC})
tdata.index = range(1,10)
tdata 

If you want to display data summary, use DataFrame.describe().

tdata.describe()

ANOVA

subjects=['id1','id2','id3','id4','id5','id6','id7']
points = np.array(groupA +groupB + groupC)
conditions = np.repeat(['A','B','C'],len(group0))
subjects = np.array(subjects+subjects+subjects)
df = pd.DataFrame({'Point':points,'Conditions':conditions,'Subjects':subjects})
aov=anova.AnovaRM(df, 'Point','Subjects',['Conditions'])
result=aov.fit()

print(result)

>>                 Anova
========================================
           F Value Num DF  Den DF Pr > F
----------------------------------------
Conditions  5.4182 2.0000 12.0000 0.0211
========================================

The smaller the p-value, the stronger the evidence that you should reject the null hypothesis.
When statistically significant, that is, p-value is less than 0.05 (typically ≤ 0.05), perform a multiple comparison. This p value is different between paired ANOVA and unpaired ANOVA.

Tukey’s multiple comparisons

Use pairwise_tukeyhsd(endog, groups, alpha=0.05) for tuky’s HSD(honestly significant difference) test. Argument endog is response variable, array of data (A[0] A[1]… A[6] B[1] … B[6] C[1] … C[6]). Argument groups is list of names(A, A…A, B…B, C…C) that corresponds to response variable. Alpha is significance level.

def tukey_hsd(group_names , *args ):
    endog = np.hstack(args)
    groups_list = []
    for i in range(len(args)):
        for j in range(len(args[i])):
            groups_list.append(group_names[i])
    groups = np.array(groups_list)
    res = pairwise_tukeyhsd(endog, groups)
    print (res.pvalues) #print only p-value
    print(res) #print result
print(tukey_hsd(['A', 'B', 'C'], tdata['A'], tdata['B'],tdata['C']))
>> [0.02259466 0.06511251 0.85313142]
 Multiple Comparison of Means - Tukey HSD, FWER=0.05 
=====================================================
group1 group2 meandiff p-adj   lower    upper  reject
-----------------------------------------------------
     A      B -20.8571 0.0226 -38.9533 -2.7609   True
     A      C -17.1429 0.0651 -35.2391  0.9533  False
     B      C   3.7143 0.8531 -14.3819 21.8105  False
-----------------------------------------------------
None

What is Node and NodeTree in Blender?

GOAL

To explain the words “Node” and “NodeTree” in Blender. This article doesn’t contain detail of each nodes and their usage.

What is Node?

Node is a data processing mechanism that has zero or more input sockets and output sockets and processing function.

@ 2020 Nako

Nodes can be connected to each other.

@ 2020 Nako

Blender Nodes has Title, Sockets, Properties. Click Blender document for detail.

from Blender Node Editor

What is Node Tree

Node Tree is the whole structure consists of connected nodes.

Node type in Blender

There are three types of node trees and node editor in Blender, Shade Nodes, Composite Nodes and Texture Nodes. Please refer to Blender 2.80 Manual “Introduction” for detail.

Shader Nodes

Materials, lights and backgrounds are all defined using a network of shading nodes. These nodes output values, vectors, colors and shaders.

Blender Document: Shader Nodes (https://docs.blender.org/manual/en/dev/render/shader_nodes/introduction.html )

Composite Nodes

Compositing Nodes allow you to assemble and enhance an image (or movie). Using composition nodes, you can glue two pieces of footage together and colorize the whole sequence all at once.You can enhance the colors of a single image or an entire movie clip in a static manner or in a dynamic way that changes over time (as the clip progresses).

Blender Document: Compositing Nodes
( https://docs.blender.org/manual/en/dev/compositing/introduction.html )

Texture Nodes

Blender includes a node-based texture generation system, which enables textures creation by combining colors, patterns and other textures in the same way as shader writing with material nodes.

Blender Document: Texture Nodes
( https://docs.blender.org/manual/en/dev/editors/texture_node/introduction.html )

How to manipulate Nodes?

You can manipulate Nodes and create node network with different types of node editors. The basic operation method of node editor is here.

NodeTree in PythonAPI

The word “NodeTree” is also used in Blender PythonAPI( https://docs.blender.org/api/current/bpy.types.NodeTree.html ). bpy.types.NodeTree(ID) class, which has nodes attribute and links attribute, can get NodeTree specified by the ID. Nodes is bpy_prop_collection of nodesthat make up the node tree. Links is bpy_prop_collection of links to connect the nodes.

What is “getattr()” in Python?

GOAL

To understand getattr() function in python.

getattr(Object, name [, default])

Return the value of the named attribute of objectname must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, getattr(x, 'foobar') is equivalent to x.foobar. If the named attribute does not exist, default is returned if provided, otherwise AttributeError is raised.

Python document > library > functions

What will happen

The following is sample code with Dog class and getattr().

class Dog():
    def __init__(self, name, age):
        self.name = name
        self.age = age
    def sit(self):
        self.tired = False
        print("sit down")
    def bark(self, count):
        self.tired = True
        for i in range(count):
            print("bow wow")

dog1 = Dog("Poppy", 3)
val1 = getattr(dog1, "name")
val2 = getattr(dog1, "age")
val3 = getattr(dog1, "tired", "unknown")
val4 = getattr(dog1, "sit")()
val5 = getattr(dog1, "bark")(2)
val6 = getattr(dog1, "sit")
val7 = getattr(dog1, "bark")
val8 = getattr(dog1, "tired", "unknown")

Get attribute

# val1 = getattr(dog1, "name")
print(val1)
>> Poppy
# val2 = getattr(dog1, "age")
print(val2)
>> 3

Get default value

# val3 = getattr(dog1, "tired", "unknown")
print(val3)
>> unknown

Execute function

# val4 = getattr(dog1, "sit")()
print(val4)
>> None
# val5 = getattr(dog1, "bark")(2)
print(val5)
>> None

Get function

# val6 = getattr(dog1, "sit")
print(val6)
>> <bound method Dog.sit of <__main__.Dog object at 0x7f192a93f1d0>>
val6()
>> sit down
# val7 = getattr(dog1, "bark")
print(val7)
>> <bound method Dog.bark of <__main__.Dog object at 0x7fb2169ae1d0>>
val7(3)
>> bow wow
>> bow wow
>> bow wow

After Executing function

# val8 = getattr(dog1, "tired", "unknown")
print(val8)
>> True

getattr(dog1, sit)() and getattr(dog1, bark)(2) changed internal variable “tired”.

What is color manager

GOAL

To understand color space and color manager.

What is color manager?

Color manager (also called “color management system” or “management solution”) is an application to change the color space of image and video.

In VFX production, many color spaces are used according to the tools such as digital cinema camera, rendered CG, photos and matte paint. it is necessary to unify or convert the color space. Color space conversion is an important process in VFX production.

What is color space?

Color space is a specific organization of colors in which colors are represented as coordinates.

Color model

Color model is an abstract mathematical model describing colors with some channels ( e.g. RGB, CMYK). Although color model is not the same thing as color space, some color system such as Adobe RGB and sRGB are based on color model.

Representative color space

Color spaces in Adobe Photoshop Color Picker
Comparison of some RGB and CMYK colour gamut on a CIE 1931 xy chromaticity diagram, based on http://commons.wikimedia.org/wiki/File:CIE1931xy_blank.svg and data from Blatner and Fraser’s “Real World Photoshop CS”, p179: http://canopuscomputing.com.au/gallery2/d/8631-1/Gamuts_comparison-B_F.jpg . ( CC BY-SA 3.0 )

sRGB

sRGB (standard Red Green Blue) is an RGB color space to use mainly on monitors, printers, and the Internet. The color gamut that can be represented in this method is the color triangle defined by three primary colors, Red, Green and Blue.

CIE 1931 xy chromaticity diagram showing the gamut of the sRGB color space and location of the primaries.( CC BY-SA 3.0)
* This image is colored in sRGB space, so the colors outside of the triangle are interpolated.

Adobe RGB

Adobe RGB is a color space definition proposed by Adobe Systems. It has a wider RGB color reproduction range than sRGB (especially green), designed to cover most of the colors achievable with CMYK color printers. It encompasses about 50% of the visible colors specified in the CIELAB color space.

The CIE 1931 xy chromaticity diagram showing the primaries of the Adobe RGB (1998) color space. The CIE Standard Illuminant D65 white point is shown in the center.( CC BY-SA 3.0)

NTSC (BT.601)

NTSC Color Space is designed for television. It features a color gamut that is much wider than sRGB.While NTSC is not used in modern displays, it is commonly used to compare and specify color gamut.
This is also one of the major television formats in the world including PAL, SECAM.

Rec.2020

ITU-R Recommendation BT.2020 aka Rec.2020 or BT.2020 defines various aspects of ultra-high-definition television (UHDTV) with standard dynamic range (SDR) and wide color gamut (WCG).
It defines picture resolutions, frame rates with progressive scan, bit depths, color primaries, RGB and luma-chroma color representations, chroma subsamplings, and an opto-electronic transfer function. full HD and HDR are not supported.

Rec.2100

Rec.2100 is upward compatible with Rec.2020. ITU-R Recommendation BT.2100 aka Rec.2100 or BT.2100 is an international standard for specifications that must be met by devices that handle full HD(2K), 4K and 8K resolutions. It was established by the International Telecommunication Union Wireless Communication Sector (ITU-R).

CMYK(or just CMY)

CMYK uses subtractive color mixing used in the printing process.
CMYK corresponds to Ink colors, Cyan, Magenta, Yellow and Black.

HSV 

HSV(HueSaturationValue) is used for painting or color sample on computers. Painting artists use it because it is more natural and intuitive to consider colors in terms of hue, color and saturation than additive mixing or subtractive mixing. HSV is a transformation of an RGB color space. HSV is also called HSB (hue, saturation, brightness).

HSL

HSL (hue, saturation, lightness / luminance) is quite similar to HSV, with “lightness” replacing “brightness”. The difference is a value calculation method. HSV uses a hexagonal pyramid model in which the brightness of pure color is equal to the brightness of white, while HLS uses a bi-hexagonal pyramid model in which the brightness of pure color is 50% of the brightness of white.(Please refer this image). It is also called HSI (hue, saturation, intensity).

LMS

LMS color place is based on three kinds of cone cells that human eye with normal vision has. These cone cells sense light and have peaks of spectral sensitivity in Short wavelength, Middle wavelength and Long wavelength.
The three parameters corresponding to levels of stimulus of the three kinds of cone cells(L, M, S) describe any human color sensation. So LMS color space can contain all visible colors.
However LMS is not objective representation of colors because parameters L, M and S is different between people and emvironment.

CIE 1931 color spaces

CIE (Commission internationale de l’éclairage, the International Commission on Illumination) is the organization that creates international standards related to light and color.
CIE 1931 color spaces is the first defined quantitative relations between distributions of wavelengths in the electromagnetic visible spectrum, and physiologically perceived colors.

The CIE XYZ is remap of the color space in which the tristimulus values ​​are conceptualized as amounts of three primary colors.These primary colors are unvisible for human. The CIE XYZ color space is designed so that Y component corresponds to luminance.
CIE XYZ can contain all visible colors.While RGB can’t represent some of visible colors without using negative value, CIE XYZ can contain all visible colors in positive quadrant.

Why is color management needed?

©2020 Nako

When you transfer exported video to another media, color gamut remapping, gamma correction, setting of white chromaticity (white point) are required and so on.

What is ACES?

ACES(Academy Color Encoding System) is a color image encoding system created under the auspices of the Academy of Motion Picture Arts and Sciences. The system defines its own primary color that encompass the visible spectral locus as defined by the CIE xyY specification.

When you use ACES in Video editing software such as Adobe AfterEffects , Maya and Nuke, color manager is needed. Color manager is usually provided as a plugin or built-in function.

Representative Color manager

OpenColorIO

OpenColorIO (OCIO) is a complete color management solution geared towards motion picture production with an emphasis on visual effects and computer animation.

OpenColorIO official web site( https://opencolorio.org/ )

OCIO is compatible with ACES and is LUT-format agnostic, supporting many popular formats.

SynColor

SynColor is the Autodesk Color Management component.

Adobe Color Management Module(CMM)

CMM is color manager for Adobe software such as Photoshop.

2020 Event Schedule

あけましておめでとうございます。良き一年になりますように。

2020年の画像処理、CG、VFX、AR、VR、人工知能、アニメーション、映画などに関わるイベントをまとめました。国際的なイベントのみについては、英語版の2020 Event Scheduleをご覧ください。

1月

2月

3月

4月

5月

6月

7月

  • SIGGRAPH
  • MANGA都市TOKYO ニッポンのマンガ・アニメ・ゲーム・特撮2020

8月

  • ECCV
    • 8/23-28
    • Glasgow’s Scottish Event Campus (SEC), GLASGOW
    • One of the top conference on Computer Vision
    • https://eccv2020.eu/

9月

  • CEDEC 2020
    • 9/2(水)-9/4日(金)
    • パシフィコ横浜ノース
    • コンピュータエンターテインメントデベロッパーズカンファレンス
    • https://cedec.cesa.or.jp/2020/koubo

10月

11月

12月

2020 Event Schedule

Happy New Year! I hope we have a wonderful year.

I summarized some events that will be held in 2020 related to Image processing, CG, VFX, AR, VR, Artificial Intelligence, Animation, Adobe, Creative, Movie and so on.

January

February

March

April

May

June

July

August

  • ECCV
    • 8/23-28
    • Glasgow’s Scottish Event Campus (SEC), GLASGOW
    • One of the top conference on Computer Vision
    • https://eccv2020.eu/

September

October

November

December

homebrew install Error

Problem

An error “Permission denied @ apply2files – /usr/local/share/ghostscript/9.23/Resource/CIDFSubst/Deng.ttf” occurred when I tried to update homebrew.

What is homebrew?

Homebrew is a package management system to install and update software for macOS.
(Official link: https://brew.sh/index_en)

What is ghostscript?

Homebrew is a package management system to install and update software for macOS.
(Official link: https://brew.sh/index_en)
Ghostscript is invoked and started by other software including homebrew.

The Resource / CIDFSubst directory is a directory to store TrueType fonts (but there is no problem here).

Cause of the error

Because the error message says “Permission denied”, the current user does not have access. So it seems that homebrew cannot use the required files.

Solution

As an immediate solution, give access to the ghostscript directory with the following command. You will be prompted for a password.

sudo chown -R <UserName>:admin /usr/local/share/ghostscript

Now you can run without error. It remains unclear why the access was lost.