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
Container Registry
Model registry
Operate
Environments
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
Sébastien Peillet
otb
Commits
645ecf8c
Commit
645ecf8c
authored
7 years ago
by
Antoine Regimbeau
Browse files
Options
Downloads
Patches
Plain Diff
BUG : memory leak fixed
parent
12545ffb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx
+25
-18
25 additions, 18 deletions
.../Applications/AppFiltering/app/otbContrastEnhancement.cxx
with
25 additions
and
18 deletions
Modules/Applications/AppFiltering/app/otbContrastEnhancement.cxx
+
25
−
18
View file @
645ecf8c
...
...
@@ -32,6 +32,7 @@
#include
"otbComputeHistoFilter.h"
#include
"otbComputeGainLutFilter.h"
#include
"otbApplyGainFilter.h"
#include
"otbImageFileWriter.h"
namespace
otb
{
...
...
@@ -47,35 +48,35 @@ class LuminanceOperator
typedef
FloatImageType
::
PixelType
OutPixel
;
typedef
FloatVectorImageType
::
PixelType
InPixel
;
public:
LuminanceOperator
()
{
m_Rgb
=
new
int
[
3
]
;
m_LumCoef
=
new
float
[
3
]
;
}
LuminanceOperator
()
{}
virtual
~
LuminanceOperator
()
{
}
OutPixel
operator
()
(
InPixel
input
)
{
{
OutPixel
out
;
out
=
(
m_LumCoef
[
0
]
*
input
[
m_Rgb
[
0
]]
+
\
m_LumCoef
[
1
]
*
input
[
m_Rgb
[
1
]]
+
\
m_LumCoef
[
2
]
*
input
[
m_Rgb
[
2
]]
)
;
out
=
m_LumCoef
[
0
]
*
input
[
m_Rgb
[
0
]]
+
m_LumCoef
[
1
]
*
input
[
m_Rgb
[
1
]]
+
m_LumCoef
[
2
]
*
input
[
m_Rgb
[
2
]]
;
return
out
;
}
// end operator ()
void
SetRgb
(
int
rgb
[]
)
void
SetRgb
(
std
::
vector
<
int
>
rgb
)
{
m_Rgb
=
rgb
;
}
void
SetLumCoef
(
float
lumCoef
[]
)
void
SetLumCoef
(
std
::
vector
<
float
>
lumCoef
)
{
m_LumCoef
=
lumCoef
;
}
std
::
vector
<
float
>
GetLumCoef
()
{
return
m_LumCoef
;
}
private
:
int
*
m_Rgb
;
float
*
m_LumCoef
;
std
::
vector
<
int
>
m_Rgb
;
std
::
vector
<
float
>
m_LumCoef
;
};
// end of functor class MultiplyOperator
...
...
@@ -288,7 +289,7 @@ private:
else
if
(
mode
==
"lum"
)
{
int
rgb
[
3
]
;
std
::
vector
<
int
>
rgb
(
3
,
0
)
;
rgb
[
0
]
=
GetParameterInt
(
"mode.lum.red.ch"
);
rgb
[
1
]
=
GetParameterInt
(
"mode.lum.gre.ch"
);
rgb
[
2
]
=
GetParameterInt
(
"mode.lum.blu.ch"
);
...
...
@@ -522,10 +523,10 @@ private:
// Compute the luminance with user parameters
void
ComputeLuminance
(
const
FloatVectorImageType
::
Pointer
inImage
,
int
rgb
[]
)
std
::
vector
<
int
>
rgb
)
{
// Retreive the coeff for each chanel
float
lumCoef
[
3
]
;
std
::
vector
<
float
>
lumCoef
(
3
,
0.0
)
;
lumCoef
[
0
]
=
GetParameterFloat
(
"mode.lum.red.coef"
);
lumCoef
[
1
]
=
GetParameterFloat
(
"mode.lum.gre.coef"
);
lumCoef
[
2
]
=
GetParameterFloat
(
"mode.lum.blu.coef"
);
...
...
@@ -543,13 +544,16 @@ private:
m_luminanceFilter
=
LuminanceFilter
::
New
()
;
m_luminanceFilter
->
GetFunctor
().
SetRgb
(
rgb
);
m_luminanceFilter
->
GetFunctor
().
SetLumCoef
(
lumCoef
);
// std::cout<<m_luminanceFilter->GetFunctor().GetLumCoef()[0]<<std::endl;
// std::cout<<m_luminanceFilter->GetFunctor().GetLumCoef()[1]<<std::endl;
// std::cout<<m_luminanceFilter->GetFunctor().GetLumCoef()[2]<<std::endl;
m_luminanceFilter
->
SetInput
(
inImage
);
}
// Equalize the lumiance and apply the corresponding gain on each chanel
// used to compute this luminance
void
LuminanceEqualization
(
const
ImageListType
::
Pointer
inputImageList
,
const
int
rgb
[]
,
const
std
::
vector
<
int
>
rgb
,
ImageListType
::
Pointer
outputImageList
)
{
m_filterLut
.
resize
(
1
);
...
...
@@ -565,7 +569,10 @@ private:
m_RAMWriter
[
0
]
,
m_luminanceFilter
->
GetOutput
()
,
max
,
min
);
ImageFileWriter
<
FloatImageType
>::
Pointer
writer
(
ImageFileWriter
<
FloatImageType
>::
New
());
writer
->
SetInput
(
m_luminanceFilter
->
GetOutput
());
writer
->
SetFileName
(
"/home/antoine/dev/my_data/anaglum.tif"
);
writer
->
Update
();
for
(
int
chanel
=
0
;
chanel
<
3
;
chanel
++
)
{
m_filterGain
[
chanel
]
=
FilterGainType
::
New
();
...
...
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