2016-09-15 3 views
0

문제가 있습니다. 티파니 이미지 (4 개 레이어 있음)가 있습니다. 내 작업은 픽셀의 색상을 약간 변경하여 이미지를 개선하는 것입니다. 이 경우 GDAL 라이브러리를 사용합니다. 내 출처는 다음과 같습니다.GDAL 픽셀 색상을 얻으십시오

GDALDataset *poDataset; 
GDALAllRegister(); 
poDataset = (GDALDataset *) GDALOpen(fileName.toStdString().c_str(), GA_ReadOnly); 
if (poDataset == NULL) { 
    QMessageBox::information(0, "error", "We have problems"); 
} else { 
    QMessageBox::information(0, "Message", "All is ok"); 
} 
int rasterCount = poDataset->GetRasterCount(); // Here is 4 raster images 
GDALRasterBand *band = poDataset->GetRasterBand(1); 
int width = band->GetXSize(); 
int height = band->GetYSize(); 


for (int i = 0; i < width; i++) { 
    for (int j = 0; j < height; j++) { 
     // cross all pixels 
     // How to get pixel color here? 
    } 
} 

그래서 주기적으로 픽셀 색상을 얻는 방법을 모릅니다. 너에게 나에게 충고를 줄 수 있니?

+1

이 질문은, 조언을 주셔서 감사 http://gis.stackexchange.com에 더 적합 – cartant

+0

추가 될 수 있습니다. – lazexe

답변

0

GDAL API에 예제가 없지만 파이썬 라이브러리에서 수행했습니다. 비슷한 논리를 따라 이미지 값을 배열로 가져 와서 루프를 반복하면서 유사한 조건을 적용 할 수 있습니다.

import numpy as np 
from osgeo import gdal 
ds = gdal.Open("test.tif") 
myarray = np.array(ds.GetRasterBand(1).ReadAsArray()) 
... 
관련 문제