Skip to content

Commit 9f3eb36

Browse files
Merge pull request #1976 from alicevision/dev/cleanupImage
Cleanup image module
2 parents 80c4530 + 3568fb0 commit 9f3eb36

18 files changed

+29
-234
lines changed

src/aliceVision/featureEngine/FeatureExtractor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "FeatureExtractor.hpp"
88
#include <aliceVision/image/io.hpp>
9+
#include <aliceVision/image/imageAlgo.hpp>
910
#include <aliceVision/system/MemoryInfo.hpp>
1011
#include <aliceVision/utils/filesIO.hpp>
1112
#include <aliceVision/alicevision_omp.hpp>

src/aliceVision/fuseCut/PointCloud.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <geogram/mesh/mesh.h>
2020
#include <geogram/basic/geometry_nd.h>
2121

22+
#include <aliceVision/image/imageAlgo.hpp>
23+
2224
namespace aliceVision {
2325
namespace fuseCut {
2426

src/aliceVision/image/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ set(image_files_headers
66
Image.hpp
77
imageAlgo.hpp
88
colorspace.hpp
9-
concat.hpp
109
conversion.hpp
1110
convolutionBase.hpp
1211
convolution.hpp
@@ -17,7 +16,6 @@ set(image_files_headers
1716
io.hpp
1817
jetColorMap.cpp
1918
resampling.hpp
20-
warping.hpp
2119
pixelTypes.hpp
2220
Rgb.hpp
2321
Sampler.hpp

src/aliceVision/image/all.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "aliceVision/image/filtering.hpp"
2020
#include "aliceVision/image/resampling.hpp"
2121
#include "aliceVision/image/diffusion.hpp"
22-
#include "aliceVision/image/concat.hpp"
2322
#include <aliceVision/image/imageAlgo.hpp>
2423
#include "aliceVision/image/io.hpp"
2524
#include "aliceVision/image/convolutionBase.hpp"

src/aliceVision/image/concat.hpp

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/aliceVision/image/conversion.hpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -111,47 +111,5 @@ void ConvertPixelType(const ImageIn& imaIn, ImageOut* imaOut)
111111
Convert(imaIn(j, i), (*imaOut)(j, i));
112112
}
113113

114-
//--------------------------------------------------------------------------
115-
// RGB ( unsigned char or int ) to Float
116-
//--------------------------------------------------------------------------
117-
118-
template<typename Tin, typename Tout>
119-
inline void convertRGB2Float(const Tin& valIn, Tout& valOut, float factor = 1.0f / 255.f)
120-
{
121-
for (int channel = 0; channel < 3; ++channel)
122-
valOut(channel) = (float)((int)(valIn(channel)) * factor);
123-
}
124-
125-
template<typename ImageIn>
126-
void rgb2Float(const ImageIn& imaIn, Image<RGBfColor>* imaOut, float factor = 1.0f / 255.f)
127-
{
128-
assert(imaIn.depth() == 3);
129-
(*imaOut).resize(imaIn.width(), imaIn.height());
130-
// Convert each int RGB to float RGB values
131-
for (int j = 0; j < imaIn.height(); ++j)
132-
for (int i = 0; i < imaIn.width(); ++i)
133-
convertRGB2Float(imaIn(j, i), (*imaOut)(j, i), factor);
134-
}
135-
136-
//--------------------------------------------------------------------------
137-
// Float to RGB ( unsigned char or int )
138-
//--------------------------------------------------------------------------
139-
140-
inline void convertFloatToInt(const RGBfColor& valIn, RGBColor& valOut, float factor = 255.f)
141-
{
142-
for (int channel = 0; channel < 3; ++channel)
143-
valOut(channel) = (int)(valIn(channel) * factor);
144-
}
145-
146-
inline void rgbFloat2rgbInt(const Image<RGBfColor>& imaIn, Image<RGBColor>* imaOut, float factor = 255.f)
147-
{
148-
assert(imaIn.depth() == 3);
149-
(*imaOut).resize(imaIn.width(), imaIn.height());
150-
// Convert each int RGB to float RGB values
151-
for (int j = 0; j < imaIn.height(); ++j)
152-
for (int i = 0; i < imaIn.width(); ++i)
153-
convertFloatToInt(imaIn(j, i), (*imaOut)(j, i), factor);
154-
}
155-
156114
} // namespace image
157115
} // namespace aliceVision

src/aliceVision/image/dcp.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#include <string>
88

99
#include <OpenImageIO/imagebuf.h>
10-
11-
#include <aliceVision/image/all.hpp>
10+
#include <aliceVision/image/Image.hpp>
1211

1312
namespace aliceVision {
1413
namespace image {

src/aliceVision/image/drawing_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// v. 2.0. If a copy of the MPL was not distributed with this file,
66
// You can obtain one at https://mozilla.org/MPL/2.0/.
77

8-
#include "aliceVision/image/all.hpp"
8+
#include "aliceVision/image/drawing.hpp"
99

1010
#define BOOST_TEST_MODULE ImageDrawing
1111

src/aliceVision/image/filtering.hpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -60,49 +60,6 @@ void imageYDerivative(const Image& img, Image& out, const bool normalize = true)
6060
imageVerticalConvolution(img, kernel, out);
6161
}
6262

63-
/**
64-
** Compute X-derivative using 3x3 Sobel kernel
65-
** @param img Input image
66-
** @param out Output image
67-
** @param normalize true if kernel must be scaled by 1/8
68-
**/
69-
template<typename Image>
70-
void imageSobelXDerivative(const Image& img, Image& out, const bool normalize = true)
71-
{
72-
Vec3 kernel_horiz(-1.0, 0.0, 1.0);
73-
74-
if (normalize)
75-
kernel_horiz *= 0.5;
76-
77-
Vec3 kernel_vert(1.0, 2.0, 1.0);
78-
79-
if (normalize)
80-
kernel_vert *= 0.25;
81-
82-
imageSeparableConvolution(img, kernel_horiz, kernel_vert, out);
83-
}
84-
85-
/**
86-
** Compute Y-derivative using 3x3 Sobel kernel
87-
** @param img Input image
88-
** @param out Output image
89-
** @param normalize true if kernel must be scaled by 1/8
90-
**/
91-
template<typename Image>
92-
void imageSobelYDerivative(const Image& img, Image& out, const bool normalize = true)
93-
{
94-
Vec3 kernel_horiz(1.0, 2.0, 1.0);
95-
96-
if (normalize)
97-
kernel_horiz *= 0.25;
98-
99-
Vec3 kernel_vert(-1.0, 0.0, 1.0);
100-
101-
if (normalize)
102-
kernel_vert *= 0.5;
103-
104-
imageSeparableConvolution(img, kernel_horiz, kernel_vert, out);
105-
}
10663

10764
/**
10865
** Compute X-derivative using 3x3 Scharr kernel

src/aliceVision/image/filtering_test.cpp

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
// v. 2.0. If a copy of the MPL was not distributed with this file,
66
// You can obtain one at https://mozilla.org/MPL/2.0/.
77

8-
#include "aliceVision/image/all.hpp"
8+
#include <aliceVision/image/Image.hpp>
9+
#include <aliceVision/image/colorspace.hpp>
10+
#include <aliceVision/image/filtering.hpp>
11+
#include <aliceVision/image/io.hpp>
912

1013
#include <iostream>
1114

@@ -100,42 +103,3 @@ BOOST_AUTO_TEST_CASE(Image_Convolution_Scharr_X_Y)
100103
writeImage("out_ScharrY.png", outFilteredCast, image::ImageWriteOptions().toColorSpace(image::EImageColorSpace::NO_CONVERSION)));
101104
}
102105

103-
BOOST_AUTO_TEST_CASE(Image_Convolution_Sobel_X_Y)
104-
{
105-
Image<float> in(40, 40, true);
106-
in.block(10, 10, 20, 20).fill(255.f);
107-
108-
Image<float> outFiltered(40, 40, true);
109-
110-
imageSobelXDerivative(in, outFiltered);
111-
112-
// X dir
113-
BOOST_CHECK_EQUAL(127.5f, outFiltered(20, 10));
114-
BOOST_CHECK_EQUAL(-127.5f, outFiltered(20, 30));
115-
// Y dir
116-
BOOST_CHECK_EQUAL(0.f, outFiltered(10, 20));
117-
BOOST_CHECK_EQUAL(0.f, outFiltered(30, 20));
118-
// Check it exist a vertical black band
119-
BOOST_CHECK_EQUAL(0.f, outFiltered.block(0, 10 + 3, 40, 20 - 2 * 3).array().abs().sum());
120-
121-
Image<unsigned char> inCast = Image<unsigned char>(in.cast<unsigned char>());
122-
Image<unsigned char> outFilteredCast = Image<unsigned char>(outFiltered.cast<unsigned char>());
123-
BOOST_CHECK_NO_THROW(writeImage("in_Scharr.png", inCast, image::ImageWriteOptions().toColorSpace(image::EImageColorSpace::NO_CONVERSION)));
124-
BOOST_CHECK_NO_THROW(
125-
writeImage("out_SobelX.png", outFilteredCast, image::ImageWriteOptions().toColorSpace(image::EImageColorSpace::NO_CONVERSION)));
126-
127-
outFiltered.fill(0.0f);
128-
imageSobelYDerivative(in, outFiltered);
129-
130-
// X dir
131-
BOOST_CHECK_EQUAL(0.f, outFiltered(20, 10));
132-
BOOST_CHECK_EQUAL(0.f, outFiltered(20, 30));
133-
// Y dir
134-
BOOST_CHECK_EQUAL(127.5f, outFiltered(10, 20));
135-
BOOST_CHECK_EQUAL(-127.5f, outFiltered(30, 20));
136-
// Check it exist a horizontal black band
137-
BOOST_CHECK_EQUAL(0.f, outFiltered.block(10 + 3, 0, 20 - 2 * 3, 40).array().abs().sum());
138-
outFilteredCast = Image<unsigned char>(outFiltered.cast<unsigned char>());
139-
BOOST_CHECK_NO_THROW(
140-
writeImage("out_SobelY.png", outFilteredCast, image::ImageWriteOptions().toColorSpace(image::EImageColorSpace::NO_CONVERSION)));
141-
}

0 commit comments

Comments
 (0)