Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ade dua satu hiboos, satu minmax
- 1) void hiboos(char *fileName, Data data){
- ifstream tifFile;
- ofstream lowPassFile, highPassFile, highBoostFile, medianFile;
- double pixelTemp;
- unsigned short pixel, min, max;
- tifFile.open(fileName, ios::binary);
- tifFile.seekg(data.firstData, ios::beg);
- for(int i = 0; i < data.length; i++){
- for(int j = 0; j < data.width; j++){
- tifFile.read((char*) &rawData[i][j],1);
- }
- }
- tifFile.close();
- int c;
- cout << "Enter value c: ";
- cin >> c;
- // High Boost Filtering
- highBoostFile.open("highBoost.raw", ios::binary);
- for(int row=0; row<data.length; row++){
- for(int col=0; col<data.width; col++){
- // Inside Border Pixel
- if(row >= 1 && row <= (data.length - 2) && col >= 1 && col<= (data.width - 2)){
- // Compute
- pixelTemp = ((rawData[row - 1][col - 1] * -1) +
- (rawData[row - 1][col ] * -1) +
- (rawData[row - 1][col + 1] * -1) +
- (rawData[row ][col - 1] * -1) +
- (rawData[row ][col ] * c) +
- (rawData[row ][col + 1] * -1) +
- (rawData[row + 1][col - 1] * -1) +
- (rawData[row + 1][col ] * -1) +
- (rawData[row + 1][col + 1] * -1)) / 9.0;
- // Find 'min' and 'max'
- getMinMax(row, col, min, max);
- // Compute Value for Mapping
- pixelTemp = ((pixelTemp + min) / (min + max)) * 255;
- // Round-off
- pixel = roundOff(pixelTemp);
- }
- // Border Pixel
- else
- pixel = 0;
- highBoostFile.write(reinterpret_cast<char *>(&pixel), 1);
- }
- }
- highBoostFile.close();
- cout << "High Boost files successfully created!\n";
- }
- 2) void getMinMax(int row, int col, unsigned short &min, unsigned short &max){
- min = max = rawData[row - 1][col - 1];
- for(int rowCount = row - 1; rowCount <= row + 1; rowCount++){
- for (int colCount = col - 1; colCount <= col + 1; colCount++){
- if(rawData[rowCount][colCount] < min)
- min = rawData[rowCount][colCount];
- else if(rawData[rowCount][colCount] > max)
- max = rawData[rowCount][colCount];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement