Isis 3.0 Object Programmers' Reference |
Home |
00001 #include "MoravecOperator.h" 00002 #include "Chip.h" 00003 00004 namespace Isis { 00012 double MoravecOperator::Interest(Chip &chip) { 00013 int height = chip.Lines(); 00014 int width = chip.Samples(); 00015 std::vector<double> interests; 00016 double smallestInterest = 0.0; 00017 00018 // Create offsets for comparison of different areas of the chip 00019 for(int offX = -1; offX <= 1; offX++) { 00020 for(int offY = -1; offY <= 1; offY++) { 00021 // doesnt do work if offset would be center chip 00022 if(offX == 0 && offY == 0) continue; 00023 // Do interest computation between center and offset areas and store into array 00024 double interest = 0.0; 00025 for(int y = 2; y <= height - 1; y++) { 00026 for(int x = 2; x <= width - 1; x++) { 00027 // If either pixel is special ignore difference 00028 if(ValidDnValue(chip.GetValue(x, y)) && ValidDnValue(chip.GetValue(x + offX, y + offY))) { 00029 interest += std::pow(chip.GetValue(x, y) - chip.GetValue(x + offX, y + offY), 2); 00030 } 00031 } 00032 } 00033 // Initialize smallest interest with first value 00034 if(interests.size() == 1) { 00035 smallestInterest = interest; 00036 } 00037 interests.push_back(interest); 00038 } 00039 } 00040 // find smallest interest and return 00041 for(unsigned int i = 0; i < interests.size(); i++) { 00042 if(interests[i] < smallestInterest) { 00043 smallestInterest = interests[i]; 00044 } 00045 } 00046 return smallestInterest; 00047 } 00048 00055 int MoravecOperator::Padding() { 00056 return 2; 00057 } 00058 } 00059 extern "C" Isis::InterestOperator *MoravecOperatorPlugin(Isis::Pvl &pPvl) { 00060 return new Isis::MoravecOperator(pPvl); 00061 }