1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
--==========================================================================
--
-- Copyright Insight Software Consortium
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0.txt
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--==========================================================================*/
--
-- WARNING: DO NOT EDIT THIS FILE!
-- THIS FILE IS AUTOMATICALLY GENERATED BY THE SIMPLEITK BUILD PROCESS.
-- Please look at LuaImageFilterTestTemplate.lua.in to make changes.
--
-- This is Lua code to test ${name}
require "SimpleITK"
inputs = 1
$(if number_of_inputs then
OUT=[[inputs = ${number_of_inputs}]]
end)
if #arg < inputs + 2 then
print ( "Usage: ${name} tag <input(s)> output" )
os.exit ( 1 )
end
tag = arg[1];
reader = SimpleITK.ImageFileReader()
writer = SimpleITK.ImageFileWriter()
filter = SimpleITK.${name}()
$(if #tests == 0 then
OUT=[[print ( "No tests defined!" ); os.exit ( 1 );]]
end)
$(foreach tests
if tag == "${tag}" then
$(when settings
$(foreach settings
$(if parameter == "SeedList" and lua_value then
OUT=[[filter:ClearSeeds();
$(for i=1,#lua_value do OUT=OUT .. "\
idx = SimpleITK.VectorUInt32();\
for _,v in ipairs(".. lua_value[i] ..") do idx:push_back(v) end\
filter:AddSeed( idx );"end)]]
elseif parameter == "SeedList" then
OUT=[[filter:ClearSeeds();
$(for i=1,#value do OUT=OUT .. "\
idx = SimpleITK.VectorUInt32();\
for _,v in ipairs(".. value[i] ..") do idx:push_back(v) end\
filter:AddSeed( idx );"end)]]
elseif parameter == "TrialPoints" and lua_value then
OUT=[[filter:ClearTrialPoints();
$(for i=1,#lua_value do OUT=OUT .. "\
idx = SimpleITK.VectorUInt32();\
for _,v in ipairs(".. lua_value[i] ..") do idx:push_back(v) end\
filter:AddTrialPoint( idx );"end)]]
elseif parameter == "TrialPoints" then
OUT=[[filter:ClearTrialPoints();
$(for i=1,#value do OUT=OUT .. "\
idx = SimpleITK.VectorUInt32();\
for _,v in ipairs(".. value[i] ..") do idx:push_back(v) end\
filter:AddTrialPoint( idx );"end)]]
elseif point_vec and point_vec == 1 then
OUT=[[filter:Clear${parameter}();
]]
for i=1,#value do
OUT=OUT .. [[
pts = SimpleITK.VectorUInt32();
for _,v in ipairs(]].. value[i] ..[[) do pts:push_back(v) end
filter:Add${parameter:gsub('s([0-9]?)$','%1')}( pts );]]
end
elseif dim_vec and dim_vec == 1 then
if type == "bool" then
OUT="idx = SimpleITK.VectorBool();"
elseif type == "uint8_t" then
OUT="idx = SimpleITK.VectorUInt8();"
elseif type == "int" then
OUT="idx = SimpleITK.VectorInt32();"
elseif type == "double" then
OUT="idx = SimpleITK.VectorDouble();"
else
OUT="idx = SimpleITK.VectorUInt32();"
end
OUT=OUT.. [[
for _,v in ipairs(]]
if lua_value then
OUT=OUT..'${lua_value}'
else
OUT=OUT..'{'
for i=1,#value-1 do
OUT=OUT..value[i]..", "
end
OUT=OUT..value[#value]..'}'
end
OUT=OUT..[[) do idx:push_back(v) end
filter:Set${parameter}( idx );]]
else
OUT=[[
filter:Set${parameter}( $(if lua_value then OUT='${lua_value}' else OUT='${value}' end) );]]
end)
)
)
inputs = {}
for i=2,#arg-1 do
print( "reading..."..arg[i] );
reader:SetFileName ( arg[i] );
table.insert( inputs, reader:Execute() );
end
$(if inputA_cast then
OUT=[[
inputs[1] = SimpleITK.Cast( inputs[1], SimpleITK.${inputA_cast} );
]]
end)
$(if inputB_cast then
OUT=[[
inputs[2] = SimpleITK.Cast( inputs[2], SimpleITK.${inputB_cast} );
]]
end)
output = filter:Execute ( unpack( inputs ) )
$(if not no_return_image then
OUT=[[
labelIDs = { SimpleITK.sitkLabelUInt8, SimpleITK.sitkLabelUInt16, SimpleITK.sitkLabelUInt32, SimpleITK.sitkLabelUInt64 }
for _,v in pairs( labelIDs ) do
if v == output:GetPixelID() then
output = SimpleITK.LabelMapToLabel(output)
end
end
writer:SetFileName ( arg[#arg] )
writer:Execute ( output )
]]
end)
end
)
|