読み込んだ2次元画像のうち、黒を赤に置換する。
Programmable Filter適用後、Object Inspector上のPropertiesタブにて‘Map Scalars’のチェックを外す。
動作確認バージョン
ParaView 4.2.0
Output Data Set Type
vtkImageData
Script
pdi = self.GetInput() pdo = self.GetOutput() e = pdi.GetExtent() ca = vtk.vtkUnsignedCharArray() ca.SetName('PNGImage') ca.SetNumberOfComponents(3) ca.SetNumberOfTuples((e[1] + 1) * (e[3] + 1)) for i in range(e[3] + 1): for j in range(e[1] + 1): gray = pdi.GetPointData().GetArray('PNGImage').GetValue(i * (e[1] + 1) + j) if gray > 0: ca.SetTuple3(i * (e[1] + 1) + j, gray, gray, gray) else: ca.SetTuple3(i * (e[1] + 1) + j, 255, 0, 0) pdo.GetPointData().SetScalars(ca)
RequestInformation Script
from paraview import util inp = self.GetInput() util.SetOutputWholeExtent(self, inp.GetExtent())
コメントを残す