Permalink
Browse files

Clean up includes and namespaces

This was done in an effort to insure that ASP can be built without BA support. Surprisingly a lot of ASP code makes includes for no particular purpose.
  • Loading branch information...
Zack Moratto
Zack Moratto committed Apr 1, 2010
1 parent 35a56b1 commit d43a5bd9f13c8e3445d4f5270c66ed2738c33baf
Showing with 281 additions and 323 deletions.
  1. +1 −1 configure.ac
  2. +94 −139 src/asp/Core/MedianFilter.h
  3. +5 −4 src/asp/Core/SparseView.h
  4. +0 −1 src/asp/Sessions/RMAX/RMAX.h
  5. +6 −2 src/asp/Tools/stereo.cc
  6. +175 −176 src/asp/Tools/stereo.h
View
@@ -305,7 +305,7 @@ AX_MODULE(CORE, [src/asp/Core], [libaspCore.la], yes, [], [VW_ALL BO
AX_MODULE(SPICEIO, [src/asp/SpiceIO], [libaspSpiceIO.la], yes, [], [VW BOOST_MOST SPICE])
AX_MODULE(ISISIO, [src/asp/IsisIO], [libaspIsisIO.la], yes, [], [ISIS VW_CARTOGRAPHY BOOST])
AX_MODULE(SESSIONS, [src/asp/Sessions], [libaspSessions.la], yes, [CORE], [], [ISISIO SPICEIO])
-AX_MODULE(MPI, [src/asp/MPI], [], no, [ISISIO CORE], [BOOST_SERIALIZATION BOOST_MPI OPEN_MPI VW_ALL])
+AX_MODULE(MPI, [src/asp/MPI], [], no, [VW_BUNDLEADJUSTMENT ISISIO CORE], [BOOST_SERIALIZATION BOOST_MPI OPEN_MPI VW_ALL])
AX_APP(STEREO, [src/asp/Tools], yes, [SESSIONS])
AX_APP(ORTHOPROJECT, [src/asp/Tools], yes, [SESSIONS])
View
@@ -5,186 +5,141 @@
// __END_LICENSE__
-/// \file StereoSession.h
+/// \file MedianFilter.h
///
#ifndef __MEDIAN_FILTER_H__
#define __MEDIAN_FILTER_H__
-typedef uint8 CalcPixelT;
#define CALC_PIXEL_NUM_VALS 256
-CalcPixelT find_median_in_histogram(Vector<int, CALC_PIXEL_NUM_VALS> histogram, int kernSize) {
- int acc = 0;
- int acc_limit = kernSize * kernSize / 2;
+#include <vw/Core/FundamentalTypes.h>
- CalcPixelT i = 0;
+namespace vw {
- for (;;) {
- acc += histogram(i);
+ uint8 find_median_in_histogram(Vector<int, CALC_PIXEL_NUM_VALS> histogram, int kernSize) {
+ int acc = 0;
+ int acc_limit = kernSize * kernSize / 2;
- if (acc >= acc_limit)
- break;
+ uint8 i = 0;
- i++;
- }
+ for (;;) {
+ acc += histogram(i);
- return i;
-}
+ if (acc >= acc_limit)
+ break;
-template<class ImageT>
-ImageView<typename ImageT::pixel_type> fast_median_filter(ImageViewBase<ImageT> const& img, int kernSize) {
- typedef typename ImageT::pixel_type PixelT;
+ i++;
+ }
- ImageView<CalcPixelT> src = pixel_cast_rescale<CalcPixelT>(img.impl());
- ImageView<CalcPixelT> result(src.cols(), src.rows());
+ return i;
+ }
- Vector<int, CALC_PIXEL_NUM_VALS> histogram;
+ template<class ImageT>
+ ImageView<typename ImageT::pixel_type> fast_median_filter(ImageViewBase<ImageT> const& img, int kernSize) {
+ typedef typename ImageT::pixel_type PixelT;
- // Seed histogram
- for (int x = 0; x < kernSize; x++) {
- for (int y = 0; y < kernSize; y++) {
- histogram(src(x, y))++;
+ ImageView<uint8> src = pixel_cast_rescale<uint8>(img.impl());
+ ImageView<uint8> result(src.cols(), src.rows());
+
+ Vector<int, CALC_PIXEL_NUM_VALS> histogram;
+
+ // Seed histogram
+ for (int x = 0; x < kernSize; x++) {
+ for (int y = 0; y < kernSize; y++) {
+ histogram(src(x, y))++;
+ }
}
- }
- bool goingRight = true;
- int x = 0, y = 0;
- //while (y <=src.rows() - kernSize) { //this was a bug
- while (y < src.rows() - kernSize) {
+ bool goingRight = true;
+ int x = 0, y = 0;
+ //while (y <=src.rows() - kernSize) { //this was a bug
+ while (y < src.rows() - kernSize) {
- result(x + kernSize / 2, y + kernSize / 2) = find_median_in_histogram(histogram, kernSize);
+ result(x + kernSize / 2, y + kernSize / 2) = find_median_in_histogram(histogram, kernSize);
- if (goingRight) {
- if (x < src.cols() - kernSize) {
- for (int i = 0; i < kernSize; i++) {
- histogram(src(x, y + i))--;
- histogram(src(x + kernSize, y + i))++;
- }
- x++;
+ if (goingRight) {
+ if (x < src.cols() - kernSize) {
+ for (int i = 0; i < kernSize; i++) {
+ histogram(src(x, y + i))--;
+ histogram(src(x + kernSize, y + i))++;
+ }
+ x++;
- }
- else {
- // Reached the right edge
- for (int i = 0; i < kernSize; i++) {
- histogram(src(x + i, y))--;
- histogram(src(x + i, y + kernSize))++;
}
- goingRight = false;
- y++;
- }
- }
- else {
- if (x > 0) {
- for (int i = 0; i < kernSize; i++) {
- histogram(src(x - 1, y + i))++;
- histogram(src(x + kernSize - 1, y + i))--;
+ else {
+ // Reached the right edge
+ for (int i = 0; i < kernSize; i++) {
+ histogram(src(x + i, y))--;
+ histogram(src(x + i, y + kernSize))++;
+ }
+ goingRight = false;
+ y++;
}
- x--;
}
else {
- // Reached the left edge
- for (int i = 0; i < kernSize; i++) {
- histogram(src(x + i, y))--;
- histogram(src(x + i, y + kernSize))++;
+ if (x > 0) {
+ for (int i = 0; i < kernSize; i++) {
+ histogram(src(x - 1, y + i))++;
+ histogram(src(x + kernSize - 1, y + i))--;
+ }
+ x--;
+ }
+ else {
+ // Reached the left edge
+ for (int i = 0; i < kernSize; i++) {
+ histogram(src(x + i, y))--;
+ histogram(src(x + i, y + kernSize))++;
+ }
+ goingRight = true;
+ y++;
}
- goingRight = true;
- y++;
}
}
- }
- ImageView<PixelT> result_scaled = pixel_cast_rescale<PixelT>(result);
+ ImageView<PixelT> result_scaled = pixel_cast_rescale<PixelT>(result);
- return result_scaled;
+ return result_scaled;
-}
-template<class PixelT>
-class MedianFilterFunctor:public ReturnFixedType<PixelT>
-{
- int m_kernel_width;
- int m_kernel_height;
+ }
+ template<class PixelT>
+ class MedianFilterFunctor:public ReturnFixedType<PixelT>
+ {
+ int m_kernel_width;
+ int m_kernel_height;
-public:
- MedianFilterFunctor(int kernel_width, int kernel_height):
- m_kernel_width(kernel_width),
- m_kernel_height(kernel_height){}
+ public:
+ MedianFilterFunctor(int kernel_width, int kernel_height):
+ m_kernel_width(kernel_width),
+ m_kernel_height(kernel_height){}
- BBox2i work_area() const{ return BBox2i(Vector2i(-m_kernel_width/2, -m_kernel_height/2),
- Vector2i(m_kernel_width/2, m_kernel_height/2)); }
+ BBox2i work_area() const{ return BBox2i(Vector2i(-m_kernel_width/2, -m_kernel_height/2),
+ Vector2i(m_kernel_width/2, m_kernel_height/2)); }
- template<class PixelAccessorT>
- typename PixelAccessorT::pixel_type operator()(PixelAccessorT const& acc) const{
+ template<class PixelAccessorT>
+ typename PixelAccessorT::pixel_type operator()(PixelAccessorT const& acc) const{
- Vector<int, CALC_PIXEL_NUM_VALS> histogram;
+ Vector<int, CALC_PIXEL_NUM_VALS> histogram;
- // Seed histogram
- for (int x = 0; x < m_kernel_width; x++) {
- for (int y = 0; y < m_kernel_height; y++) {
+ // Seed histogram
+ for (int x = 0; x < m_kernel_width; x++) {
+ for (int y = 0; y < m_kernel_height; y++) {
histogram(*acc)++;
- }
- }
- *acc = find_median_in_histogram(histogram, m_kernel_width);
-
- /*
- bool goingRight = true;
- int x = 0, y = 0;
- while (y < src.rows() - kernSize) {
-
- result(x + m_kernel_width / 2, y + m_kernel_height / 2) = find_median_in_histogram(histogram, m_kernel_width);
-
- if (goingRight) {
- if (x < src.cols() - kernSize) {
- for (int i = 0; i < kernSize; i++) {
- histogram(src(x, y + i))--;
- histogram(src(x + kernSize, y + i))++;
- }
- x++;
- }
- else {
- // Reached the right edge
- for (int i = 0; i < kernSize; i++) {
- histogram(src(x + i, y))--;
- histogram(src(x + i, y + kernSize))++;
- }
- goingRight = false;
- y++;
- }
- }
- else {
- if (x > 0) {
- for (int i = 0; i < kernSize; i++) {
- histogram(src(x - 1, y + i))++;
- histogram(src(x + kernSize - 1, y + i))--;
- }
- x--;
- }
- else {
- // Reached the left edge
- for (int i = 0; i < kernSize; i++) {
- histogram(src(x + i, y))--;
- histogram(src(x + i, y + kernSize))++;
- }
- goingRight = true;
- y++;
- }
+ }
}
+ *acc = find_median_in_histogram(histogram, m_kernel_width);
- }
-
- ImageView<PixelT> result_scaled = pixel_cast_rescale<PixelT>(result);
+ return *acc;
+ }
+ };
- return result_scaled;
- */
- return *acc;
- }
-};
+ template<class ViewT>
+ UnaryPerPixelAccessorView<EdgeExtensionView<ViewT, ZeroEdgeExtension>, MedianFilterFunctor<typename ViewT::pixel_type> >
+ my_median_filter(ImageViewBase<ViewT> const& input, int kernel_width, int kernel_height)
+ {
+ return UnaryPerPixelAccessorView<EdgeExtensionView<ViewT, ZeroEdgeExtension>, MedianFilterFunctor<typename ViewT::pixel_type> >(edge_extend(input, ZeroEdgeExtension()), MedianFilterFunctor<typename ViewT::pixel_type> (kernel_width, kernel_height));
+ }
-template<class ViewT>
-UnaryPerPixelAccessorView<EdgeExtensionView<ViewT, ZeroEdgeExtension>, MedianFilterFunctor<typename ViewT::pixel_type> >
-my_median_filter(ImageViewBase<ViewT> const& input, int kernel_width, int kernel_height)
-{
- return UnaryPerPixelAccessorView<EdgeExtensionView<ViewT, ZeroEdgeExtension>, MedianFilterFunctor<typename ViewT::pixel_type> >(edge_extend(input, ZeroEdgeExtension()), MedianFilterFunctor<typename ViewT::pixel_type> (kernel_width, kernel_height));
}
#endif // __MEDIAN_FILTER_H__
@@ -15,6 +15,7 @@
#include <vector>
// VW
+#include <vw/Core/Log.h>
#include <vw/Math/Vector.h>
#include <vw/Image/ImageViewBase.h>
#include <vw/Image/PixelMask.h>
@@ -213,15 +214,15 @@ class SparseView : public vw::ImageViewBase< SparseView<PixelT> > {
// Debug structure
void print_structure( void ) const {
- vw_out() << "SparseView Structure:\n";
+ vw::vw_out() << "SparseView Structure:\n";
for ( vw::uint32 i = 0; i < m_data->size(); i++ ) {
- vw_out() << i << " | ";
+ vw::vw_out() << i << " | ";
for ( typename map_type::const_iterator it = (*m_data)[i].begin();
it != (*m_data)[i].end(); it++ ) {
vw::int32 start = it->first - it->second.size();
- vw_out() << "(" << start << "->" << it->first << ")";
+ vw::vw_out() << "(" << start << "->" << it->first << ")";
}
- vw_out() << "\n";
+ vw::vw_out() << "\n";
}
}
@@ -15,7 +15,6 @@
#include <string>
#include <vw/FileIO/DiskImageResourcePNG.h>
#include <vw/Camera/CAHVORModel.h>
-#include <vw/BundleAdjustment.h>
#include <vw/Core.h>
struct ImageInfo {
View
@@ -11,6 +11,10 @@
#include <asp/Tools/stereo.h>
+using namespace vw;
+using namespace vw::camera;
+using namespace vw::cartography;
+
namespace vw {
template<> struct PixelFormatID<PixelMask<Vector<float, 5> > > { static const PixelFormatEnum value = VW_PIXEL_GENERIC_6_CHANNEL; };
}
@@ -761,8 +765,6 @@ int main(int argc, char* argv[]) {
<< e.what() << "\nExiting.\n\n";
exit(0);
}
-
-
}
@@ -782,6 +784,7 @@ int main(int argc, char* argv[]) {
boost::shared_ptr<camera::CameraModel> camera_model1, camera_model2;
session->camera_models(camera_model1, camera_model2);
+#if HAVE_PKG_VW_BUNDLEADJUSTMENT
// If the user has generated a set of position and pose
// corrections using the bundle_adjust program, we read them in
// here and incorporate them into our camera model.
@@ -801,6 +804,7 @@ int main(int argc, char* argv[]) {
position_correction,
pose_correction));
}
+#endif
// Apply the stereo model. This yields a image of 3D points in
// space. We build this image and immediately write out the
Oops, something went wrong.

0 comments on commit d43a5bd

Please sign in to comment.