Terra Lib 5 Terra View 5 Raster Processing
Terra. Lib 5 / Terra. View 5 Raster Processing Eric Silva Abreu
Índice • Classes Básicas • • Raster Grid Band. Property • Raster Processing • Algoritmos • Interfaces • Exemplos • Hands On
Raster • Um RASTER é composto por uma ou mais bandas. • Cada BANDA é descrita por um BANDPROPERTY. • Um RASTER também possui um GRID que descreve sua espacialidade.
Band Property Algumas das informações contidas nessa classe são: • • • Indice da banda. Tipo do dados elementos da banda. Valor mínimo contido na banda. Valor máximo contido na banda. Média e desvio padrão dos valores da banda. Valor que representa o dummy. Valores de ganho e offset da banda. Tipo fotométrico da banda. Paleta de cores.
Grid As informações contidas nessa classe são: • • • O box do raster. Identificação da projeção associada ao raster (EPSG). Informação do número de colunas. Informação do número de linhas. Lista de 6 coeficientes que descrevem uma transformação afim para mapear uma posição em linha x coluna para uma coordenada georeferenciada.
Open Raster std: : map<std: : string, std: : string> rinfo; rinfo["URI"] = "/dir/myfile. tif"; te: : rst: : Raster* r = te: : rst: : Raster. Factory: : make(); r->open(rinfo, te: : common: : RAccess); // your code manipulating the raster goes here! delete r;
Create a new Raster te: : rst: : Grid* grid = new te: : rst: : Grid(. . . ); te: : rst: : Band. Property* b 1 = new te: : rst: : Band. Property(. . . ); te: : rst: : Band. Property* b 2 = new te: : rst: : Band. Property(. . . ); te: : rst: : Band. Property* b 3 = new te: : rst: : Band. Property(. . . ); std: : vector<te: : rst: : Band. Property*> bands; bands. push_back(b 1); bands. push_back(b 2); bands. push_back(b 3); std: : map<std: : string, std: : string> rinfo; rinfo["URI"] = "/dir/myfile. tif"; te: : rst: : Raster* r = te: : rst: : Raster. Factory: : make(grid, bands, rinfo); // R is ready for working!! delete r;
Raster Access double value; std: : complex<double> cvalue; // cvalue. real() is the real part, and cvalue. imag() is the imaginary part std: : vector<std: : complex<double> > values; // for example, to get the value in position (10, 50) from band 2 in myraster // method 1, using Raster class myraster->get. Value(10, 50, value, 2); // method 2, using Raster class myraster->get. Value(10, 50, cvalue, 2); value = cvalue. real(); // method 3, using vector of complex data in Raster class myraster->get. Values(10, 50, values); value = values[2]. real(); // method 4, using Band class myraster->get. Band(2)->get. Value(10, 50, value);
Operations - Resampling Os métodos de interpolação disponíveis na Terralib são: • Bicubico: considera 16 pixesl (4 x 4) para a interpolação, criando um resultado suavizado. É o método mais lento. • Bilinear: considera os 4 pixels mais próximos (2 x 2) e interpola usando a média ponderada. Os pesos são definidos pela distância do vizinho. • Vizinho mais próximo: esta interpolação cria um novo valor de pixel copiando o valor do vizinho mais próximo. É o método mais rápido, mas cria artefatos.
Operations - Resampling // load input raster std: : map<std: : string, std: : string> rinfo; rinfo["URI"] = "input. tif"; te: : rst: : Raster* inraster = te: : rst: : Raster. Factory: : open(rinfo); // define output raster name std: : map<std: : string, std: : string> orinfo; orinfo["URI"] = "output-resampling-nn. tif"; // applies the interpolation using neares neighbor technique te: : rst: : Raster* nnraster = inraster->resample(te: : rst: : Interpolator: : Nearest. Neighbor, 2, orinfo); // clean up delete inraster; delete nnraster;
Operations - Cropping Esta operação permite cortar um raster, criando uma nova imagem. Essa operação é feita através da função Trim da classe
Operations - Cropping // load input raster std: : map<std: : string, std: : string> rinfo; rinfo["URI"] = "input. tif"; te: : rst: : Raster* inraster = te: : rst: : Raster. Factory: : open(rinfo); // set envelope based on line/column te: : gm: : Coord 2 D cur = inraster->get. Grid()->grid. To. Geo(299, 150); te: : gm: : Coord 2 D cll = inraster->get. Grid()->grid. To. Geo(100, 299); te: : gm: : Envelope* blenv = new te: : gm: : Envelope(cll. x, cll. y, cur. x, cur. y); // define output raster parameters std: : map<std: : string, std: : string> orinfo; orinfo["URI"] = "output-crop. tif"; // perform trim operation te: : rst: : Raster* outraster = inraster->trim(blenv, orinfo); // clean up delete inraster; delete outraster;
Operations - Reprojection Esta operação reprojeta o raster para uma outra projeção. // load the input raster std: : map<std: : string, std: : string> rinfo; rinfo["URI"] = "input. tif"; te: : rst: : Raster* inraster = te: : rst: : Raster. Factory: : open(rinfo); // define raster output parameters std: : map<std: : string, std: : string> orinfo; orinfo["URI"] = "output-reprojection. tif"; // call reprojection with changing SRID to 4326 (WGS 84) te: : rst: : Raster* outraster = te: : rst: : Reproject(inraster, 4326, orinfo); // clean up delete inraster; delete outraster;
Raster Processing Para utilizar os algoritmos desse módulo são necessários: • Carregar imagem de entrada, • Definir os parametros especificos do algoritmo, • Definir a imagem de saída. Após a definição dos parâmetros, dois métodos devem ser utilizados para a correta execução do algoritmo. • Initialize: Verifica a consistencia dos parametros. • Execute: Executa o algoritmo.
Raster Processing // open input raster std: : map<std: : string, std: : string> rinfo; rinfo["URI"] = "input. tif"; te: : rst: : Raster* rin = te: : rst: : Raster. Factory: : open(rinfo); // link specific parameters with chosen implementation te: : rp: : Contrast: : Input. Parameters cont. Input. Parameters; cont. Input. Parameters. m_type = te: : rp: : Contrast: : Input. Parameters: : Linear. Contrast. T; cont. Input. Parameters. m_in. Raster. Ptr = rin; for (unsigned b = 0; b < rin->get. Number. Of. Bands(); b++) { cont. Input. Parameters. m_in. Raster. Bands. push_back(b); cont. Input. Parameters. m_l. CMin. Input. push_back(100); cont. Input. Parameters. m_l. CMax. Input. push_back(200); } // set output raster for linear contrast std: : map<std: : string, std: : string> orinfo; orinfo["URI"] = "output-linear-contrast. tif"; te: : rp: : Contrast: : Output. Parameters cont. Output. Parameters; cont. Output. Parameters. m_created. Out. Raster. Info = orinfo; cont. Output. Parameters. m_created. Out. Raster. DSType = "GDAL"; // execute the algorithm te: : rp: : Contrast continstance; bool initok = continstance. initialize(cont. Input. Parameters); if (initok) continstance. execute(cont. Output. Parameters); // clean up delete rin;
Raster Processing • Plugin para o Terra. View Interfaces padrão Wizard Seleção do Dado de Entrada Parâmetros do Algoritmo Definição do Dado de Saída
Raster Processing - Wizard Seleção dos dados de entrada Definição do dado de saída
Arithmetic Operations //!< Input rasters vector. std: : vector< te: : rst: : Raster* > m_input. Rasters; //!< Arithmetic string. std: : string m_arithmetic. String; //!< Output values normalization will be performed bool m_normalize; //!< The raster interpolator method (default: Nearest. Neighbor). te: : rst: : Interpolator: : Method m_interp. Method;
Classifier //!< Input raster. te: : rst: : Raster const* m_input. Raster. Ptr; //!< Bands to be processed from the input raster. std: : vector<unsigned int> m_input. Raster. Bands; //!< The polygons to be classified when using objectbased image analysis std: : vector<te: : gm: : Polygon*> m_input. Polygons; //!< The classifier strategy name see each te: : rp: : Classifier. Strategy. Factory std: : string m_strategy. Name;
Classifier
Clipping //!< The envelope (inside original extent) to crop the raster. te: : gm: : Envelope* m_env; //!< The parameters needed to build the output raster. std: : map<std: : string, std: : string> m_rinfo;
Color Transformation param input. RGBRaster The input raster. te: : rst: : Raster& input. RGBRaster param red. Band. Idx The red band index. Unsigned int red. Band. Idx; param green. Band. Idx The red band index. unsigned int green. Band. Idx; param blue. Band. Idx The red band index. unsigned int blue. Band. Idx; param rgb. Range. Min The minimum RGB value. double rgb. Range. Min; param rgb. Range. Max The maximum RGB value. double rgb. Range. Max; param output. IHSRaster An output pré-initiated raster te: : rst: : Raster& output. IHSRaste;
Composition param feeder Input rasters feeder. te: : rp: : Feeder. Const. Raster& feeder; param input. Raster. Bands Input raster bands std: : vector< unsigned int >& input. Raster. Bands; param interp. Method The interpolator method to use. te: : rst: : Interpolator: : Method& interp. Method; param output. Raster. Info Output raster connection info. std: : map<std: : string, std: : string>& output. Raster. Info; param output. Data. Source. Type Output raster datasource type. std: : string& output. Data. Source. Type; param output. Raster. Ptr A pointer to the generated output raster. std: : auto_ptr< te: : rst: : Raster >& output. Raster. Ptr;
Contrast //!< The contrast type to be applied. Contrast. Type m_type; //!< Input raster. te: : rst: : Raster const* m_in. Raster. Ptr; //!< Bands to be processed from the input raster. std: : vector< unsigned int > m_in. Raster. Bands; //!< The parameters for each Constrast Type, Ex: Linear //!< The contrast minimum input greyscale value of each band. std: : vector< double > m_l. CMin. Input; //!< The contrast maximum input greyscale value of each band. std: : vector< double > m_l. CMax. Input;
Filter //!< The edge filter type. Filter. Type m_filter. Type; //!< Input raster. te: : rst: : Raster const* m_in. Raster. Ptr; //!< Bands to be used from the input raster 1. std: : vector< unsigned int > m_in. Raster. Bands; //!< The number of iterations to perform. unsigned int m_iterations. Number; //!< The height of the convolution window. unsigned int m_window. H; //!< The width of the convolution window. unsigned int m_window. W; //!< User defined convolution window. boost: : numeric: : ublas: : matrix<double> m_window; Original Passa Baixa Detecção de bordas
Fusion //!< Input low-resolution multi-band raster. te: : rst: : Raster const* m_low. Res. Raster. Ptr; //!< The low-resolution raster red band index. unsigned int m_low. Res. Raster. Red. Band. Index; //!< The low-resolution raster green band index. unsigned int m_low. Res. Raster. Green. Band. Index; //!< The low-resolution raster blue band index. unsigned int m_low. Res. Raster. Blue. Band. Index; //!< Input high-resolution raster. te: : rst: : Raster const* m_high. Res. Raster. Ptr; //!< Band to process from the high-resolution raster. unsigned int m_high. Res. Raster. Band; //!< The raster interpolator method te: : rst: : Interpolator: : Method m_interp. Method;
Mixture Model //!< Input raster. te: : rst: : Raster const* m_input. Raster. Ptr; //!< Bands to be processed from the input raster. std: : vector<unsigned int> m_input. Raster. Bands; //!< The names of the sensor/bands. std: : vector<std: : string> m_input. Sensor. Bands; //!< A set of endmembers and its radiances. std: : map<std: : string, std: : vector<double> > m_components; //!< The mixture model strategy name std: : string m_strategy. Name; //!< Internal specific mixture model strategy parameters. Strategy. Parameters* m_mixture. Model. Strategy. Params. Ptr;
Mosaic //!< Input rasters feeder. Feeder. Const. Raster* m_feeder. Raster. Ptr; //!< Bands to process for each input raster. std: : vector< unsigned int > > m_input. Rasters. Bands; //!< The raster interpolator method. te: : rst: : Interpolator: : Method m_interp. Method; //!< The pixel value used where no raster data is avaliable (defaul: 0). double m_no. Data. Value; //!< If true, m_no. Data. Value will be used bool m_force. Input. No. Data. Value; //!< The pixel blending method. te: : rp: : Blender: : Blend. Method m_blend. Method; //!< Auto equalization will be performed bool m_auto. Equalize; //!< Enable or disable the use of raster caching. bool m_use. Raster. Cache; //!< Enable/disable the use of threads. bool m_enable. Multi. Thread;
Rasterization param input. Raster Input raster. te: : rst: : Raster& input. Raster, param input. Raster. Band Input raster band. unsigned int input. Raster. Band, param Created instead of a multi-band raster. bool create. Palette. Raster, param slices. Number The number of historgram slices; unsigned int slices. Number, param eq. Histogram Equalized before the slicing. bool eq. Histogram, param raster. Info The output raster info. std: : map< std: : string, std: : string >& raster. Info, param raster. Type The output raster type std: : string& raster. Type, param palette. Ptr A pointer to an optional user given palette std: : vector< te: : rst: : Band. Property: : Color. Entry >* palette. Ptr, param out. Raster. Ptr The output sliced raster pointer. std: : auto_ptr< te: : rst: : Raster >& out. Raster. Ptr
Register //!< Input raster. te: : rst: : Raster* m_input. Raster. Ptr; //!< Bands to process from the input raster. std: : vector< unsigned int > m_input. Raster. Bands; //!< Tie-points between each raster point std: : vector< te: : gm: : GTParameters: : Tie. Point > m_tie. Points; //!< The output raster SRID (default: 0). int m_output. SRID; //!< The output raster X axis resolution. double m_output. Resolution. X; //!< The output raster Y axis resolution. double m_output. Resolution. Y; //!< The raster interpolator method. te: : rst: : Interpolator: : Method m_interp. Method; //!< The pixel value used for dummy. double m_no. Data. Value; //!< The name of the geometric transformation std: : string m_geom. Transf. Name; //!< An optional bounding box te: : gm: : Envelope m_output. Bounding. Box;
Segmentation //!< Input raster. te: : rst: : Raster const* m_input. Raster. Ptr; //!< Bands to be processed from the input raster. std: : vector< unsigned int > m_input. Raster. Bands; //!< A vector of values of no-data values std: : vector< std: : complex< double > > m_input. Raster. No. Data. Values; //!< Threaded processing will be performed bool m_enable. Threaded. Processing; //!< The maximum number of threads unsigned int m_max. Seg. Threads; //!< Raster will be splitted into blocks bool m_enable. Block. Processing; //!< Blocks with this width unsigned int m_max. Block. Size; //!< Blocks overlapped area unsigned char m_blocks. Overlap. Percent; //!< The segmenter strategy name std: : string m_strategy. Name; //!< Raster data cache. bool m_enable. Raster. Cache;
Vectorization param g A reference to a vector of geometries. std: : vector<te: : gm: : Geometry*>& g param b The band index to vectorize. std: : size_t b param mp Maximum number of geometries generated unsigned int mp
Hands On • Classifier (supervisionada) • Cut (box) • Contrast • Filter (sobel) • Mosaic (geo mosaic, sem cache sem auto equalizer) • Rasterization (municípios) 07/06/16
- Slides: 33