Skip to content

Commit

Permalink
added remove_outlier_pixels method to image readers
Browse files Browse the repository at this point in the history
takes care of pixels where the sensor malfunctions and creates an
anomolous bright spot
  • Loading branch information
dicengine committed Aug 22, 2019
1 parent f390848 commit a25a9ad
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/base/DICe.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ const char* const compute_image_gradients = "compute_image_gradients";
/// String parameter name
const char* const filter_failed_cine_pixels = "filter_failed_cine_pixels";
/// String parameter name
const char* const remove_outlier_pixels = "remove_outlier_pixels";
/// String parameter name
const char* const convert_cine_to_8_bit = "convert_cine_to_8_bit";
/// String parameter name
const char* const initial_condition_file = "initial_condition_file";
Expand Down Expand Up @@ -1233,12 +1235,17 @@ const Correlation_Parameter filter_failed_cine_pixels_param(filter_failed_cine_p
BOOL_PARAM,
false,
"Filter out any pixels that failed during cine acquisition");
/// Correlation parameter and properties
const Correlation_Parameter remove_outlier_pixels_param(remove_outlier_pixels,
BOOL_PARAM,
false,
"Remove outlier pixel intensities (usually due to failed pixels)");


// TODO don't forget to update this when adding a new one
/// The total number of valid correlation parameters
/// Vector of valid parameter names
const int_t num_valid_correlation_params = 88;
const int_t num_valid_correlation_params = 89;
/// Vector oIf valid parameter names
const Correlation_Parameter valid_correlation_params[num_valid_correlation_params] = {
correlation_routine_param,
Expand Down Expand Up @@ -1317,6 +1324,7 @@ const Correlation_Parameter valid_correlation_params[num_valid_correlation_param
rotate_def_image_270_param,
levenberg_marquardt_regularization_factor_param,
filter_failed_cine_pixels_param,
remove_outlier_pixels_param,
time_average_cine_ref_frame_param,
global_regularization_alpha_param,
global_stabilization_tau_param,
Expand Down
28 changes: 28 additions & 0 deletions src/utils/src/DICe_ImageIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ void read_image(const char * file_name,
}
// apply any post processing of the images as requested
if(params!=Teuchos::null){
if(params->get<bool>(remove_outlier_pixels,false)){
remove_outliers(width,height,intensities);
}
if(params->get<bool>(spread_intensity_histogram,false)){
spread_histogram(width,height,intensities);
}
Expand All @@ -313,6 +316,31 @@ void round_intensities(const int_t width,
}
}


DICE_LIB_DLL_EXPORT
void remove_outliers(const int_t width,
const int_t height,
intensity_t * intensities){

std::vector<intensity_t> sorted_intensities(width*height,0.0);
for(int_t i=0;i<width*height;++i)
sorted_intensities[i] = intensities[i];
std::sort(sorted_intensities.begin(),sorted_intensities.end());
const intensity_t outlier_intens = 0.98 * sorted_intensities[width*height-1];
intensity_t replacement_intens = 0.0;
for(int_t i=0;i<width*height;++i){
if(sorted_intensities[width*height-i-1] < outlier_intens){
replacement_intens = sorted_intensities[width*height-i-1];
break;
}
}
DEBUG_MSG("utils::remove_outliers(): outlier intensity value: " << outlier_intens << " to be replaced with intensity: " << replacement_intens);
for(int_t i=0;i<width*height;++i){
if(intensities[i]>=outlier_intens)
intensities[i] = replacement_intens;
}
}

DICE_LIB_DLL_EXPORT
void floor_intensities(const int_t width,
const int_t height,
Expand Down
10 changes: 10 additions & 0 deletions src/utils/src/DICe_ImageIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ void round_intensities(const int_t width,
const int_t height,
intensity_t * intensities);

/// Set the intensity value for outlier pixels (the ones with the highest intensity value) to the second highest value
/// This is helpful in removing failed cine pixels
/// \param width
/// \param height
/// \param intensities
DICE_LIB_DLL_EXPORT
void remove_outliers(const int_t width,
const int_t height,
intensity_t * intensities);

/// Round the image intensity values to the nearest integer value
/// \param width
/// \param height
Expand Down
3 changes: 2 additions & 1 deletion tools/DICe_CineToTiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ int main(int argc, char *argv[]) {

// filter out failed cine pixels
Teuchos::RCP<Teuchos::ParameterList> params = Teuchos::rcp(new Teuchos::ParameterList());
params->set(filter_failed_cine_pixels,true);
params->set(remove_outlier_pixels,true);
params->set(spread_intensity_histogram,true);

for(int_t i=start_frame;i<=end_frame;++i){
int_t num_digits_total = 0;
Expand Down

0 comments on commit a25a9ad

Please sign in to comment.