Skip to content

Commit

Permalink
Made threaded triangulation and transforming standard. Also added an …
Browse files Browse the repository at this point in the history
…option for normalizing the images on input.
  • Loading branch information
Zack Moratto committed Aug 7, 2009
1 parent 737486c commit 72b6cde
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
46 changes: 36 additions & 10 deletions src/Isis/StereoSessionIsis.cc
Expand Up @@ -249,6 +249,7 @@ void StereoSessionIsis::pre_preprocessing_hook(std::string const& input_file1, s
min_max_channel_values(create_mask(right_disk_image), right_lo, right_hi);
}
vw_out(InfoMessage) << "\t Right: [" << right_lo << " " << right_hi << "]\n";

float lo = std::min (left_lo, right_lo);
float hi = std::min (left_hi, right_hi);

Expand All @@ -268,9 +269,17 @@ void StereoSessionIsis::pre_preprocessing_hook(std::string const& input_file1, s
// Create the geotransform objects and determine the common size
// of the output images and apply it to the right image.
GeoTransform trans2(input_georef2, common_georef);
ImageViewRef<PixelGray<float> > Limg = normalize(remove_isis_special_pixels(left_disk_image, lo), lo, hi, 0, 1.0);
ImageViewRef<PixelGray<float> > Rimg = crop(transform(normalize(remove_isis_special_pixels(right_disk_image, lo),lo,hi,0.0,1.0),trans2),common_bbox);

ImageViewRef<PixelGray<float> > Limg;
ImageViewRef<PixelGray<float> > Rimg;
if (stereo_settings().individually_normalize == 0 ) {
Limg = normalize(remove_isis_special_pixels(left_disk_image, lo), lo, hi, 0, 1.0);
Rimg = crop(transform(normalize(remove_isis_special_pixels(right_disk_image, lo), lo, hi, 0, 1.0),trans2),common_bbox);
} else {
vw_out(0) << "\t--> Individually normalizing.\n";
Limg = normalize(remove_isis_special_pixels(left_disk_image, left_lo));
Rimg = crop(transform(normalize(remove_isis_special_pixels(right_disk_image, right_lo)),trans2),common_bbox);
}

// Write the results to disk.
write_image(output_file1, channel_cast_rescale<uint8>(Limg), TerminalProgressCallback(ErrorMessage, "Left map-projected image: " ));
write_image(output_file2, channel_cast_rescale<uint8>(Rimg), TerminalProgressCallback(ErrorMessage, "Right map-projected image: "));
Expand All @@ -284,19 +293,36 @@ void StereoSessionIsis::pre_preprocessing_hook(std::string const& input_file1, s
Matrix<double> align_matrix(3,3);
align_matrix.set_identity();
if (stereo_settings().keypoint_alignment)
align_matrix = determine_image_alignment(input_file1, input_file2, lo, hi);
align_matrix = determine_image_alignment(input_file1, input_file2,
lo, hi);
::write_matrix(m_out_prefix + "-align.exr", align_matrix);

// Apply the alignment transformation to the right image.
ImageViewRef<PixelGray<float> > Limg = normalize(remove_isis_special_pixels(left_disk_image, lo),lo,hi,0.0,1.0);
ImageViewRef<PixelGray<float> > Rimg = transform(normalize(remove_isis_special_pixels(right_disk_image,lo),lo,hi,0.0,1.0),
HomographyTransform(align_matrix),
left_disk_image.cols(), left_disk_image.rows());
ImageViewRef<PixelGray<uint8> > Limg;
ImageViewRef<PixelGray<uint8> > Rimg;
if (stereo_settings().individually_normalize == 0 ) {
Limg = channel_cast_rescale<uint8>(normalize(remove_isis_special_pixels(left_disk_image, lo),lo,hi,0.0,1.0));
Rimg = channel_cast_rescale<uint8>(transform(normalize(remove_isis_special_pixels(right_disk_image,lo),lo,hi,0.0,1.0),
HomographyTransform(align_matrix),
left_disk_image.cols(), left_disk_image.rows()));
} else {
vw_out(0) << "\t--> Individually normalizing.\n";
Limg = channel_cast_rescale<uint8>(normalize(remove_isis_special_pixels(left_disk_image, left_lo)));
Rimg = channel_cast_rescale<uint8>(transform(normalize(remove_isis_special_pixels(right_disk_image,right_lo)),
HomographyTransform(align_matrix),
left_disk_image.cols(), left_disk_image.rows()));
}

// Write the results to disk.
vw_out(0) << "\t--> Writing pre-aligned images.\n";
write_image(output_file1, channel_cast_rescale<uint8>(Limg), TerminalProgressCallback(ErrorMessage, "\t Left: "));
write_image(output_file2, channel_cast_rescale<uint8>(Rimg), TerminalProgressCallback(ErrorMessage, "\t Right: "));
{
DiskImageResourceGDAL left_rsrc( output_file1, Limg.format() );
block_write_image( left_rsrc, Limg, TerminalProgressCallback(ErrorMessage, "\t Left: "));
}
{
DiskImageResourceGDAL right_rsrc( output_file2, Rimg.format() );
block_write_image( right_rsrc, Rimg, TerminalProgressCallback(ErrorMessage, "\t Right: "));
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/Isis/StereoSessionIsis.h
Expand Up @@ -105,7 +105,9 @@ class StereoSessionIsis: public StereoSession {
static StereoSession* construct() { return new StereoSessionIsis; }

private:
vw::math::Matrix<double> determine_image_alignment(std::string const& input_file1, std::string const& input_file2, float lo, float hi);
vw::math::Matrix<double> determine_image_alignment(std::string const& input_file1,
std::string const& input_file2,
float lo, float hi );

};

Expand Down
1 change: 1 addition & 0 deletions src/StereoSettings.cc
Expand Up @@ -98,6 +98,7 @@ StereoSettings::StereoSettings() {
ASSOC_INT("DO_EPIPOLAR_ALIGNMENT", epipolar_alignment, 1, "Align images using epipolar constraints");
ASSOC_INT("DO_INTERESTPOINT_ALIGNMENT", keypoint_alignment, 0, "Align images using the keypoint alignment method");
ASSOC_INT("INTERESTPOINT_ALIGNMENT_SUBSAMPLING", keypoint_align_subsampling, 1, "Image sub-sampling factor for keypoint alignment.");
ASSOC_INT("DO_INDIVIDUAL_NORMALIZATION", individually_normalize, 0, "Normalize each image individually before processsing.");

// Correlation Options
ASSOC_INT("DO_SLOG", slog, 1, "perform an slog (relpace the emboss)");
Expand Down
1 change: 1 addition & 0 deletions src/StereoSettings.h
Expand Up @@ -46,6 +46,7 @@ class StereoSettings {
int epipolar_alignment; /* Align images using the epipolar constraints */
int keypoint_alignment; /* Align images using the keypoint alignment method */
int keypoint_align_subsampling; // if > 1, image sub-sampling factor for keypoint aligment (to speed things up)
int individually_normalize; // if > 1, normalize the images individually with their own hi's and low. Default = 0 means we pick a global high and low.

// Correlation Options
int slog; /* perform an slog (relpace the emboss) */
Expand Down
2 changes: 1 addition & 1 deletion src/stereo.cc
Expand Up @@ -766,7 +766,7 @@ int main(int argc, char* argv[]) {
point_cloud_rsrc.set_block_size(Vector2i(std::min(1024,point_cloud.cols()),
std::min(1024, point_cloud.rows())));

write_image(point_cloud_rsrc, point_cloud, TerminalProgressCallback(ErrorMessage, "\t--> Triangulating: "));
block_write_image(point_cloud_rsrc, point_cloud, TerminalProgressCallback(ErrorMessage, "\t--> Triangulating: "));
vw_out(0) << "\t--> " << universe_radius_func;
} catch (IOErr &e) {
cout << "\nUnable to start at point cloud stage -- could not read input files.\n" << e.what() << "\nExiting.\n\n";
Expand Down

0 comments on commit 72b6cde

Please sign in to comment.