Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Cabieces
otb
Commits
1a4015c9
Commit
1a4015c9
authored
10 years ago
by
Rashad Kanavath
Browse files
Options
Downloads
Patches
Plain Diff
TEST: test for numpy support
Signed-off-by:
Rashad Kanavath
<
rashad.kanavath@c-s.fr
>
parent
527d2b08
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Modules/Wrappers/SWIG/test/python/CMakeLists.txt
+5
-0
5 additions, 0 deletions
Modules/Wrappers/SWIG/test/python/CMakeLists.txt
Modules/Wrappers/SWIG/test/python/PythonNumpyTest.py
+56
-0
56 additions, 0 deletions
Modules/Wrappers/SWIG/test/python/PythonNumpyTest.py
with
61 additions
and
0 deletions
Modules/Wrappers/SWIG/test/python/CMakeLists.txt
+
5
−
0
View file @
1a4015c9
...
@@ -72,3 +72,8 @@ add_test( NAME pyTvBandMathInXML
...
@@ -72,3 +72,8 @@ add_test( NAME pyTvBandMathInXML
${
TEMP
}
/pyTvBandMathInXML.tif
${
TEMP
}
/pyTvBandMathInXML.tif
)
)
add_test
(
NAME pyTvNumpyIO
COMMAND
${
TEST_DRIVER
}
Execute
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/PythonNumpyTest.py
${
OTB_DATA_ROOT
}
/Input/poupees.tif
${
TEMP
}
/pyTvNumpyIO_
)
This diff is collapsed.
Click to expand it.
Modules/Wrappers/SWIG/test/python/PythonNumpyTest.py
0 → 100644
+
56
−
0
View file @
1a4015c9
import
sys
import
os
#from scipy import misc
import
numpy
as
np
import
otbApplication
#from PIL import Image as PILImage
inFile
=
sys
.
argv
[
1
]
prefix
=
sys
.
argv
[
2
]
# pilimage = PILImage.open(inFile)
# npimage = np.asarray(pilimage)
# print npimage.dtype
ExtractROI
=
otbApplication
.
Registry
.
CreateApplication
(
"
ExtractROI
"
)
ExtractROI
.
SetParameterString
(
"
in
"
,
inFile
)
ExtractROI
.
SetParameterInt
(
"
startx
"
,
10
)
ExtractROI
.
SetParameterInt
(
"
starty
"
,
10
)
ExtractROI
.
SetParameterInt
(
"
sizex
"
,
250
)
ExtractROI
.
SetParameterInt
(
"
sizey
"
,
250
)
#Bug or Design ?.
#Anyway below two is needed only for ExtractROI application
ExtractROI
.
SetParameterUserValue
(
"
sizex
"
,
True
)
ExtractROI
.
SetParameterUserValue
(
"
sizey
"
,
True
)
ExtractROI
.
Execute
()
ExtractROIOut
=
ExtractROI
.
GetVectorImageAsNumpyArray
(
"
out
"
,
'
float
'
)
#write RGB image to file via python
#misc.imsave('ExtractROIOut.jpg', ExtractROIOut)
Rescale
=
otbApplication
.
Registry
.
CreateApplication
(
"
Rescale
"
)
#take numpy array from ExtractROI and feed into Rescale
Rescale
.
SetVectorImageFromNumpyArray
(
"
in
"
,
ExtractROIOut
)
Rescale
.
SetParameterFloat
(
"
outmin
"
,
50
,
True
)
Rescale
.
SetParameterFloat
(
"
outmax
"
,
100
,
True
)
Rescale
.
Execute
()
RescaleOut
=
Rescale
.
GetVectorImageAsNumpyArray
(
"
out
"
,
'
float
'
)
#misc.imsave('RescaleOut.jpg', RescaleOut)
Convert
=
otbApplication
.
Registry
.
CreateApplication
(
"
Convert
"
)
#take numpy output from Rescale application and feed into Convert
Convert
.
SetVectorImageFromNumpyArray
(
"
in
"
,
RescaleOut
)
Convert
.
SetParameterString
(
"
out
"
,
"
ConvertOut.png
"
)
Convert
.
ExecuteAndWriteOutput
()
ConvertOut
=
Convert
.
GetVectorImageAsNumpyArray
(
"
out
"
,
'
float
'
)
Smoothing
=
otbApplication
.
Registry
.
CreateApplication
(
"
Smoothing
"
)
#take numpy output from Convert application and feed into Smoothing
Smoothing
.
SetVectorImageFromNumpyArray
(
"
in
"
,
ConvertOut
)
Smoothing
.
SetParameterString
(
"
type
"
,
'
anidif
'
)
Smoothing
.
SetParameterString
(
"
out
"
,
prefix
+
"
SmoothingOut.png
"
)
Smoothing
.
ExecuteAndWriteOutput
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment