Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
273
Issues
273
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
89497850
Commit
89497850
authored
Oct 09, 2013
by
Julien Michel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: LSMS integration (work in progress)
parent
645ca9c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
15 deletions
+48
-15
Applications/Segmentation/otbLSMSSegmentation.cxx
Applications/Segmentation/otbLSMSSegmentation.cxx
+48
-15
No files found.
Applications/Segmentation/otbLSMSSegmentation.cxx
View file @
89497850
...
...
@@ -196,7 +196,8 @@ private:
unsigned
int
nbTilesX
=
GetParameterInt
(
"nbtilesx"
);
unsigned
int
nbTilesY
=
GetParameterInt
(
"nbtilesy"
);
unsigned
int
step
=
0
;
std
::
vector
<
LabelImageReaderType
::
Pointer
>
localReaders
;
readers
.
clear
();
// Ensure that temporary directory exists if activated:
if
(
IsParameterEnabled
(
"tmpdir"
))
...
...
@@ -212,7 +213,8 @@ private:
ImageType
::
Pointer
spatialIn
;
std
::
vector
<
std
::
string
>
createdFiles
;
std
::
vector
<
std
::
string
>
createdFiles1
;
std
::
vector
<
std
::
string
>
createdFiles2
;
// TODO: Check this
if
(
!
HasValue
(
"inpos"
))
...
...
@@ -240,9 +242,6 @@ private:
sizeImageY
=
imageIn
->
GetLargestPossibleRegion
().
GetSize
()[
1
];
unsigned
int
nbComp
=
imageIn
->
GetNumberOfComponentsPerPixel
();
long
nbStars
=
50
;
unsigned
long
sizeTilesX
=
(
sizeImageX
+
nbTilesX
-
1
)
/
nbTilesX
,
sizeTilesY
=
(
sizeImageY
+
nbTilesY
-
1
)
/
nbTilesY
;
unsigned
long
regionCount
=
0
;
...
...
@@ -337,7 +336,7 @@ private:
joins
.
push_back
(
tileOut
.
str
());
std
::
string
currentFile
=
itksys
::
SystemTools
::
JoinPath
(
joins
);
createdFiles
.
push_back
(
currentFile
);
createdFiles
1
.
push_back
(
currentFile
);
ImageWriter
->
SetInput
(
labelBandMath
->
GetOutput
());
ImageWriter
->
SetFileName
(
currentFile
);
...
...
@@ -346,7 +345,7 @@ private:
LabelImageReaderType
::
Pointer
currentReader
=
LabelImageReaderType
::
New
();
currentReader
->
SetFileName
(
currentFile
);
r
eaders
.
push_back
(
currentReader
);
localR
eaders
.
push_back
(
currentReader
);
tileFusion
->
SetInput
(
nbTile
++
,
currentReader
->
GetOutput
());
}
...
...
@@ -373,7 +372,8 @@ private:
LUT
[
curLabel
]
=
curLabel
;
otbAppLogINFO
(
<<
"LUT creation ..."
);
// Ok for memory (only tile borders are loaded), but problem with
// number of open files)
for
(
unsigned
int
row
=
1
;
row
<
nbTilesY
;
row
++
)
{
unsigned
long
startY
=
row
*
(
sizeTilesY
+
1
);
...
...
@@ -450,6 +450,8 @@ private:
LUT
[
label
]
=
can
;
}
// Cette partie ne sert à rien
for
(
unsigned
int
row
=
0
;
row
<
nbTilesY
;
row
++
)
for
(
unsigned
int
column
=
0
;
column
<
nbTilesX
;
column
++
)
{
...
...
@@ -476,7 +478,7 @@ private:
joins
.
push_back
(
tileOut
.
str
());
std
::
string
currentFile
=
itksys
::
SystemTools
::
JoinPath
(
joins
);
createdFiles
.
push_back
(
currentFile
);
createdFiles
2
.
push_back
(
currentFile
);
ImageWriter
->
SetInput
(
extractROI
->
GetOutput
());
ImageWriter
->
SetFileName
(
currentFile
);
...
...
@@ -490,6 +492,30 @@ private:
tileFusion2
->
SetInput
(
nbTile
++
,
currentReader
->
GetOutput
());
}
localReaders
.
clear
();
// Cleanup
if
(
IsParameterEnabled
(
"cleanup"
))
{
otbAppLogINFO
(
<<
"Cleaning temporary files"
);
for
(
std
::
vector
<
string
>::
const_iterator
it
=
createdFiles1
.
begin
();
it
!=
createdFiles1
.
end
();
++
it
)
{
// Try to remove the geom file if existing
std
::
string
geomfile
=
it
->
substr
(
0
,
it
->
size
()
-
itksys
::
SystemTools
::
GetFilenameExtension
(
it
->
c_str
()).
size
()).
append
(
".geom"
);
if
(
itksys
::
SystemTools
::
FileExists
(
geomfile
.
c_str
()))
{
itksys
::
SystemTools
::
RemoveFile
(
geomfile
.
c_str
());
}
if
(
itksys
::
SystemTools
::
FileExists
(
it
->
c_str
()))
{
itksys
::
SystemTools
::
RemoveFile
(
it
->
c_str
());
}
}
}
tileFusion2
->
GetOutput
()
->
UpdateOutputInformation
();
//Tiles relabelling
...
...
@@ -521,6 +547,7 @@ private:
unsigned
long
sizeX
=
vcl_min
(
sizeTilesX
,
sizeImageX
-
startX
),
sizeY
=
vcl_min
(
sizeTilesY
,
sizeImageY
-
startY
);
ExtractROIFilterType
::
Pointer
extractROI
=
ExtractROIFilterType
::
New
();
// TODO check me
extractROI
->
SetInput
(
changeLabel1
->
GetOutput
());
extractROI
->
SetStartX
(
startX
);
extractROI
->
SetStartY
(
startY
);
...
...
@@ -542,11 +569,17 @@ private:
changeLabel2
->
SetInput
(
changeLabel1
->
GetOutput
());
for
(
LabelImagePixelType
label
=
1
;
label
<
regionCount
+
1
;
++
label
)
if
(
label
!=
newLabel
[
label
])
changeLabel2
->
SetChange
(
label
,
newLabel
[
label
]);
for
(
std
::
vector
<
LabelImageReaderType
::
Pointer
>::
iterator
readIt
=
readers
.
begin
();
readIt
!=
readers
.
end
();
++
readIt
)
{
std
::
cout
<<
(
*
readIt
)
->
GetOutput
()
->
GetBufferedRegion
()
<<
std
::
endl
;
}
readers
.
clear
();
SetParameterOutputImage
(
"out"
,
changeLabel2
->
GetOutput
());
clock_t
toc
=
clock
();
otbAppLogINFO
(
<<
"Elapsed time: "
<<
(
double
)(
toc
-
tic
)
/
CLOCKS_PER_SEC
<<
" seconds"
);
...
...
@@ -555,8 +588,8 @@ private:
if
(
IsParameterEnabled
(
"cleanup"
))
{
otbAppLogINFO
(
<<
"Cleaning temporary files"
);
for
(
std
::
vector
<
string
>::
const_iterator
it
=
createdFiles
.
begin
();
it
!=
createdFiles
.
end
();
++
it
)
for
(
std
::
vector
<
string
>::
const_iterator
it
=
createdFiles
2
.
begin
();
it
!=
createdFiles
2
.
end
();
++
it
)
{
// Try to remove the geom file if existing
std
::
string
geomfile
=
it
->
substr
(
0
,
it
->
size
()
-
itksys
::
SystemTools
::
GetFilenameExtension
(
it
->
c_str
()).
size
()).
append
(
".geom"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment